Commit Graph

217 Commits (489dd27268431da5fc2fde874d456416bf9bd777)

Author SHA1 Message Date
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
Jeff Grafton efee0704c6 Autogenerate BUILD files 2017-12-23 13:12:11 -08:00
juanvallejo c53120e6b9
ensure PrinterForCommand is consumed through cmdutil.Factory 2017-12-05 13:39:29 -05:00
juanvallejo f5ab356043
pass printOpts by pointer 2017-11-20 14:49:23 -05:00
juanvallejo d3773b4b06
consolidate printer OutputOpts w PrintOpts
This patch removes the use of printers.OutputOptions in favor of only
having a single struct for setting / passing printer options set by user
flags.
2017-11-20 14:49:23 -05:00
Kubernetes Submit Queue a78d6b85ce
Merge pull request #46946 from kellycampbell/sort-contexts
Automatic merge from submit-queue (batch tested with PRs 46946, 45792). 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 config get-contexts: sort output

This sorts the output of kubectl config get-contexts because the ordering is otherwise non-stable and makes it harder to find the context you're looking for when you have more than a few.

```release-note
The output of kubectl config get-contexts is now sorted alphabetically by the context name.
```
2017-11-09 11:27:37 -08:00
Kubernetes Submit Queue 79d858660c
Merge pull request #55044 from ahmetb/wording
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>.

kubectl/config/rename: fix wording

Using `Context %q renamed to %q.` in rename-context to be consistent with other
commands like delete-context, set-context, use-context.

/sig cli
/release-note none
2017-11-09 01:52:26 -08:00
Ahmet Alp Balkan d7b0890217
kubectl/config/rename: fix wording
Using "Context %q renamed to %q." in rename-context to be consistent with other
commands like delete-context, set-context, use-context.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2017-11-02 21:10:11 -07:00
Cao Shufeng 26032ad6f8 [cli] exit when Validate() return an error
cmdutil.UsageErrorf() does nothing but return a string. When Validate()
returns an error, we should call exit() function.
2017-11-02 14:51:28 +08:00
Jeff Grafton aee5f457db update BUILD files 2017-10-15 18:18:13 -07:00
zhengjiajin 56930674c9 bug(cli)fix kubectl config unset unexist map key will add this key, should tell user this key not exist 2017-09-24 22:23:13 +08:00
zhengjiajin e62bc0b7c8 fix issue(11233)enhance kubectl config command 2017-09-14 17:14:42 +08:00
ymqytw b776df8a20 move i18n to kubectl/util 2017-08-16 12:27:36 -07:00
Kubernetes Submit Queue efe47a3988 Merge pull request #50023 from tcharding/kubectl-options
Automatic merge from submit-queue (batch tested with PRs 50023, 50639)

Correct case for starting character of option string

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

Kubectl-conventions.md states:

   "Flag descriptions should start with an uppercase letter and not have a period at the end of a sentence"

There are numerous cases where this is violated in `kubectl/cmd`. This PR is the result of an audit of all source files under `kublet/cmd` and corrects the case of the initial Flag description character.

/sig cli
/kind cleanup
/kind documentation

**Release note**:
```release-note
NONE
```
2017-08-15 11:23:53 -07:00
Jeff Grafton a7f49c906d Use buildozer to delete licenses() rules except under third_party/ 2017-08-11 09:32:39 -07:00
Jeff Grafton 33276f06be Use buildozer to remove deprecated automanaged tags 2017-08-11 09:31:50 -07:00
tcharding be04ad4aca Correct case for starting character of option string 2017-08-11 07:24:08 +10:00
Kubernetes Submit Queue 702e506a69 Merge pull request #46687 from zjj2wry/delete_unuse_error
Automatic merge from submit-queue

Delete unuse err check

**What this PR does / why we need it**:
err has fatal, this err check  can't execute.

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

**Special notes for your reviewer**:
thank you ~

**Release note**:

```release-note
NONE
```
2017-08-06 07:32:11 -07:00
Kelly Campbell 9f7468599e kubectl config get-contexts: sort output 2017-07-28 22:03:42 -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
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
Kubernetes Submit Queue 2629bf79f2 Merge pull request #46265 from waseem/printers-genericity
Automatic merge from submit-queue (batch tested with PRs 41563, 45251, 46265, 46462, 46721)

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.
2017-06-02 19:53:40 -07:00
Kubernetes Submit Queue 2269f5ca76 Merge pull request #43505 from zjj2wry/004
Automatic merge from submit-queue

unit test for kubectl config set-cluster

**What this PR does / why we need it**:
unit test for create cluster

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

**Special notes for your reviewer**:
i want test secure mode,but CA path how set?

**Release note**:

```release-note
NONE
```
2017-06-01 05:16:02 -07:00
zhengjiajin 7a55b5663c Delete unuse err check 2017-05-31 15:45:03 +08: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
zhengjiajin 7c362f2f65 unit test for create cluster 2017-05-31 14:19:12 +08:00
Kubernetes Submit Queue f7215b7cdf Merge pull request #45755 from ahmetb/set-context-differentiate
Automatic merge from submit-queue (batch tested with PRs 42240, 46100, 46154, 46431, 45755)

Differentiate update/create message on set-context
2017-05-30 14:57:07 -07:00
Kubernetes Submit Queue 1889d654f5 Merge pull request #46114 from arthur0/rename_context
Automatic merge from submit-queue (batch tested with PRs 46489, 46281, 46463, 46114, 43946)

Add `kubectl config rename-context`

Add `kubectl config rename-context`

This command allows renaming a context, instead of editing manually in .kubeconfig

Fix https://github.com/kubernetes/kubernetes/issues/45131

```release-note
Add `kubectl config rename-context`
```
2017-05-30 11:59:07 -07:00
zhengjiajin 586ebdb337 add error info 2017-05-27 22:27:12 +08:00
Arthur Miranda 83fec5bafb Add `kubeclt config rename-context`
Enables renaming of a context via `kubectl`

Fix https://github.com/kubernetes/kubernetes/issues/45131
2017-05-26 15:49:30 -03:00
zhengjiajin 802362007e add test in create authinfo 2017-05-24 10:01:45 +08:00
deads2k 75bd27a595 remove unnessary confusion of dead values 2017-05-17 07:15:29 -04:00
Jeffrey Regan 7abff879d7 Introduce visibility rules to kubernetes code.
**What this PR does / why we need it**:

Visibility rules allow dependency control.  The rules currently in
place make all targets public, to override the default state of
private.  This PR removes public visibility from kubectl code.  It
uses specially named pacakge groups to identify "bad" dependencies on
kubectl code for later refactoring or removal.

**Which issue this PR fixes**

First in a series of PRs to address kubernetes/community#598

**Release note**:
```release-note
NONE
```
2017-05-15 12:50:56 -07:00
Ahmet Alp Balkan f39afd4eeb
Differentiate update/create message on set-context
kubectl config set-context prints the same message (Context %q set) for both
new and existing contexts. This patch helps differentiate whether an existing
context is modified or a new context is created.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
2017-05-12 18:22:02 -07:00
Kubernetes Submit Queue b26d902070 Merge pull request #43517 from zjj2wry/007
Automatic merge from submit-queue

unit test for kubectl config set

**What this PR does / why we need it**:
unit test for kubectl config set

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

**Special notes for your reviewer**:
think you

**Release note**:

```release-note
```
2017-04-24 06:27:52 -07:00
Kubernetes Submit Queue fab2f5e3af Merge pull request #44267 from zjj2wry/005-f
Automatic merge from submit-queue (batch tested with PRs 43000, 44500, 44457, 44553, 44267)

add kubectl config view test code

**What this PR does / why we need it**:
kubectl config view test code

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

**Special notes for your reviewer**:
think you very much :)

**Release note**:

```release-note
```
2017-04-18 13:19:12 -07:00
zhengjiajin d5a3c22cb8 add test code for kubectl config set 2017-04-17 16:20:33 +08:00
Mike Danese a05c3c0efd autogenerated 2017-04-14 10:40:57 -07: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
zhengjiajin 420da81a4b add kubectl config view test code 2017-04-10 19:36:42 +08:00
Kubernetes Submit Queue bf766f48a6 Merge pull request #42538 from adohe/context_warning
Automatic merge from submit-queue (batch tested with PRs 44119, 42538, 43802, 42336, 43396)

print warning when delete current context

mirror update to kubectl. fix #42012 @smarterclayton ptal.

**Release Note**:
```
print warning when delete current context
```
2017-04-07 14:09:36 -07:00
Kubernetes Submit Queue 89875ccb40 Merge pull request #43514 from zjj2wry/006
Automatic merge from submit-queue (batch tested with PRs 44047, 43514, 44037, 43467)

unit test for kubectl config use-context

**What this PR does / why we need it**:
unit test for kubectl config use-context

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

**Special notes for your reviewer**:
think you

**Release note**:

```release-note
```
2017-04-04 14:33:22 -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
Kubernetes Submit Queue e9a91b8cca Merge pull request #44020 from tpot/kubectl-cmdline-spelling-fix
Automatic merge from submit-queue (batch tested with PRs 42674, 43937, 44020)

Fix spelling of 'arguments' for kubectl create authinfo

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

Fixes a silly spelling mistake in help output.

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

**Special notes for your reviewer**:

I've signed the CLA but don't fully understand the PR process yet.  I guess the "cla:yes" label gets added by someone else or automatically by a bot?

**Release note**:

```release-note
NONE
```
2017-04-04 00:53:16 -07:00
Tim Potter 1e4c93a0f8 Fix spelling of 'arguments' for kubectl create authinfo 2017-04-04 15:17:55 +10:00
Kubernetes Submit Queue 1df2363093 Merge pull request #42999 from shiywang/fix-return0
Automatic merge from submit-queue (batch tested with PRs 43450, 42999, 43968)

fix kubectl config return 0 on error

Fixes https://github.com/kubernetes/kubernetes/issues/42852
cc @kubernetes/sig-cli-bugs
@ymqytw ptal
2017-04-03 09:48:23 -07:00
Kubernetes Submit Queue 2d646e0c29 Merge pull request #43450 from zjj2wry/003
Automatic merge from submit-queue (batch tested with PRs 43450, 42999, 43968)

unit test for kubectl config set-context

**What this PR does / why we need it**:
unit test for create context

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

**Special notes for your reviewer**:
think you 

**Release note**:

```release-note
NONE
```
2017-04-03 09:48:21 -07:00
zhengjiajin 56c1baae01 unit test for kubectl config use-context 2017-03-31 13:29:52 +08:00
Kubernetes Submit Queue c0497fc278 Merge pull request #43518 from zjj2wry/008
Automatic merge from submit-queue

unit test for kubectl config unset

**What this PR does / why we need it**:
unit test for kubectl config unset

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

**Special notes for your reviewer**:
think you 

**Release note**:

```release-note
```
2017-03-28 13:51:54 -07:00
zhengjiajin ee23bb1b3c unit test for kubectl config set-context 2017-03-25 17:46:22 +08:00
zhengjiajin 611c90c65d unit test for kubectl config unset 2017-03-25 17:44:57 +08:00
shiywang 917a0b6f1b fix kubectl config return 0 on error 2017-03-16 08:34:51 +08:00
AdoHe 8ebc6e91f8 print warning when delete current context 2017-03-12 22:29:11 +08:00
juanvallejo b9d0c76dfd config set cluster api value 2017-03-02 14:01:25 -05:00
Clayton Coleman 651188d687
generated: bazel 2017-02-23 00:28:32 -05:00
Clayton Coleman 2aa4abb73b
Refactor commands to use new factory method 2017-02-23 00:28:32 -05:00
deads2k d3da1d102d deprecate and disconnect --output-version 2017-02-16 13:23:59 -05:00
Dr. Stefan Schimanski 44ea6b3f30 Update generated files 2017-01-29 21:41:45 +01:00
Dr. Stefan Schimanski 79adb99a13 pkg/api: move Semantic equality to k8s.io/apimachinery/pkg/api/equality 2017-01-29 21:41:45 +01:00
Brendan Burns 25ba561702 Extract strings for translation for the kubectl config family. 2017-01-27 20:31:49 -08:00
Dr. Stefan Schimanski 2b8e938128 Update generated files 2017-01-24 20:56:03 +01:00
Dr. Stefan Schimanski 82826ec273 pkg/util/flag: move to k8s.io/apiserver 2017-01-24 20:56:03 +01:00
deads2k 335ef747d6 mechanical 2017-01-23 10:03:55 -05:00
deads2k cdb2934bbc remove kubernetes copy of clientcmd types 2017-01-19 07:39:19 -05:00
deads2k 6a4d5cd7cc start the apimachinery repo 2017-01-11 09:09:48 -05:00
Kubernetes Submit Queue 748e8f6b1c Merge pull request #39540 from pwittrock/kubectldocs
Automatic merge from submit-queue (batch tested with PRs 39673, 39536, 39617, 39540, 39686)

Improve kubectl help with examples.

```release-note
NONE
```
2017-01-10 20:38:19 -08:00
Phillip Wittrock dc2fffe5d4 Improve kubectl help with examples. 2017-01-06 13:35:43 -08:00
Jeff Grafton 20d221f75c Enable auto-generating sources rules 2017-01-05 14:14:13 -08:00
Mike Danese 161c391f44 autogenerated 2016-12-29 13:04:10 -08:00
Mike Danese c87de85347 autoupdate BUILD files 2016-12-12 13:30:07 -08:00
Kubernetes Submit Queue 15bbd11bbf Merge pull request #35967 from saturnism/patch-2
Automatic merge from submit-queue

Append newline to the "deleted context ... " and "deleted cluster" message

**What this PR does / why we need it**: Append newline to the "deleted context ... " message.

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

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2016-11-18 08:28:12 -08:00
Ray Tsang 846cd2d66a Append newline to the "deleted context ... " and "deleted cluster ..." message 2016-11-17 12:30:45 -05:00
Klaus Ma fec8793b5f Set non-zero exit code on failures for kubectl. 2016-11-12 07:40:54 -05:00
juanvallejo 988e747649 update default run function for sub-commands
This patch updates parent commands of sub-commands to exit with a usage
error and exit code 1 on an invalid (non-sub-command) argument.
2016-10-31 10:08:12 -04:00
Mike Danese 3b6a067afc autogenerated 2016-10-21 17:32:32 -07:00
Fabiano Franz f6d1ac72a0 Use our own normalizers for cmd examples and descriptions 2016-10-17 11:49:55 -02:00
Harry Zhang eb81ef6023 Merge string flag into util flag 2016-10-11 23:28:59 -04:00
guangxuli d8331735a2 clean up the tmp Cert data
use function os.Remove to remove file
2016-09-27 23:17:47 +08:00
Kubernetes Submit Queue bb51525d0d Merge pull request #31212 from YuPengZTE/printf
Automatic merge from submit-queue

It is better to add "\n" in printf

<!--  Thanks for sending a pull request!  Here are some tips for you:
1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md
2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md
3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes
-->

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

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

**Special notes for your reviewer**:

**Release note**:
<!--  Steps to write your release note:
1. Use the release-note-* labels to set the release note state (if you have access) 
2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. 
-->
```release-note
```
2016-09-10 10:48:47 -07:00
Kubernetes Submit Queue e24aff0711 Merge pull request #29821 from alexbrand/config-cluster
Automatic merge from submit-queue

Add get/delete cluster, delete context to kubectl config

Fixes #29794 by adding `get-clusters`, `delete-cluster` and `delete-context` actions to `kubectl config`.
2016-08-26 11:44:46 -07:00
YuPengZTE 83cdfba0e0 It is better to add "\n" in printf
Signed-off-by: YuPengZTE <yu.peng36@zte.com.cn>
2016-08-26 11:58:26 +08:00
Daniel Smith f1fd638962 fix register.go files up + add test import 2016-08-11 17:06:54 -07:00
Eric Chiang 974473c45f kubectl config set-crentials: add arguments for auth providers
This PR adds `--auth-provider` and `--auth-provider-arg` flags to the
`kubectl config set-credentials` sub-command.
2016-08-04 16:23:40 -07:00
Andrey Kurilin 91cace347d Fix various typos in kubectl 2016-08-02 19:51:51 +03:00
abrand 20ae1b87cc Fix error msg in kubectl config get-contexts 2016-08-01 17:27:15 -04:00
abrand 82c700c896 Add get/delete cluster, delete context to kubectl 2016-08-01 17:04:13 -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
k8s-merge-robot 2da247ffbc Merge pull request #26977 from joe2far/fix-help-strings
Automatic merge from submit-queue

Make kubectl help strings consistent
2016-07-07 00:12:22 -07: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
joe2far 25b4341dc7 Make kubectl help strings consistent 2016-06-29 12:50:24 +01: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
CJ Cullen 86293810af Move ModifyConfig (and some related functions) into the clientcmd pkg. 2016-05-07 18:15:18 -07:00
AdoHe 6958db9c16 fix config view output bug 2016-04-28 23:04:57 -04:00
petervo 4f9d3ace5d kubectl: Allow []byte config fields to be set by the cli
Allows []byte config fields such as 'certificate-authority-data'
to be set using `kubectl config set` commands.
2016-04-22 15:53:24 -07:00
k8s-merge-robot acf9492cb1 Merge pull request #23660 from goltermann/vetclean
Automatic merge from submit-queue

Additional go vet fixes

Mostly:
- pass lock by value
- bad syntax for struct tag value
- example functions not formatted properly
2016-04-12 06:22:16 -07:00
goltermann 696423e044 Vet fixes, mostly pass lock by value errors. 2016-04-06 11:27:40 -07:00
Fabiano Franz 9ddacfa25f Mark filename flags for completions 2016-04-01 16:14:36 -03:00
k8s-merge-robot 4af38b52b9 Merge pull request #22736 from resouer/fix-util-dev
Auto commit by PR queue bot
2016-03-22 19:54:58 -07:00