Commit Graph

25 Commits

Author SHA1 Message Date
yylt 0198d9185e Fix edit command
Kubernetes-commit: 2ae37c8046128e0191ec96c8b31361ae894f2330
2021-10-21 20:07:38 +08:00
brianpursley 07f77100fc Add --override-type flag to kubectl run and kubectl expose to allow the choice of using a JSON Patch or Strategic Merge Patch to apply the override to the generated output.
Kubernetes-commit: 0e697e19ac9f73e2efa0e60157730ba8731e3847
2021-11-05 07:10:47 -04:00
Marc Khouzam b111bee570 Complete multiple resource names
This commit teaches the completion function to repeat resource names
when supported by the command. The logic checks if a resource name
has already been specified by the user and does not include it again
when repeating the completion.

For example, the get command can receive multiple pods names, therefore
with this commit we have:
  kubectl get pod pod1 [tab]
will provide completion of pod names again, but not show 'pod1' since
it is already part of the command-line.

The improvement affects the following commands:
- annotate
- apply edit-last-applied
- apply view-last-applied
- autoscale
- delete
- describe
- edit
- expose
- get
- label
- patch
- rollout history
- rollout pause
- rollout restart
- rollout resume
- rollout undo
- scale
- taint

Note that "rollout status" only accepts a single resource name, unlike
the other "rollout ..." commands; this required the creation of a
special completion function that did not repeat just for that case.

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

Kubernetes-commit: 7aa5cb40316dbeb970250ee0835fbd597fd19a20
2021-10-15 15:36:09 -04:00
Julian V. Modesto f9ab824bc9 Remove deprecated kubectl --dry-run values.
The boolean values for --dry-run have been deprecated for removal since
1.18, more than 2 releases.

The default value for --dry-run with the flag set and unspecified has
been deprecated for removal since 1.18, more than 2 releases.

Both values are now removed in this change. Any kubectl --dry-run
usage no longer accepts --dry-run=(true|false) boolean values and usage
now requires that a value of (client|server|none) is specified.

Kubernetes-commit: e0b7a85ee5b5d546bec2dc0e8cbf5cd4c0c684d8
2021-09-28 10:03:20 -04:00
BLasan 9072d8b375 Remove AddGeneratorFlag function
Kubernetes-commit: 9c8335b65a4527ea3a07687e4a7a8ba5ebd72041
2021-04-13 23:58:24 +05:30
Katrina Verey 086cadbf87 Create helper for adding chunk-size flag to commands
Kubernetes-commit: f8097c6ceeb16461861c74d4fc5dd0bcd36ebeaf
2021-03-19 08:30:49 -07:00
Katrina Verey 9348b0acca Extract DefaultChunkSize constant
Kubernetes-commit: 222e2c5ef897f4d47831b8d822cab09c000037c2
2021-03-10 12:21:25 -08:00
mengjiao.liu a0af655b7a kubectl default container behavior
Kubernetes-commit: 88e530117ff3fff29e670aee51c677a8e0fe8dec
2021-03-05 17:04:40 +08:00
Clayton Coleman 56434236a4 kubectl: Inline the containers for the user in attach/exec
The behavior of the container defaulting in attach/exec is inconsistent
and should be unified. As a user, when we default the vast majority of
pods will have a small number of containers and so printing the container
names inline (as kubectl logs did) is more appropriate. The debug message
we printed about using describe was already longer than 99% of all pod
container names, so we were wasting user time.

Unify container selection for exec and attach to be consistent with old
behavior. Properly handle the --quiet flag (should not print in that case)
for both commands. Remove EnableCmdSuggestion and the machinery it needs.

The message now prints:

> Defaulted container "etcdctl" out of: etcdctl, etcd, etcd-metrics, etcd-ensure-env-vars (init), etcd-resources-copy (init)

Kubernetes-commit: 43e8ebbbcd3f57d18d8151efb6242f88a763b06d
2021-02-11 11:40:25 -05:00
pacoxu 4245d9e7b5 print log for default container of kubectl
Kubernetes-commit: 96f8d6262459e802510244d2880886f8b481ee0e
2021-03-01 12:04:29 +08:00
pacoxu 8d367eb060 move default container annotation to kubectl pkg
Kubernetes-commit: 27bd94e54d2f8a7676411b280ab9d0ac7f9e921b
2021-02-26 10:11:12 +08:00
pacoxu 360e8d2b15 feature: use default container annotation for logs and exec
- update according to KEP: move getContainerName to helper

Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: b54e823dbce08bff6fab979243663b0fea5a351f
2020-12-07 15:30:30 +08:00
Maciej Szulik e650b90b3e Change at which level klog.Fatal is invoked
Kubernetes-commit: 6b4dd3d774bcc84a1f969214096b9cfa373ad389
2020-09-09 21:41:56 +02:00
Julian V. Modesto 0d395d7c98 Make client-side apply safer
- Remove the ServerDryRun field and delegate it entirely to the resource.Helper
- Use resource.Helper for deletions (as in `kubectl apply --force`)
instead of using the pruner's method that uses a dynamic client
- Reduce the resource.Helpers and times we check for server-side dry-run
in apply

Kubernetes-commit: f0eb68c0cfcff6d50d9d5ec278f96820e3cb3f9a
2020-04-02 18:26:32 -04:00
Davanum Srinivas 445ad1366b switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Julian V. Modesto 415a73888a Set kubectl field manager names
Kubernetes-commit: 360c348d0eb5be8c7c9720d5bfda16dbe04e8d15
2020-03-04 22:04:01 -05:00
Maciej Szulik e576e735d4 Deprecate --generator flag from kubectl create commands
Kubernetes-commit: be6ac856f13b994251b3c8e54b2251cf75c6847d
2020-02-28 11:58:53 +01:00
Julian V. Modesto f9460c5333 Use --dry-run=client,server in kubectl.
- Support --dry-run=server for subcommands apply, run, create, annotate,
expose, patch, label, autoscale, apply set-last-applied, drain, rollout undo
- Support --dry-run=server for set subcommands
  - image
  - resources
  - serviceaccount
  - selector
  - env
  - subject
- Support --dry-run=server for create subcommands.
  - clusterrole
  - clusterrolebinding
  - configmap
  - cronjob
  - job
  - deployment
  - namespace
  - poddisruptionbudget
  - priorityclass
  - quota
  - role
  - rolebinding
  - service
  - secret
  - serviceaccount
- Remove GetClientSideDryRun

Kubernetes-commit: 13b80b48cd02b8263d910f2423a1f5b92cdf7644
2020-01-30 20:23:33 -05:00
Antoine Pelisse 4c36396b35 kubectl-diff: Return non-1 errors on kubectl failures
Currently, diff AND kubectl can return 1 errors either when diff finds
differences, or when kubectl fails something. It also prints an ugly
error when diff finds a differences, since 1 is treated as an error.

Two things this PR does:

1. If diff returns 1, then do not treat it as an error, and exit with
exit code 1. It no longer prints the ugly error.

2. Kubectl errors are +1'd so that they never return 1 which shouldn't
be considered an error.

We need to update the documentation accordingly, to mention that
`KUBECTL_EXTERNAL_DIFF` programs must also follow the convention of
using one as their exit code for changes detected.

Kubernetes-commit: f2b21f08d95291212ba8987aa9d446c02a96089a
2020-01-21 13:52:41 -08:00
Julian V. Modesto c0b11fa131 Extend --dry-run to support string values.
* Extend --dry-run to support string values for dry run strategies
  'client', 'server', and 'none'
* Ensure --dry-run is set and accessed via cmdutil
* Deprecate --dry-run (unset), --dry-run=true, and --dry-run=false

Kubernetes-commit: af52beda260257e81cc9e19e9e5108b682ee93d6
2019-12-15 18:29:27 -05:00
danielqsj 4b914450ab unify alias of api errors under pkg and staging
Kubernetes-commit: 5bc0e26c1902e7e28abfc828de19a2dbb3e492c2
2019-11-12 16:26:59 +08:00
Lantao Liu 7c6594395c Fix kubectl panic when handling invalid error.
Kubernetes-commit: 12d944b860e4872085fa1155590c7fcef58e6bb8
2019-09-19 21:48:50 -07:00
draveness a61556981e feat: remove deprecated include uninitialized flag
Kubernetes-commit: f18f86ad9a16335e44b2799a419f51c9b606526b
2019-07-19 10:01:17 +08:00
Antoine Pelisse 4574b365f9 Rename --experimental-* flags to --* for server-side apply
Kubernetes-commit: a3f4e6e933d3292b3921cdc7b60d7ae019ca1580
2019-08-26 09:09:40 -07:00
Sean Sullivan 1919d7fa45 Move pkg/kubectl/cmd/util and subdirs to staging
Kubernetes-commit: 6c96a059dd4a64f1917378b4a0c13899dff31918
2019-07-28 21:29:36 -07:00