Commit Graph

112 Commits (284e8182a402cfd545fc000fedaea071fed873b0)

Author SHA1 Message Date
David Eads 5432ef5c45 divide statically known typer from dynamically derive restmapper 2018-04-27 11:15:05 -04:00
David Eads 6fbcbc994f remove unnecessarily flexibiliy to simplify the resource builder 2018-04-27 09:27:51 -04:00
David Eads 61fdd880b2 stop anonymously including types in resource struct so we can track usage 2018-04-27 08:32:56 -04:00
David Eads b8177bb9af tighten .Info for kubectl to avoid unpredictable conversion 2018-04-26 12:47:25 -04:00
David Eads 6900f8856f rest mappings cannot logically be object converters 2018-04-26 12:47:25 -04:00
Kubernetes Submit Queue c36e66dd66
Merge pull request #48244 from xilabao/add-validation-when-create-directory
Automatic merge from submit-queue. 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>.

add validation in kubectl create if no file in directory

**What this PR does / why we need it**:
if no yaml or json file in a directory
```
# ./cluster/kubectl.sh create -f ../0/1 --dry-run
pod "nginx" created (dry run)

# ./cluster/kubectl.sh create -f ../0
error: You must provide one or more resources by argument or filename.
Example resource specifications include:
   '-f rsrc.yaml'
   '--filename=rsrc.json'
   '<resource> <name>'
   '<resource>'
```
expected:
```
# ./cluster/kubectl.sh create -f ../0
error: error reading [../0]: please make sure the file extension is [.json .yaml .yml]
```

**Which issue this PR fixes**: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
2018-04-18 11:08:55 -07:00
juanvallejo 177dcb998f
match KindFor first 2018-03-09 15:43:10 -05:00
juanvallejo 765f9ec68b
update -o name format to kind.group/name 2018-02-15 10:33:06 -05:00
Zhenguo Niu 6be1b975d2 Make REST mappings for resources a unique list
This ensures the mappings list for resources(shortcuts, plural) unique,
instead of doing multiple requests to server for the same resource.
2018-01-26 15:46:35 +08:00
juanvallejo 80bc560489
check for empty label before assigning 2017-12-11 12:52:29 -05: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 04ab96d2bd
Unify Object and UnstructuredObject
The unified RESTMapper and Typer follow the new rules, but on error will
fallback to the legacy path (while still supporting Unstructured
objects). This allows callers to handle the appropriate distinction
themselves if necessary.

Add a LocalParam() method to the resource.Builder that DRYs up a large
chunk of complicated code in set commands.
2017-11-19 19:16:50 -05:00
Clayton Coleman 0229fd4bd1
Unify unstructured and versioned object in resource.Builder
resource.Builder should be aware of both paths, and the caller is
responsible for determining the different path via use.
2017-11-19 19:02:25 -05:00
Clayton Coleman 98e0c69907 Revert "refactor builder in kubectl factory"
This reverts commit 06c5be9802.
2017-11-19 19:02:21 -05:00
Clayton Coleman a972c6bb00
Allow resource.Builder to modify requests per client
Gives the builder a hook point to add settings to each request. These
settings are applied before the request is created and so are unable to
view the request. Intended to set controls on a per request basis.
2017-11-18 14:34:26 -05:00
Clayton Coleman b366afa00a
Move category expander out of kubectl/resource 2017-11-14 17:38:16 -05:00
ymqytw 06c5be9802 refactor builder in kubectl factory 2017-11-07 20:16:27 -08:00
Di Xu 4a3131ddaa add fieldSelector for kubectl get 2017-11-06 14:30:56 +08:00
Di Xu 057b7bf767 rename selector to labelSelector 2017-11-06 14:30:20 +08:00
Kubernetes Submit Queue 12e5db561e
Merge pull request #53768 from smarterclayton/chunking_cli
Automatic merge from submit-queue. 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>.

Support api chunking in kubectl get

This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.

```
$ kubectl get pods --all-namespaces
... print batch of 500 pods ...
... print second batch of 500 pods ...
...
```

@kubernetes/sig-cli-pr-reviews @kubernetes/sig-api-machinery-pr-reviews

```release-note
`kubectl get` will by default fetch large lists of resources in chunks of up to 500 items rather than requesting all resources up front from the server. This reduces the perceived latency of managing large clusters since the server returns the first set of results to the client much more quickly.  A new flag `--chunk-size=SIZE` may be used to alter the number of items or disable this feature when `0` is passed.  This is a beta feature.
```
2017-10-29 15:59:54 -07:00
Clayton Coleman 4780ad0297
Support api chunking in kubectl get
This enables chunking in the resource builder to make it easy to
retrieve resources in pages and visit partial result sets. This adds
`--chunk-size` to `kubectl get` only so that users can get comfortable
with the use of chunking in beta. Future changes will enable chunking
for all CLI commands so that bulk actions can be performed more
efficiently.
2017-10-27 17:23:36 -04:00
juanvallejo 6144799f75
remove mutual exclusivity check - local, unstructured builder attrs 2017-10-24 14:16:47 -04:00
Di Xu 279065aa6c pass labelSelector to server side opaquely 2017-09-30 14:54:27 +08: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
juanvallejo c10f4f78bc
add err message if <rsrc>/<name> pairs specified under --local 2017-09-05 11:04:39 -04:00
Di Xu 6b24fe2215 kubectl get show uninitialized resources 2017-08-26 13:52:36 +08:00
xilabao a9086f9b4f add validation in kubectl create if no file in directory 2017-08-18 13:08:43 +08:00
Jeffrey Regan dbc22ad6fd Remove kubectl's dependence on schema file in pkg/api/validation.
**What this PR does / why we need it**:

Makes functions in validation/schema.go private to kubectl,
further isolating kubectl.

**Which issue this PR fixes**

Part of a series of PRs to address kubernetes/community#598

**Release note**:
```release-note
NONE
```
2017-08-16 16:38:28 -07:00
Cao Shufeng b53ae95e84 modify the example part of missingResourceError
"missingResourceError" is a generic error for kubectl, so we should
not use concrete examples in the error message.
2017-05-16 09:37:37 +08:00
deads2k 8895f314b4 move category expansion out of restmapper 2017-03-27 13:54:05 -04:00
Clayton Coleman bace937438
Don't filter items when resources requested by name
Add tracking on resource.Builder if a "named" item is requested (from
file, stream, url, or resource args) and use that in `get` to accurately
determine whether to filter resources. Add tests.
2017-02-28 19:19:33 -05:00
Kubernetes Submit Queue bef60b8602 Merge pull request #40046 from juanvallejo/jvallejo/update-multiple-types-requested-check
Automatic merge from submit-queue (batch tested with PRs 40046, 40073, 40547, 40534, 40249)

update check for "all" resources

This patch updates the check for `all` resources to handle cases where a resource's name is "all". Rather than cycling through all given args until `all` is found, this patch makes sure that only a single argument `all` was specified at all.

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

@fabianofranz @pwittrock
2017-01-26 16:10:34 -08:00
juanvallejo 1b8f4e0b7d update check for "all" resources 2017-01-25 10:15:29 -05:00
Clayton Coleman 469df12038
refactor: move ListOptions references to metav1 2017-01-23 17:52:46 -05:00
Kubernetes Submit Queue 6e5b455b77 Merge pull request #39038 from ncdc/fix-kubectl-get-list
Automatic merge from submit-queue

Fix kubectl get -f <file> -o <nondefault printer> so it prints all items in the file

**What this PR does / why we need it**: Fix kubectl get -f <file> -o <nondefault printer> so it prints all the objects in the file, instead of just the first one. Also add a test for this feature.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
```

cc @AdoHe @deads2k @liggitt @fabianofranz @kubernetes/kubectl @kubernetes/sig-cli-misc
2017-01-11 09:58:38 -08:00
Andy Goldstein 613ada4cd7 Fix kubectl get -f <file> -o <nondefault printer>
Fix kubectl get -f <file> -o <nondefault printer> so it prints all the
objects in the file, instead of just the first one. Also add a test for
this feature.
2017-01-11 10:30:13 -05:00
deads2k 6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
juanvallejo 3484c6f676 add resource prefix to multiple items w/ same kind
This patch ensures that a resource prefix is added to multiple items of
the same kind, when using `oc get all`. Before, a prefix was added only
when a single item was returned on `oc get all`, but ignored if only a
single resource kind existed but multiple items for that kind were
returned.
2016-12-02 15:14:44 -05:00
Clayton Coleman 35a6bfbcee
generated: refactor 2016-11-23 22:30:47 -06:00
Kubernetes Submit Queue 9174429776 Merge pull request #33546 from k82cn/k8s_15834
Automatic merge from submit-queue

Updated err message when retrieving resources by name with --all-name…

fixes #15834
2016-10-15 06:50:00 -07:00
Ivan Shvedunov f1258dca4e Fix typos 2016-10-15 00:21:00 +03:00
Klaus Ma 005b8dad14 Updated err message when retrieving resources by name with --all-namespaces. 2016-10-14 22:21:01 +08:00
Mike Danese 5f2569c16d allow kubectl -f to filter by selector 2016-09-30 00:42:35 -07:00
Kubernetes Submit Queue 4b700f41ec Merge pull request #32944 from k82cn/refactor_builder_visitorResult
Automatic merge from submit-queue

Refactor Builder.visitorResult by extra methonds.

**What this PR does / why we need it**:
Code polish; it'll make code readable.
2016-09-22 13:45:09 -07:00
Davanum Srinivas e1373cf516 Extend all to more resources
Added more things from the list here:
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/cmd.go#L159

Update the devel/kubectl-conventions.md with the rules mentioned by
a few folks on which resources could be added to the special 'all' alias
2016-09-19 13:01:59 -04:00
Klaus Ma d55006d38f Refactor Builder.visitorResult by extra methonds. 2016-09-17 17:36:13 +08: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
Brendan Burns 155fb9f4be improve some error messages. 2016-08-29 22:27:22 -07:00
Kubernetes Submit Queue 5b5a4145da Merge pull request #30821 from ardnaxelarak/21076_change_isEmpty_to_Empty
Automatic merge from submit-queue

Rename IsEmpty to Empty

addresses #21076
2016-08-22 00:54:28 -07:00
Kara Alexandra d12a66a422 Rename IsEmpty to Empty
Signed-off-by: Kara Alexandra <kalexandra@us.ibm.com>
2016-08-19 14:19:19 -07:00