Commit Graph

484 Commits

Author SHA1 Message Date
jlsong01 ec9d0484e5 add a warning printer in cli-runtime to coordinate warning style
modified:   staging/src/k8s.io/kubectl/pkg/cmd/auth/auth.go

Kubernetes-commit: 272e245f06e425fc912b1e477e8b6763850b161e
2022-02-18 20:33:38 +08:00
Arda Güçlü 81a25f37b5 Set validate functions requiring no parameters for all commands
Validate function is used to validate command options and should not get
any additional parameter. To preserve compatibility across all
kubectl commands, this PR removes all parameters in validate functions.

Kubernetes-commit: 8fb423bfabe0d53934cc94c154c7da2dc3ce1332
2022-05-17 11:38:20 +03:00
Brian Pursley 0c3ff4c860 Add unit tests for completion command
Kubernetes-commit: a8ec462e6fdbceb0a0e96446511b8b7e5e4b7781
2022-05-14 11:12:00 -04:00
Brian Pursley 96f0c72304 Add unit tests for api-resources and api-versions commands
Kubernetes-commit: 13e0120bf0662c4530df2badf1f8f73426cf9e51
2022-05-14 11:06:49 -04:00
xin.li 8207383170 update kubectl doc url
Signed-off-by: xin.li <xin.li@daocloud.io>

Kubernetes-commit: e89a87f708a03c5a8331639739982d426077ad3a
2022-05-05 21:27:52 +08:00
Philip Ottesen 13c8d95987 kubectl rollout: support recursive flag for rollout status
Kubernetes-commit: 9d8286c82ca3c79d68d36c58e69d91cbb7032b2c
2022-03-17 15:41:10 -04:00
Kazuki Suda 08a1f36bc3 Fix discovery cache TTL to 6 hours
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>

Kubernetes-commit: d2b4c017c8c4103199a4f85ba63fd3ab659f5f42
2022-05-09 12:22:43 +09:00
Maciej Szulik aa2aec18b6 Export function returning kustomize version
Kubernetes-commit: 8074ef58677ed41468fe82ee89f020c481c6c33b
2022-04-12 11:01:08 +02:00
Shubham Kuchhal e767a9773e Update rs.extensions to rs.apps
Kubernetes-commit: ce17a027477efd933775e320b1ce6c3876c136c3
2022-03-29 16:40:28 +05:30
Shubham Kuchhal bb7ded5a2e typo fix.
Kubernetes-commit: d350eb75d62bc51290826b94aa1d89bb6137595b
2022-03-30 18:57:43 +05:30
Shubham Kuchhal 32aa8d698a Updated the user and group flag.
Kubernetes-commit: bf77c2c3e7cdd67079742996cf47bac1003ffc26
2022-03-30 13:03:05 +05:30
Shubham Kuchhal 357211463f Improvement: Updated the serviceaccount flag for multiple subjects.
Kubernetes-commit: 3aa53c99a99f4dfe7d2e0faf2bf51e8252359e8d
2022-03-11 11:40:30 +05:30
Alexandre Garnier 459942a56d Do not raise an error proposing to use '--overwrite' when labeling with the same value (#105936)
* Do not propose to use '--overwrite' when labeling with the same value

* Check expected error value in label_test.TestLabelFunc

Kubernetes-commit: 10eb7092f854c71122c03752465e868bce23c0b6
2022-05-04 02:17:49 +02:00
Chok Yip Lau 7254bd442d Added --sum flag to kubectl top pod
Kubernetes-commit: 71acf56766c966653c3d1fe0ef6f3f036277d546
2021-09-16 09:28:30 -04:00
Katrina Verey 4424f53c23 Update kubectl kustomize to kyaml/v0.13.6, cmd/config/v0.10.6, api/v0.11.4, kustomize/v4.5.4
Kubernetes-commit: a8e1c67667288fb3aacc0a63a04b77aaac13bb4a
2022-03-28 19:22:08 -04:00
Chok Yip Lau de77e6a05b Remove generator dependency of expose.go
Kubernetes-commit: d7ab8d442b7913e5eb69fc2ce93b2b704645b089
2021-12-04 16:38:01 -05:00
Maciej Szulik 9ca2ff9172 Allow adding new verbs in AddSpecialVerb
Kubernetes-commit: 790396caba63f18ac529cf381b405390b62ad3e7
2022-03-28 12:49:02 +02:00
Filip Křepinský 0636d103cb resume kubectl cp with tail when --retries is negative
- count retries from 1 when printing info for users

Kubernetes-commit: a81f674a05a5747df1109ed3e572042caf6d607b
2022-03-16 19:59:39 +01:00
Daniel 12ebe4811f Fix: kubectl create -f and kubectl delete -f are not glob friendly (#102265)
* Fix: kubectl create -f and kubectl delete -f are not glob friendly

* gofmt fix

* removing unused receiver

* adding extra test

* log paths used

* fixing bad merge

* klog/v2 mod

* rebase fixes

* better error fmt

* error fmt unit test

* PR comments and tests

* Add reference to globbing to help snippets

Kubernetes-commit: 2cb3c7f706dbf266820fbde2e1b23a320e5d3de7
2022-03-28 05:45:26 +00:00
Rey Lejano b062628db1 updates for kubectl generated ref docs
Kubernetes-commit: 37a86e3e33349baa8fdfd25506dddb6009973337
2022-03-25 12:31:12 -07:00
Kevin Delgado 61f42e595f add server-side validation support to kubectl
Kubernetes-commit: fe3772890f650f9bcf020b43dc5a51fab0fa17f4
2022-03-09 14:52:32 +00:00
Arda Güçlü 11acf004c8 Remove deprecated discovery/ServerResources function
ServerResources function was deprecated and instead ServerGroupsAndResources
function is suggested.

This PR removes ServerResources function and move every place to use ServerGroupsAndResources.

Kubernetes-commit: ef39a8914291ba200bd5486c88a7575ffd4b7d1d
2021-12-22 11:14:09 +03:00
Ikko Ashimine be8cd595fc Fix typo in get_test.go
overide -> override

Kubernetes-commit: 10cdb0546aa7b89d8d6ab93d0826e4cda5c060eb
2021-12-13 22:56:22 +09:00
Maciej Szulik d2031a1eed Start deprecating long/golang version information
Kubernetes-commit: 43c09f6f9dc22771ac1b6b4459e4c2ce5d55c82a
2022-03-24 18:02:14 +01:00
Marc Khouzam cd5b039b42 Refactor completion code into its own package
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: c4f8c57b43843abd13bae677b73c622e1c30b46f
2022-03-24 09:06:05 -04:00
Marc Khouzam cd245d2e22 Support completion for the <type>/<name> form
This commit teaches the shell completion logic how to handle the
<type>/<name> form for resource specification.

It also teaches the 'exec' command how to complete its '--container/-c'
flag using container names.

Also, for commands that work on pods, kubectl will now also suggest
completion choices of the form <type>/<name> for resource types that
contain pods (see below for more details).

The following commands can now have completion of the <type>/<name>
form. Commands that accept any resource type:

annotate
apply edit-last-applied
apply view-last-applied
delete
describe
edit
get
label
patch

Commands that accept a subset of resource types:

autoscale
expose
rollout history
rollout pause
rollout restart
rollout resume
rollout status
rollout undo
scale
taint

Commands that apply to resource types that contain pods:

attach
exec
logs
port-foward

For these last four commands, the possible resource types are now
included in the completion choices.  For example:
    kubectl exec d<TAB>
will suggest
    daemonsets/   deployments/

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: cf66f5c3cbd0a0e2f223af438ee4c6bc7e4a907c
2022-03-01 10:45:59 -05:00
Yuvaraj Kakaraparthi 38487e770c kubectl: add --support to get, patch, edit and replace commands
Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com>

Kubernetes-commit: a5aa858d44651ba48bdce634a39b55be91216614
2021-07-07 08:30:59 -07:00
Patrick Ohly 7c4cfc5d12 enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of
reusing the result), others address real issues:

- Logging a message only above a certain verbosity threshold without
  recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
  this matters when using a logging backend which records the verbosity
  level.

- Passing a format string with parameters to a logging function that
  doesn't do string formatting.

All of these locations where found by the enhanced logcheck tool from
https://github.com/kubernetes/klog/pull/297.

In some cases it reports false positives, but those can be suppressed with
source code comments.

Kubernetes-commit: edffc700a43e610f641907290a5152ca593bad79
2022-02-16 12:17:47 +01:00
Chok Yip Lau 6a5a78c26b Beautify kubectl help flag commands
Kubernetes-commit: 1c031d4fa8450550fa9a6bd5abe7fac45816156e
2021-09-02 13:41:07 -04:00
Katrina Verey 5bb84013cd kubectl version should include bundled kustomize version
Kubernetes-commit: 44e63e8ff8e7f98c75dc86d8c41553a5cce6a603
2022-03-23 19:17:29 -04:00
brianpursley 131a58c252 Renamed create_authinfo.go, create_cluster.go, and create_context.go
to match their kubectl config subcommand names and reflect that they
are used for setting values, not just creating.

Deprecated NewCmdConfigSetAuthInfo in favor of NewCmdConfigSetCredentials.

Did some minor refactoring of one of the complete functions to eliminate
an unused argument and not wrap returned errors that do not add detail.

Kubernetes-commit: 48007fc32bb473d1d0d7d7c24b9daa2157e433d1
2022-02-06 21:31:13 -05:00
mozillazg 66c4b40dd6 kubectl: Remove deprecated flags
Remove the deprecated `--serviceaccount`, `--hostport`, `--requests` and `--limits` flags

Kubernetes-commit: 95f5d507f5b5a19d9b031bfa5eb46e72311f9896
2022-03-19 15:32:06 +08:00
Arda Güçlü 1474736be3 Remove DiscoveryClient from diff command
This PR removes `DiscoveryClient` field in diff command. Because
it is not used anywhere in diff command.

Kubernetes-commit: 5fdf97ad8e3a9b7a16479a5ec4ebff3d38c55a18
2022-03-08 09:59:49 +03:00
Monis Khan f315a5dd88 kubectl create token: use duration instead of expiration seconds
Expiration seconds is great for an unambiguous REST API.  It it not
a great input for a command line meant to be used by humans.

Signed-off-by: Monis Khan <mok@vmware.com>

Kubernetes-commit: 6b9d556c9dc1fca37349833d38f8921f436e1874
2022-03-18 16:11:13 -04:00
kkkkun b5be321e1a sort custom column print flags
Kubernetes-commit: 36ed148761cb5a30c21b45a64d95cabd1a9d07ff
2022-03-03 22:31:58 +08:00
Jefftree ef358291b5 googleapis/gnostic -> google/gnostic
Kubernetes-commit: 8a1d5947ad34ba275192341baa4e5fef8e6c7f24
2022-03-15 20:36:21 -07:00
Kevin Delgado 7e681490ec Generalize dry run verify to arbitrary query param
Kubernetes-commit: d6c83281bc696474a76365a879f2255b8b568786
2022-03-09 14:51:50 +00:00
Lee Verberne 3d7e4b3f7f Print kubectl debug messages received when starting a container (#108591)
* kubectl debug: print container messages

This provides feedback to the user, for example that the server is
unable to pull the debug container image.

* Label debug container updates as warnings

Co-authored-by: Eddie Zaneski <eddiezane@gmail.com>

Co-authored-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: 90956e6d3e9df02d932f9954911b89a3fd1619fb
2022-03-10 02:41:45 +00:00
brianpursley 5cd0db54d5 Add unit tests for cluster, context, and user command line completion functions
Kubernetes-commit: 996f79738e6f6c7dc9723cffe2b0bddc267777c6
2022-02-12 11:23:35 -05:00
W. Trevor King 5ff8356c5b kubectl drain: Generic "declare a controller" message
When it initially landed in kubernetes/kubernetes@c6e9ad066e (Initial
node drain implementation for #3885, 2015-08-30,
kubernetes/kubernetes#16698), the drain logic looked in a created-by
annotation for recognized kinds [1], so listing the set of recognized
kinds was a clear approach.

Sometime later, the source moved into ownerReferences, but the
hard-coded set of recognized controller kinds remained.

When kubernetes/kubernetes@2f1108451f (Remove hard-coded
pod-controller check, 2017-12-05, kubernetes/kubernetes#56864) removed
the hard-coded set of recognized controller kinds, it should have also
updated these messages to remove stale references to the previous
hard-coded values.  This commit catches the message strings up with
that commit.

[1]: c6e9ad066e (diff-211259b8a8ec42f105264c10897dad48029badb538684e60e43eaead68c3d219R216)

Kubernetes-commit: 587f4f04cc5fc18f4e85ed6a4a06bbf1bfee0496
2022-02-23 16:26:59 -08:00
jlsong01 4b64056435 kubectl version should fail when given extra arguments
Kubernetes-commit: 969cc463efcfacac728bac218534d0a027d448ee
2022-02-05 22:29:08 +08:00
czm 46b7c48533 fix defer in for loop, maybe resource leak
Kubernetes-commit: 684c5bf2a77f96b7db608e3c726a1d7da1a68421
2022-02-20 11:39:11 +08:00
Wojciech Tyczyński 3f11f31017 Stop setting selfLink in kubectl
Kubernetes-commit: 9015f27e6d8295d7dcdbf5915024f28cc00d4d2f
2022-02-16 17:13:54 +01:00
jlsong01 a64711ac83 add warning when kubectl set env from secret leads to uppercase
Kubernetes-commit: feb84ccef4a69fc1710003c71bc496b94448f094
2022-02-08 19:10:12 +08:00
Sebastian Sterk 31436b2c03 simple grammar fix
Kubernetes-commit: 5e286470fa16c4d53aa24b76a4fe94edf7b7016c
2022-02-02 00:02:11 +01:00
David Hotham 675d0d2328 Completions for kubectl config delete-user
Kubernetes-commit: 62eb74880cc3a97b04d1ea7fab62a207433a0f77
2021-12-20 14:40:56 +00:00
Eddie Zaneski d76986fd7a Change level for klog.Fatal
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: cd71d3f7881f0c66dbd28aec7af7a0ea0e2acf60
2022-02-10 14:43:19 -07:00
Jordan Liggitt 344e97b543 Add command to request a bound service account token
Kubernetes-commit: fca9b1d9fcc7288ecb93c969ff9907a5def2dc9e
2022-01-31 11:46:50 -05:00
Arda Güçlü 119abb31f8 Add manually invalidate cache documentation into delete
When CRDs are deleted, discovery local cache is not invalidated.
This brings about `resource not found` error when new CRD with same name is created
with different fields(ie. changing scope from cluster-wide to namespaced).
Because this already deleted CRD still stays in serverresources.json and kubectl tries to use it.

This local cached files have 10 minutes TTL. After deletion, if user waits 10 minutes,
files will be expired and deleted and there will be no errors. However, 10 minutes is a long time
and cache needs to be invalidated after deletion occurs.

This PR adds a document into delete command by noting that there might be a need to invalidate discovery
cache when CRD is deleted. In addition to that this PR adds a test to catch this behavior.

Kubernetes-commit: 43d8b3459baec794c8a3a858c04f1562a09886a3
2021-12-21 11:53:09 +03:00
Aram Peres 8e80d8fd7e Cleanup kubectl label selectors with 'cmdutil.AddLabelSelectorFlagVar'
Kubernetes-commit: 8f8138bc35f59ef04b77a3520d8d1065603ccdb7
2022-01-06 23:28:44 -05:00