Commit Graph

92 Commits (284e8182a402cfd545fc000fedaea071fed873b0)

Author SHA1 Message Date
juanvallejo e11b66a732 update describe command opts struct 2018-04-26 09:42:26 -04:00
juanvallejo 6d3652eded remove hardcoded list of resources 2018-04-26 09:31:58 -04:00
David Eads 66a95a8f3e make describers more generic from the CLI 2018-04-19 16:22:42 -04:00
David Eads f01e16bb3e remove flags deprecated in 1.5 2018-04-19 08:08:44 -04:00
Kubernetes Submit Queue 263897a31c
Merge pull request #58420 from kragniz/valid-resource-printing
Automatic merge from submit-queue (batch tested with PRs 58420, 60483). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

kubectl: make error with resource list prettier

**What this PR does / why we need it**:

Previously, running commands like `kubectl get` with no further
arguments would print a list of valid resource types with an error
messages formatted like so:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.

This commit adds extra spacing so it now looks pretty:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')

    error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.





**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-04-04 05:03:05 -07:00
WanLinghao 7489189c2a supplement for the fix of issue:
https://github.com/kubernetes/kubernetes/issues/60366

	modified:   pkg/kubectl/cmd/describe.go
2018-03-01 16:10:04 +08:00
Louis Taylor b0f8a541fa
kubectl: make error with resource list prettier
Previously, running commands like `kubectl get` with no further
arguments would print a list of valid resource types with an error
messages formatted like so:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.

This commit adds extra spacing so it now looks pretty:

    <snip>
      * serviceaccounts (aka 'sa')
      * services (aka 'svc')
      * statefulsets (aka 'sts')
      * storageclasses (aka 'sc')

    error: Required resource not specified.
    Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
    See 'kubectl get -h' for help and examples.
2018-01-18 22:19:44 +00:00
Di Xu 1c715d51c4 some code change
fix wrong required flags

disable the addition of [flags] to the usage, use customized useline

fix function rename
2017-12-25 16:23:38 +08:00
Clayton Coleman 8f4b6c8771
All commands must declare Unstructured or Internal
Callers must take a dependency on one or the other set of conversions
and default client behavior. Future changes may add a Versioned() type,
but this is an accurate reflection of current code state.
2017-11-19 20:41:02 -05:00
Clayton Coleman 5038eb2a3f
Remove use of VersionedObject and simplify builder in generic methods
Reduce all uses of Unstructured to the simpler form, and avoid asking
for mapper or typer unless it is required. Use Typed() for places that
previously used VersionedObject, and remove paths for versioned objects
from code that is now using unstructured.
2017-11-19 19:16:49 -05:00
Clayton Coleman 98e0c69907 Revert "refactor builder in kubectl factory"
This reverts commit 06c5be9802.
2017-11-19 19:02:21 -05:00
ymqytw 06c5be9802 refactor builder in kubectl factory 2017-11-07 20:16:27 -08:00
Di Xu 057b7bf767 rename selector to labelSelector 2017-11-06 14:30:20 +08:00
Clayton Coleman 93fed120fb
Move printing the valid resource types to a function
Should be calculated from discovery in the future. Also improve
descriptions on the affected commands.
2017-10-30 23:45:45 -04:00
juanvallejo 90d76adb4b
add Local and Unstructured builder attributes
Moves DisabledClientMapperForMapping wrapper to new Local attribute.
Removes Factory#NewUnstructuredBuilder in favor of new Unstructured
builder attribute.
2017-09-05 11:57:00 -04:00
Di Xu be0cadde2e enforce include-uninitialized in several kubectl commands 2017-08-31 16:30:56 +08:00
zhengjiajin 43e3044b73 fix issue(#49883) Add selector example 2017-08-17 20:27:11 +08:00
ymqytw b776df8a20 move i18n to kubectl/util 2017-08-16 12:27:36 -07:00
Alexander Campbell 6fd36c10ad kubectl/cmd: many small refactors
* Rename variables and functions to match Go convention.
   For example, UsageError --> UsageErrorf.
 * Remove redundant or unreachable code.
 * Simplify some utility functions (no functionality changes).
 * Fix hanging 'if { return } else { return }' constructs.
 * Fix several incorrect printf verbs.
2017-06-27 16:25:20 -07:00
juanvallejo d036686185
fix --local flag for `kubectl set` commands 2017-06-13 12:57:05 -04:00
bruceauyeung ab4029c85b Signed-off-by: bruceauyeung <ouyang.qinhua@zte.com.cn>
rename variables to make sure that they conform to golang variable name convention
2017-04-25 15:07:01 +08:00
Kubernetes Submit Queue 19d722671b Merge pull request #43297 from mvdan/kubectl-params
Automatic merge from submit-queue

kubectl/cmd: remove a bunch of unused parameters

Found with github.com/mvdan/unparam.

**Release note**: NONE
2017-04-13 04:07:21 -07:00
Brendan Burns 79f51923d3 Extract a bunch more strings from kubectl 2017-04-06 20:12:50 -07:00
Daniel Martí 810dbc5e98 kubectl/cmd: remove a bunch of unused parameters
Found with github.com/mvdan/unparam.
2017-04-04 10:36:30 +01:00
deads2k 8895f314b4 move category expansion out of restmapper 2017-03-27 13:54:05 -04:00
Clayton Coleman 2aa4abb73b
Refactor commands to use new factory method 2017-02-23 00:28:32 -05:00
Brendan Burns d9c4a289a6 Extract strings for translation. 2017-02-06 22:32:01 -08:00
Jordan Liggitt 06c12f6716
describe: use unstructured objects 2017-01-26 19:59:25 -05:00
deads2k 77b4d55982 mechanical 2017-01-16 09:35:12 -05:00
deads2k 6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
Kubernetes Submit Queue f8dd91fb28 Merge pull request #36541 from juanvallejo/jvallejo/remove-duplicate-describer-errs
Automatic merge from submit-queue (batch tested with PRs 36626, 37294, 37463, 37943, 36541)

Remove duplicate describer errs

Downstream issue https://github.com/openshift/origin/issues/11846

**Release note**:
```release-note
release-note-none
```

The `describe` command iterates through a list of infos received from
the server and aggregates a list of errors while attempting to call each
resource's respective describer. When a resource exists, but does not
have a describer set, such as `Event`, the `describe` command outputs
the same error `error: no description has been implemented for "Event"`
for each info.

```
$ kubectl describe events
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
```

@kubernetes/kubectl @fabianofranz
2016-12-08 00:23:16 -08:00
xilabao b95dcfb424 update label filter prompt 2016-12-05 11:03:21 +08:00
juanvallejo 11ad2cf2ff
Remove duplicate describer errs
The `describe` command iterates through a list of infos received from
the server and aggregates a list of errors while attempting to call each
resource's respective describer. When a resource exists, but does not
have a describer set, such as `Event`, the `describe` command outputs
the same error `error: no description has been implemented for "Event"`
for each info.

```
$ kubectl describe events
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
no description has been implemented for "Event"
```
2016-11-09 16:28:36 -05:00
Fabiano Franz f6d1ac72a0 Use our own normalizers for cmd examples and descriptions 2016-10-17 11:49:55 -02:00
AdoHe b2280a646a update various commands to adapt the new Factory interface 2016-10-13 21:01:14 +08:00
Doug Davis 9d5bac6330 Change minion to node
Contination of #1111

I tried to keep this PR down to just a simple search-n-replace to keep
things simple.  I may have gone too far in some spots but its easy to
roll those back if needed.

I avoided renaming `contrib/mesos/pkg/minion` because there's already
a `contrib/mesos/pkg/node` dir and fixing that will require a bit of work
due to a circular import chain that pops up. So I'm saving that for a
follow-on PR.

I rolled back some of this from a previous commit because it just got
to big/messy. Will follow up with additional PRs

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-09-28 10:53:30 -07:00
Kubernetes Submit Queue 2941069307 Merge pull request #32894 from deads2k/cli-01-remove-arg
Automatic merge from submit-queue

make --include-extended-apis deprecated and remove plumbing

Marks a dead CLI parameter as deprecated and removes the plumbing for it.
2016-09-19 21:11:04 -07:00
deads2k 862415aaa2 make --include-extended-apis deprecated and remove plumbing 2016-09-16 16:05:52 -04:00
ymqytw c67a62da49 Fixes #30562: Refactor kubectl command options to use common struct for common file params 2016-09-12 11:01:37 -07:00
lojies f21c37db64 change to stderr 2016-08-23 14:51:56 +08:00
Kubernetes Submit Queue 3787a068fc Merge pull request #30955 from lojies/modifygetresource
Automatic merge from submit-queue

use valid_resources to replace kubectl.PossibleResourceTypes

```release
Fix resource list printed by kubectl help 
```

 `kubectl get` return 

> 
You must specify the type of resource to get. Valid resource types include:
   * componentstatuses (aka 'cs')
   * configmaps
   * daemonsets (aka 'ds')
   * deployments
   * events (aka 'ev')
   * endpoints (aka 'ep')
   * horizontalpodautoscalers (aka 'hpa')
   * ingress (aka 'ing')
   * jobs
   * limitranges (aka 'limits')
   * nodes (aka 'no')
   * namespaces (aka 'ns')
   * pods (aka 'po')
   * persistentvolumes (aka 'pv')
   * persistentvolumeclaims (aka 'pvc')
   * quota
   * resourcequotas (aka 'quota')
   * replicasets (aka 'rs')
   * replicationcontrollers (aka 'rc')
   * secrets
   * serviceaccounts (aka 'sa')
   * services (aka 'svc')
error: Required resource not specified.
See 'kubectl get -h' for help and examples.

while `kubectl get --help` return

> root@k8s-node1:~# kubectl get --help
Display one or many resources.
Possible resource types include (case insensitive): pods (po), services (svc), deployments,
replicasets (rs), replicationcontrollers (rc), nodes (no), events (ev), limitranges (limits),
persistentvolumes (pv), persistentvolumeclaims (pvc), resourcequotas (quota), namespaces (ns),
serviceaccounts (sa), ingresses (ing), horizontalpodautoscalers (hpa), daemonsets (ds), configmaps,
componentstatuses (cs), endpoints (ep), and secrets.
By specifying the output as 'template' and providing a Go template as the value
of the --template flag, you can filter the attributes of the fetched resource(s).
......

kubectl.PossibleResourceTypes missing some resouces such as jobs quota.
describe and explain have the same problem.

i think using valid_resources to replace kubectl.PossibleResourceTypes more suitable.
2016-08-19 15:49:15 -07:00
lojies f81fef1f04 use valid_resources to replace kubectl.PossibleResourceTypes 2016-08-19 09:42:46 +08:00
Clayton Coleman 6caf4d5a3f
Describing a single item should not have extra newlines 2016-08-15 12:28:15 -04:00
Davanum Srinivas c879e69f9f
Support --all-namespaces in kubectl describe
Fixes #26303
2016-07-08 11:45:38 -04:00
David McMahon ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
Michael Rubin 760b04e294 Use dedent for the kubectl commands
The one side effect is that for the "kubectl help" commands a newline
is prepended to output, which will alter the yaml output.

Here we use dedent to format the code to match the output.

hack/update-generated-docs.sh has been run and the affected files have
been added.

Note: for describe.go we added a period to the end of an output message.
2016-06-26 22:51:14 -07:00
Jan Chaloupka dd2c9c578d Introduce kubectl describe --show-events
Introduce DescriberSettings for Describer display options
Introduce --show-events flag and DescriberSettings in Describer methods
Introduce unit-tests
Regenerated kubectl describe docs
Add events flag tests to test-cmd.sh

Signed-off-by: dhodovsk@redhat.com
Signed-off-by: jchaloup@redhat.com
2016-05-06 11:40:11 +02:00
Dr. Stefan Schimanski 7e0bb885f1 Make kubectl bash completion namespace aware and add noun aliases
- add namespace filtering to bash completion
- add --namespace flag bash completion
- add bash completion noun aliases
- adapt to new cobra package structure
2016-04-03 16:25:56 +02:00
Brendan Burns be6c5b332b Add third party support to kubectl 2016-03-31 10:53:32 -07:00
Mike Metral 7403878ac0 allow kubectl cmd to process dirs recursively
reqs:
    - the kubectl cmd must support the -f | --filename flag
    - the kubectl cmd must support visiting a dir one level deep,
    or using more than one resource
2016-03-28 12:44:21 -07:00