Commit Graph

1117 Commits

Author SHA1 Message Date
Paco Xu 89470f4910 kubectl apply: warning that in future release, prune will ignores no-namespaced resource if -n is not empty
Signed-off-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: f3b49adadf2182ba0a7fb930e6340da725053520
2022-11-09 07:43:03 +08:00
lojies 98416d7c8a kubectl:fix namespace missing in kubectl rollout undo
Kubernetes-commit: 186a326fb3a9cd0dd91098cc94b9f1f8f1536ed3
2022-08-11 10:59:09 +08:00
weikhor 992e246451 Clean up testing code of kubectl cmd section
Kubernetes-commit: 69b0b731e9dcfaa3960581165e4550758b0403c6
2022-10-27 22:18:42 -04:00
Brian Pursley 41407b14e8 kubectl apply: Deprecate --prune-whitelist in favor of --prune-allowlist
Changes in kubectl apply --prune to support k8s Inclusive Naming Initiative:
* Deprecated the --prune-whitelist flag.
* Deprecated the PruneWhitelist field on ApplyFlags struct.
* Removed PruneWhitelist field (not used anywhere) from ApplyOptions struct.
* Added --prune-allowlist flag.
* Added PruneAllowlist field on ApplyFlags struct.
* Added unit tests for prune with allowlist

This commit also fixes a bug where the command would fail if you specified
the sameGVK multiple times for --allow-whitelist. Now it only attempts to
prune the unique set of allowed GVKs.

Kubernetes-commit: f7ebf4d8852d4500f24100ca9a4ca665efc1fada
2022-10-30 20:50:19 -04:00
Marly Puckett 9cebc60d68 Update redacting functionality to redact all sensitive info in config when printing with view (#109189)
* Add RedactSecrets function

* Move RedactSecrets method to existing RawBytesData case

* Update TestRedactSecrets to use new pattern of os.CreateTemp()

Kubernetes-commit: e721272d10dd6c4d85ff613182ba0eaddcec9272
2022-11-08 18:06:48 +00:00
Wenqing Luo 6a7dccd04b Fix kubectl describe ingress when default backend is empty
Kubernetes-commit: 653edeb507c3caafd0e81f6cef0a44425ef8782c
2022-11-07 10:11:28 -06:00
Alexander Zielenski 4f1b2184e0 add kubectl server-side apply migrate managedfields
in discussion with SIG, there is a strong interest in keeping the last-applied-configuration around for a bit longer as other tools transition for of it. This is OK since SSA maintains the annotation on kubectl's behalf on the server-side if it exists

migrate client-side-apply fields to SSA when --serverside-side is used

https://github.com/kubernetes/kubernetes/issues/107980

https://github.com/kubernetes/kubernetes/issues/108081

https://github.com/kubernetes/kubernetes/issues/107417

https://github.com/kubernetes/kubernetes/issues/112826

add test to make sure only one apply is needed after migration

Kubernetes-commit: 33b9552e708154c20144c7aca921ad239527fb2f
2022-11-03 20:14:37 -07:00
Marc Khouzam 4cdd516e3b Enable shell completion descriptions for bash
Cobra provides support for completion descriptions for bash.
It was turned off because of a bug with certain bash menu options which
have been fixed by Cobra 1.3.0.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>

Kubernetes-commit: d72926d4915133550e41de1252fe2a4aa0aa3745
2022-11-04 16:57:24 -04:00
Brian Pursley c6025a8904 kubectl/pkg/cmd/run: deprecate flags
The --cascade flag, has no practical effect when used, so it is being deprecated.

The following flags, which are unused and ignored by kubectl run,
have been deprecated:

--filename
--force
--grace-period
--kustomize
--recursive
--timeout
--wait

Kubernetes-commit: 09804a198c64f0a738ede28e0b2cb045d16980fc
2022-11-03 23:11:12 -04:00
Alexander Zielenski 3371c3ccee use discovery client from factory in explain v2
was making my own which was uncached

Kubernetes-commit: dca025f37c7d40388f6869fc3d04b8f4fab8d122
2022-11-03 18:59:09 -07:00
Alexander Zielenski ee7b47da7d add plaintext template
Kubernetes-commit: e394364cbd1d5ace0f9cfcf10fa2bc458076d1a4
2022-11-02 20:35:18 -07:00
Alexander Zielenski 8ae416a4e0 add template loading to generator
Kubernetes-commit: 88792d9e72ee48bac2f6c7158531579cc0bc6aca
2022-11-02 20:33:11 -07:00
Alexander Zielenski b0d33eb1b8 refactor generator
refactor funcs out of generator

Kubernetes-commit: f37f63ab9fff8c38b4c0df6a7a420d1ed710ffe5
2022-11-02 20:34:12 -07:00
Alexandre Garnier 8121aed896 Check expected error value in annotate_test.TestUpdateAnnotations
Kubernetes-commit: 78cca63817936d03dfc5e7f176f7c3a33c55a80e
2022-05-11 09:17:56 +02:00
Alexandre Garnier fa93ada9d1 Do not raise an error proposing to use '--overwrite' when annotating with the same value
Kubernetes-commit: 9feaf478c6a2d9982fa55086a856ccd2a414ecbe
2022-04-15 14:31:56 +02:00
Tim Hockin 72d1b20cad Copy LoadBalancerStatus from core to networking
This type should never have been shared between Service and Ingress.
The `ports` field is unfortunate, but it is needed to stay compatible.

Kubernetes-commit: 0153bfad16102e42d0b0dbb56742d0a6626e4180
2021-11-08 17:06:59 -08:00
arkbriar d17f0318cc Support cancelable SPDY executor stream
Mark remotecommand.Executor as deprecated and related modifications.

Handle crash when streamer.stream panics

Add a test to verify if stream is closed after connection being closed

Remove blank line and update waiting time to 1s to avoid test flakes in CI.

Refine the tests of StreamExecutor according to comments.

Remove the comment of context controlling the negotiation progress and misc.

Signed-off-by: arkbriar <arkbriar@gmail.com>

Kubernetes-commit: 42808c8343671e6783ba4c901dcd619bed648c3d
2022-08-24 10:21:35 +08:00
jonyhy96 1906bda541 feat: make jsonpath wait logics consistent with condition
Signed-off-by: jonyhy96 <hy352144278@gmail.com>

Kubernetes-commit: 7a1493be5679ed3ec85b7fdef685c7e6b580e8e4
2022-06-29 12:28:24 +08:00
David Leadbeater 8e2918ab8b Escape terminal special characters in kubectl (#112553)
* Escape terminal special characters in kubectl

* Add escaping for kubectl alpha events

Kubernetes-commit: dad0e937c0f76344363eb691b2668490ffef8537
2022-10-30 16:29:24 +00:00
Arda Güçlü daf2914981 (kubectl apiresources): Use restclientgetter instead cmdutil.Factory
This PR changes `kubectl apiresources` command by  using restclientgetter
instead of cmdutil.Factory for loose coupling and a couple of minor refactorings.

This PR also unleashes migration of other commands depending on apiresources
via completion.

Kubernetes-commit: 50c93bfe04557eccb38b46cc4b99a6a3ec13f85b
2022-08-24 09:52:10 +03:00
Arda Güçlü e5d52f2374 (kubectl certificates): Remove certificates/v1beta1 client usage
certificates/v1beta1 was deprecated in 1.19 and we can safely clear it's
dependencies in `kubectl certificates` command.

Kubernetes-commit: 48b8ee0d3ba40a19d40a7404f890031fe22bc111
2022-08-24 09:17:05 +03:00
Sam Snarr e25bbbc6e1 fixed test to fail when you change the `expectPluginArgs` so that it is different than `args`
Kubernetes-commit: 45fc1f0d93b996b0bc84cdcaec47ff60b8c21b4d
2022-10-27 22:18:42 -04:00
Marc Khouzam d2df859d92 Add support for shell completion for plugins
When doing completion for arguments or flags for a plugin, kubectl will
call "kubectl_complete-<plugin>" to obtain the list of completions.
For example, for "krew" plugin, when the user triggers completion using:

$ kubectl krew <tab><tab>

kubectl will look for an executable file called "kubectl_complete-krew".
This file should print the list of valid completions for the plugin to
stdout.  Using cobra.ShellCompDirective as the last line of the output
is supported as is done by Cobra.

We also clear global flags when doing plugin completion because plugins
don't necessarily accept the global kubectl flags.  If some plugins do,
they will need to include such flags in their kubectl_complete-<plugin>
output.

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

Kubernetes-commit: befc8da7efa5d961d9ade4eadc706292c7ca5a64
2021-09-15 21:44:07 -04:00
Kazuki Suda 9c405e27d0 Add completion support for kubectl plugins
This commit allows us to get shell completion for kubectl plugins.

For example, with the use of a plugin named 'kubectl-krew', completing
   kubectl k<tab>
will include 'krew' in the list of possible completions.

Because the shell completion scripts are generated by Cobra, this commit
took the approach of registering every plugin as a Cobra command.  This
makes Cobra aware of each plugin command when generating completions.

For efficiency, searching for plugins and registering them as Cobra
commands is only done when needed, which is when calling the
'kubectl completion' command in the case of bash, as it includes all
commands and subcommands directly in the bash generated script.

For the other shells, this will need to be done for the
'kubectl __complete' command, in a follow-up command.

Co-authored-by: Marc Khouzam <marc.khouzam@montreal.ca>
Signed-off-by: Kazuki Suda <kazuki.suda@gmail.com>

Kubernetes-commit: 3db3ff53cdf4b106365c5de9194153fc371868a7
2019-04-14 14:40:53 +09:00
Oscar Utbult bfae23fc18 grammar: replace all occurrences of "the the" with "the"
Kubernetes-commit: e4f776f23098ecf942cafa898777195adbc800f1
2022-09-17 22:58:01 +02:00
Alexander Zielenski c9325dd23a unit test v2 explain package
update

Kubernetes-commit: 0cf7240f313f831a7411abc878b7d7309e445487
2022-10-17 13:59:17 -07:00
Alexander Zielenski 9cd0ccd733 add `KUBECTL_EXPLAIN_OPENAPIV3` envar to gate new explain implementation
update

Kubernetes-commit: 2f16cd4aeabda5dd6d5398a3592400bc249fdb17
2022-10-12 08:37:41 -07:00
Alexander Zielenski 7f1795f661 openapi v3 basic renderer
Kubernetes-commit: a9c093b16560a9ed50668250fd24889e503f2d8f
2022-10-17 13:58:42 -07:00
PuneetPunamiya 768d721977 Refactors describe command to split flags from options
Signed-off-by: Puneet Punamiya ppunamiy@redhat.com

Kubernetes-commit: 568f55a82bf0e375d215ee04d4bf7b916a74a715
2022-09-23 12:16:43 +05:30
Brian Pursley 7c5e877c4d Add categories to kubectl api-resources -o wide output
Add categories column to show which categories each
resource type belongs to.

Add --categories flag to allow filtering the output to
a specific category or set of categories.

Change verbs column to display verbs in a comma-delimited
list, consistent with other multi-value columns in the output.

Kubernetes-commit: a1330a405497479ea30319258e75435ba8321d61
2022-07-12 17:57:37 -04:00
m.nabokikh a5404b6548 Split the API error in two
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: e6e670624b5fbe5493f48796f54e60d505727314
2022-09-29 11:50:33 +02:00
m.nabokikh faf015bc84 Fix the code according to the code review comments
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: 967fdbd3d52b67ed5c72f2b4888adae1f04489e1
2022-09-27 15:49:51 +02:00
m.nabokikh d614c60b0c Add more accurate error message for WhoAmI command
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: bbc58a55176ea9f879e4dfabfde0202a17504c56
2022-09-27 14:12:07 +02:00
Paco Xu e0b132cd00 add unit test for normalizer rendering markdown
Kubernetes-commit: 9d2be187e550604879ad33d99379550b6fbebc3b
2022-09-27 14:06:40 +08:00
Paco Xu 8402e4686d implement blackfriday render using v2
Kubernetes-commit: baedc1cd3201421a3c90f30876c1a6ae0b0df927
2022-09-26 16:56:20 +08:00
Arda Güçlü f6d66bab8d (kubectl patch): Add descriptive message when patch type is unsupported
`kubectl patch` commands fails when patch type is strategic merge
patch for CRDs. This PR handles `UnsupportedMediaType` error and
shows descriptive message to user.

Kubernetes-commit: dc2c0ad831f71349befdfa57d4367c4ea57d4a6c
2022-09-19 10:15:04 +03:00
Manish Kumar e19db057bd Add notes for strategic merge patch is not supported for CR
Kubernetes-commit: 4f85a584800c7967c181798387eacbe0d5e75da4
2022-09-15 11:40:46 +05:30
m.nabokikh 254147c688 Cleanup WhoAmI sorting code
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: b81b422a70ec6ab1bbdacae56bbe3ccd0daef5a6
2022-09-16 07:14:20 +02:00
m.nabokikh f55dcb2100 Fix WhoAmI flaky test
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: 378d7f8f2b05b9228efd71e73562a29f941f968a
2022-09-15 11:02:42 +02:00
m.nabokikh 2988d073de Add auth API to get self subject attributes
Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>

Kubernetes-commit: 00dfba473b08528f0a21f7bd3b921f5dd35b013a
2022-07-22 04:01:52 +04:00
song 6f44e96c59 update auto can-i error message
Signed-off-by: song <tinysong1226@gmail.com>

Kubernetes-commit: 41762c588fc92e5d310649d2fa6133523a045f19
2022-05-29 00:38:52 +08:00
Brian Pursley 96fc22ebfb Revert "Remove unused flags from kubectl run"
Kubernetes-commit: eae2c424efd9dda8cb0f5ba01ab4c955cdf42cfa
2022-09-05 09:34:48 -04:00
Jordan Liggitt 21676edd52 Improve kubectl display of invalid errors
Kubernetes-commit: 6c549d75a8d951ec43ecd5394b2634c1a40e5dd1
2022-08-31 11:49:34 -04:00
cndoit18 c688132ac9 style: remove redundant judgment
Signed-off-by: cndoit18 <cndoit18@outlook.com>

Kubernetes-commit: ec43037d0f57fdfc2fdc4960fdb8a7e31ac79fae
2022-07-29 18:25:05 +08:00
Brian Pursley 2b0d68cf1f Fix rollout history bug
Fix rollout history bug where the latest revision was
always shown when requesting a specific revision and
specifying an output.

Add unit and integration tests for rollout history.

Kubernetes-commit: 693e1299a6a75ffe358c41626532cdf2567c267b
2022-07-13 18:27:05 -04:00
Davanum Srinivas 07a930403b Remove references to openstack and cinder
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 9bbf01bae93600d3314bce0acbff1f3a0a42e74b
2022-08-08 16:01:59 -04:00
Arda Güçlü 69c8011633 (kubectl cluster-info): Move towards RESTClientGetter instead cmdutil.Factory
To preserve loose coupling, it is needed to pass `RESTClientGetter`
instead `cmdutil.Factory` for all kubectl commands.

This PR removes `cmdutil.Factory` usage in `cluster-info` command and
instead passes `RESTClientGetter`.

Kubernetes-commit: 60680fc1d5458994aa29892e581aaf966d64ae91
2022-08-04 13:08:55 +03:00
Arda Güçlü b2cb2f2c6d (kubectl certificate): Move towards restClientGetter instead cmdutil.Factory
To preserve loose coupling, it is needed to pass `RESTClientGetter`
instead `cmdutil.Factory` for all kubectl commands.

This PR removes `cmdutil.Factory` usage and instead
passes `RESTClientGetter` as well as required changes in unit tests.

Kubernetes-commit: 55cb8ba1ebe68d2fa6b33f1e474419b895eb31ea
2022-08-04 11:36:03 +03:00
Brian Pursley 2861433ddd Fix label output bug where dry run message was not printed
Kubernetes-commit: 2efe97fa6cfa99512b3b101de4c23ce7a4100b05
2022-07-30 09:27:42 -04:00
zhoumingcheng 92ac5290cc add unit test for /staging/src/k8s.io/kubectl/pkg/util/storage
Signed-off-by: zhoumingcheng <zhoumingcheng@beyondcent.com>

Kubernetes-commit: b092dafa67e8db0f8011b210ebc234511a0d00fb
2022-07-29 17:34:00 +08:00