Commit Graph

49 Commits

Author SHA1 Message Date
deads2k
a67255c170 make sure that the template param is the right type before using it 2017-07-18 13:48:29 -04: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
Kubernetes Submit Queue
c31893978b Merge pull request #45918 from juanvallejo/jvallejo/fix-kubectl-set-resources-local
Automatic merge from submit-queue

fix --local flag for kubectl commands

Fixes https://github.com/kubernetes/kubernetes/issues/47079

**Release note**:
```release-note
NONE
```

Fixes the `--local` flag for `kubectl set ...` sub-commands.
**As of the 1.7 release**, `PrinterForCommand` was updated to [use a mapper and typer for unstructured objects](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/util/factory_builder.go#L52), which further prevented the use of `--local` when there was no connection to an api server.


**before** (with no connection to a server)
```
$ kubectl set resources -f pod.json --limits=cpu=200m,memory=512Mi --local
error: unable to connect to a server to handle "pods": Get https://10.13.137.149:8443/api: dial tcp 10.13.137.149:8443: getsockopt: connection refused
```

**after** (with no connection to a server)
```
$ kubectl set resources -f pod.json --limits=cpu=200m,memory=512Mi --local
NAME              READY     STATUS    RESTARTS   AGE
mypod   0/1                 0          <unknown>
```

cc @smarterclayton @fabianofranz
2017-06-16 08:19:13 -07:00
juanvallejo
d036686185
fix --local flag for kubectl set commands 2017-06-13 12:57:05 -04:00
Tomas Nozicka
eb139f4572 Lookup --no-headers flag safely in PrinterForCommand function 2017-06-12 17:30:26 +02:00
Sunil Arora
f768a63fb0 Get cmd uses print-column extn from Openapi schema
Get command now uses metadata x-kubernetes-print-columns, if present, in Openapi schema
to format output for a resource. This functionality is guarded by a boolean
flag 'use-openapi-print-columns'.
2017-06-06 13:30:24 -07:00
Waseem Ahmad
8442a118ea Denote if a printer is generic.
This fixes #38779.

This allows us to avoid case in which printers.GetStandardPrinter
returns nil for both printer and err removing any potential panics that
may arise throughout kubectl commands.

Please see #38779 and #38112 for complete context.

Add comment explaining adding handlers to printers.HumanReadablePrinter
also remove an unnecessary conversion of printers.HumanReadablePrinter
to printers.ResourcePrinter.
2017-05-31 13:02:23 +05:30
Clayton Coleman
19ae89dcd8
command Factory should provide Printers
The factory knows all possible types, and should abstract the process of
creating all printers. A future refactor can further reduce the
dependencies between printer code and internal types.
2017-02-23 00:28:31 -05:00
deads2k
d3da1d102d deprecate and disconnect --output-version 2017-02-16 13:23:59 -05:00
AdoHe
d6d82425a4 refactor delete to remove cobra dependency 2017-01-15 15:30:06 +08:00
deads2k
6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
Andy Goldstein
80c5cd8b88 Allow missing keys in templates by default
Switch to allowing missing keys in jsonpath templates by default.

Add support for allowing/disallowing missing keys in go templates
(default=allow).

Add --allow-missing-template-keys flag to control this behavior
(default=true / allow missing keys).
2017-01-09 10:35:46 -05:00
Kubernetes Submit Queue
3951ae4e1d Merge pull request #38112 from juanvallejo/jvallejo/add-output-format-support-kubectl-create
Automatic merge from submit-queue

Add json,yaml output format support to kubectl create, kubectl apply

Fixes: https://github.com/kubernetes/kubernetes/issues/37390

**Release note**:
```release-note
Added support for printing in all supported `--output` formats to `kubectl create ...` and `kubectl apply ...`
```

This patch adds the ability to specify an output format other than
"name" to `kubectl create ...`. It can be used in conjunction with the
`--dry-run` option. Converts unstructured objects into known types in
order to support all `--output` values.

The patch prints `*resource.Info`s returned by the server. If a resource does not yet exist (and the `--dry-run` option is not set), the resource is created and printed in the specified format.

@kubernetes/cli-review @fabianofranz
2017-01-03 14:18:33 -08:00
tanshanshan
565a53871d fix help 2016-12-22 09:48:24 +08:00
juanvallejo
cbe479039b Add json,yaml output format support kubectl create
This patch adds the ability to specify an output format other than
"name" to `kubectl create ...`. It can be used in conjunction with the
`--dry-run` option. Converts unstructured objects into known types in
order to support all `--output` values.
2016-12-12 16:09:12 -05:00
Clayton Coleman
35a6bfbcee
generated: refactor 2016-11-23 22:30:47 -06:00
juanvallejo
52fc8efa55 update PrintSuccess message when using --dry-run 2016-09-15 10:11:21 -04:00
k8s-merge-robot
af1891ca03 Merge pull request #28531 from dims/fix-issues-28314
Automatic merge from submit-queue

Add custom-columns and custom-template-file to --help text
2016-07-13 06:09:25 -07:00
Sylwester Brzeczkowski
19434e1b58 24133 fix: --no-headers works with custom columns now 2016-07-07 10:04:09 +02:00
Davanum Srinivas
09fee66783
Add custom-columns and custom-template-file to --help text
Fixes #28314
2016-07-06 09:02:50 -04:00
Angus Salkeld
e0ce987f4e Add command "kubectl config get-contexts"
Note: Context is not a runtime object (doesn't have Kind and Version) so
      we can't use the resource_printer
2016-07-05 11:24:00 +02:00
David McMahon
ef0c9f0c5b Remove "All rights reserved" from all the headers. 2016-06-29 17:47:36 -07:00
Boaz Shuster
d6f69c0f22 Update the jsonpath template URL 2016-06-10 12:22:36 +03:00
Janet Kuo
aa2ac9b1d1 -t shorthand for --tty instead of --template 2016-04-15 17:12:42 -07:00
Fabiano Franz
9ddacfa25f Mark filename flags for completions 2016-04-01 16:14:36 -03:00
nikhiljindal
593b78f925 Deprecating --api-version flag 2016-03-11 10:12:44 -08:00
AdoHe
81103a07c2 fix --sort-by help bug 2016-02-14 22:31:13 -05:00
AdoHe
714d12cf72 kubectl add show-labels flag to make it more readable 2016-02-04 02:08:44 -05:00
k8s-merge-robot
6815cbf742 Merge pull request #15210 from brendandburns/docs
Auto commit by PR queue bot
2015-12-21 07:58:46 -08:00
deads2k
66eecb963a update more kubectl bits for groupversion 2015-12-07 09:01:44 -05:00
Brendan Burns
601faebfe3 Add custom-columns to the template flag 2015-12-02 10:40:32 -08:00
deads2k
a87d927588 update client.Config to use GroupVersion 2015-11-21 08:29:26 -05:00
deads2k
dd7ed11fc1 don't fatal on missing sorting flag 2015-09-24 12:53:33 -04:00
Dai Zuozhuo
2e2ef3e830 change -o template to -o go-template=... 2015-09-05 22:30:47 +08:00
hurf
d2d96ff6e1 Add -o name for commands which use printer to output results
Added a new printer which prints 'resource/name' pair of a given
object.
2015-08-26 17:04:23 +08:00
Janet Kuo
0bcb3147f6 Deprecated -t for --template to make it --tty 2015-08-24 02:16:01 -07:00
Dai Zuozhuo
85972c44a4 jsonpath user guide docs 2015-08-20 09:11:04 +08:00
Dai Zuozhuo
b61a905b19 add jsonpath to kubectl 2015-08-20 08:57:24 +08:00
Janet Kuo
44a7a52a94 Hide failed/succeeded pods in 'kubectl get pods' by default 2015-08-18 13:47:19 -07:00
deads2k
969d526ca5 tolerate output without template file 2015-08-18 08:58:04 -04:00
Brendan Burns
99b8df1812 Add field based sorting to the kubectl command line. 2015-08-12 16:51:36 -07:00
Mike Danese
8e33cbfa28 rewrite go imports 2015-08-05 17:30:03 -07:00
Janet Kuo
0e42d0699a Add '-o name' to mutations 2015-07-27 14:06:53 -07:00
Janet Kuo
682734bcc7 Implement 'kubectl get ... -o wide' 2015-06-30 14:06:47 -07:00
Anastasis Andronidis
b06ef70057 Print resource labels as columns 2015-06-22 00:44:51 +02:00
Eric Paris
6b3a6e6b98 Make copyright ownership statement generic
Instead of saying "Google Inc." (which is not always correct) say "The
Kubernetes Authors", which is generic.
2015-05-01 17:49:56 -04:00
Brendan Burns
f63cf05d21 Add some docs to the template format. 2015-02-12 18:29:11 -08:00
MikeJeffrey
e5459c8802 Clean up kubectl help for auto-gen'd kubectl.md 2015-02-10 12:02:05 -08:00
Jeff Lowdermilk
d46ae5d841 Refactor kubectl/cmd helpers into pkg/kubectl/cmd/util
Allows helpers to be used by config commands.
2015-02-05 09:39:42 -08:00