Commit Graph

46 Commits

Author SHA1 Message Date
Sai Harsha Kottapalli 61b85bce7c warn user about resource being deleted
Kubernetes-commit: 7b0ef888f3205f06c871cff901ef0f5b8fdb250c
2020-10-11 02:21:32 +05:30
Karl 'NaN' Wikström 38408eaa8c cleanup: use i18n.T on all command descriptions
cleanup: use i18n.T only on string literals

cleanup: sort imports

Add i18n dependency for wait.go

Remove translation on envResource

cleanup: translate string instead of variable

cleanup: sort imports

cleanup: translate string literal only

Kubernetes-commit: cc8428566ea7160c5b20410a1bee53ca7ddb998e
2020-10-09 13:16:13 +02:00
Masashi Honma 309d0ee885 test: Fix deprecated --dry-run parameter
Some unit tests throw this warning.

W1013 09:06:21.581870  176998 helpers.go:567] --dry-run=true is deprecated (boolean value) and can be replaced with --dry-run=client.

This patch removes the warning by using --dry-run=client instead of --dry-run=true.

The unit tests that are affected are:

make test WHAT=./vendor/k8s.io/kubectl/pkg/cmd/apply GOFLAGS=-v
make test WHAT=./vendor/k8s.io/kubectl/pkg/cmd/create GOFLAGS=-v

Signed-off-by: Masashi Honma <masashi.honma@gmail.com>

Kubernetes-commit: ad7cbac16354e19981e986bbc2b3fd9cfa930d45
2020-10-14 10:00:08 +09:00
SataQiu 7a93b067f4 kubectl: improve the warning message when doing kubectl apply to the resource without expected annotation
Signed-off-by: SataQiu <1527062125@qq.com>

Kubernetes-commit: 9c163f0a0a97a9bcf10c3f91d2cee02567700d84
2020-07-29 10:39:59 +08:00
zhouya0 8411619cbf Support kubectl delete foreground
Kubernetes-commit: 383b5f676670d99dc1fba4254ba7f6a81a052ba3
2020-07-23 18:45:59 +08:00
Yuvaraj Kakaraparthi 36c221e3cf kubectl: cannot use --force with --server-side
Kubernetes-commit: f93ad0204eeeb21e567df3d5841847373bf7a646
2020-07-06 10:07:26 -07:00
Naoki Oketani 404318cdbc Remove --export flag from kubectl get command.
Kubernetes-commit: c0562815fada455daf4826f59df895942dad8df0
2020-02-28 17:41:00 +09:00
zhouya0 7b9fac0696 Add kubectl apply generate name error message
Kubernetes-commit: c91ef266973904c82894492b887deb2a04b6d998
2020-03-10 15:51:41 +08:00
Brian Pursley b4594b0812 Added kubectl apply check to prevent using --dry-run=server with --force
Kubernetes-commit: 99f6dca1a8d1ea64d22a68263c77bcafd6fedc48
2020-04-16 21:23:36 -04:00
Julian V. Modesto df62cad179 Remove deprecated --server-dry-run.
For the beta server-side dry-run feature, `kubectl apply` provided the
`--server-dry-run` flag.

As of 1.18, this flag was deprecated and marked to be removed after 1
release.

Kubernetes-commit: 3e93f9926279db8a4d064d615c4ad7cfdc7ab38b
2020-05-20 16:53:53 -04: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
Tatsuhiro Tsujikawa e7bb62301f Restore the ability to `kubectl apply --prune` without -n flag
Before https://github.com/kubernetes/kubernetes/pull/83084, `kubectl
apply --prune` can prune resources in all namespaces specified in
config files.  After that PR got merged, only a single namespace is
considered for pruning.  It is OK if namespace is explicitly specified
by --namespace option, but what the PR does is use the default
namespace (or from kubeconfig) if not overridden by command line flag.
That breaks the existing usage of `kubectl apply --prune` without
--namespace option.  If --namespace is not used, there is no error,
and no one notices this issue unless they actually check that pruning
happens.  This issue also prevents resources in multiple namespaces in
config file from being pruned.

kubectl 1.16 does not have this bug.  Let's see the difference between
kubectl 1.16 and kubectl 1.17.  Suppose the following config file:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: foo
  namespace: a
  labels:
    pl: foo
data:
  foo: bar
---
apiVersion: v1
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: bar
  namespace: a
  labels:
    pl: foo
data:
  foo: bar
```

Apply it with `kubectl apply -f file`.  Then comment out ConfigMap foo
in this file.  kubectl 1.16 prunes ConfigMap foo with the following
command:

$ kubectl-1.16 apply -f file -l pl=foo --prune
configmap/bar configured
configmap/foo pruned

But kubectl 1.17 does not prune ConfigMap foo with the same command:

$ kubectl-1.17 apply -f file -l pl=foo --prune
configmap/bar configured

With this patch, kubectl once again can prune the resource as before.

Kubernetes-commit: 7af3b01f24edfde34e42640ee565a5a6bb66ce26
2020-03-27 01:11:36 +00:00
Sean R. Sullivan 34abefcfa8 Even with build error, kubectl apply should apply all valid resources
Kubernetes-commit: 748ad74245778a93a68652cd7e804d6a1e13ad9d
2020-04-03 19:50:25 -07:00
Julian V. Modesto 1cfa7c66b3 Ensure diff doesn't persist patches
Kubernetes-commit: 9c0320f1bfd8edfb11c283b3fd422dc6e49360c5
2020-04-02 17:14:17 -04:00
Sean R. Sullivan 26ca5b3402 Fixes problem where kubectl apply stops after first error
Kubernetes-commit: b75990cc7bccc5693df34e29745eea0c98d095d1
2020-03-26 13:24:33 -07:00
Jordan Liggitt 0c62c9a83a client-go dynamic client: add context to callers
Kubernetes-commit: b7c2faf26c2a25427794478c6265e6d55e8acb5a
2020-03-06 10:17:41 -05:00
Jordan Liggitt 1de89515de client-go dynamic client: update DeleteOptions callers
Kubernetes-commit: b19dc3a474e840340cb357f5ea9f4e575bad888d
2020-03-06 10:20:40 -05:00
Julian V. Modesto 5db847388b Hide deprecated --server-dry-run for kubectl apply
Kubernetes-commit: 7b214c96b01bf34345d4d7d82fcf5a85fd8318dd
2020-02-28 16:19:51 -05: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
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
Julian V. Modesto a3f7877cd1 Support DryRun in cli-runtime REST Helper.
- Move TestSupportsDryRun to cli-runtime
- Move TestDryRunVerifier to cli-runtime
- Add OpenAPI schema for testdata to cli-runtime
- Use Helper.DryRun and DryRunVerifier for Apply
- Add WithOptions methods to Helper

Kubernetes-commit: 6bea0e469bcfe4967cbf2656a998d60e0b684747
2019-12-18 22:00:34 -05:00
martinkaburu 50f26dd951 fix apply --prune to check cli specified namespace
Kubernetes-commit: f2518347f3dbe36586367c94aa98d5096f74a742
2019-11-25 23:21:43 +03:00
zhouya0 65d1aa5d00 fix apply set last applied namespace
Kubernetes-commit: 4291a03e39559d10eab0253f9cd431d6a375e235
2019-12-20 16:09:49 +08:00
danielqsj 4b914450ab unify alias of api errors under pkg and staging
Kubernetes-commit: 5bc0e26c1902e7e28abfc828de19a2dbb3e492c2
2019-11-12 16:26:59 +08:00
Sean Sullivan 2598a9eb6d Adds PreProcessor and PostProcessor functions for modifying apply behavior
Kubernetes-commit: 79bc63fb4b79caea4b141d318b11a0892ca14c95
2019-12-17 14:58:54 -08:00
Sean Sullivan 641631dfad Moves visitedUids and visitedNamespaces (used for pruning) into ApplyOptions
Kubernetes-commit: 4e45421f610eb881a03c0d82fca038788db12b08
2019-12-17 14:19:00 -08:00
Sean Sullivan 42da131431 Move patch functionality for apply into its own file.
Kubernetes-commit: 670369f2a4a7a7d9dad3a1ae1a334317a135f6c7
2019-12-16 16:41:49 -08:00
Sean Sullivan 65d873e277 Moved prune functionality into its own file.
Kubernetes-commit: e38e320222a1f44373ab3eaea8713f4772b26f6b
2019-12-16 16:13:39 -08:00
Sean Sullivan dfcc649b05 Refactored some apply printing functionality; removed unneeded count and objs variables
Kubernetes-commit: 07cb2fda5dada5c5145216bcab90e38426cf68e8
2019-12-16 15:21:57 -08:00
Sean Sullivan dd819b3425 Created GetObjects() method for ApplyOptions and integrated into apply
Kubernetes-commit: 02af4c9be20db201f2a2069816e97004a96bf760
2019-12-16 13:56:52 -08:00
Sean Sullivan 395bc6fc90 Changes Visit() to Infos() in apply to keep slice of objects
Kubernetes-commit: 2103ea4ddedc59d14322fd0fc34c8a9928256551
2019-12-16 13:00:33 -08:00
clarklee92 87db492820 Modify the status code number to HTTP status semantics
Signed-off-by: clarklee92 <clarklee1992@hotmail.com>

Kubernetes-commit: f86f5ee14ef3c8adf9855ce16dcc57beca949719
2019-11-06 00:45:35 +08:00
Sean Sullivan 3ec9685c39 Rename test/data directory to testdata
Kubernetes-commit: 4ce97d6c48ae4735463f020430dd20539a03e8c5
2019-10-31 13:40:02 -07:00
Ted Yu 04c0c6e8db Prune should respect namespace
Kubernetes-commit: 88e2f8e04fa310e848f07d0a2ab801aa0917e408
2019-09-25 16:43:08 -07:00
wojtekt 52d3bfc415 Minor cleanup of jsonFallbackEncoder
Kubernetes-commit: cd24a0e5fa7af1bd921386cf80c90cd535954e6c
2019-09-22 13:50:05 +02:00
ZP-AlwaysWin a376c2df78 replace 200 with http.StatusOK
Kubernetes-commit: cfa77048f9b7fa96bad4eebb059cf60acc9dfd29
2019-09-12 22:35:19 +08:00
haoshuwei 4dd9f90e6e fix some missing errors return statements
Signed-off-by: haoshuwei <haoshuwei24@gmail.com>

Kubernetes-commit: c4fe8f11b200d0a97e8ce447e5af592b5c4870d0
2019-09-09 13:54:14 +08: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
Antoine Pelisse 440d570248 Improve error message on server-side apply conflicts
Kubernetes-commit: a890331115340280bb1878c8baa46670cd6f0814
2019-08-26 10:37:42 -07:00
Sean Sullivan 1cba7858ad Update test data to reflect code move to staging
Kubernetes-commit: 58b59ae4e07f9d3718271a43740a4de9508d8688
2019-08-01 15:17:53 -07:00
Sean Sullivan 1483769081 Update gofmt
Kubernetes-commit: e2cae2344486af198f8ab38e4dd97d4f24dfd190
2019-08-01 13:14:06 -07:00
Sean Sullivan 5b48717f2d Update import statements to reflect code move
Kubernetes-commit: acece3c2964115a4f29a43e368ad5de59dbbc258
2019-08-01 11:10:05 -07:00
Sean Sullivan c6063dd846 Move pkg/kubectl/cmd/{command} to staging
Kubernetes-commit: 0e0ea523392f1121f61f99ac30a9bc2043eaed90
2019-08-01 11:01:40 -07:00