Commit Graph

39 Commits

Author SHA1 Message Date
Arda Güçlü 3f05cfcd78 Migrate genericclioptions.IOStreams usage to genericiooptions
Kubernetes-commit: 00c30941260a27e6929aef84c7fdbc8f1508518c
2023-04-05 14:07:46 +03:00
Katrina Verey 03f092a1af Use standard *.kubernetes.io instead of *.k8s.io for ApplySet
Kubernetes-commit: a0cff30104ea950a5cc733a109e7f9084275e49e
2023-03-20 18:21:04 -04:00
justinsb 62b0fbdb7a kubectl prunev2: Refactor the applyset to be more reusable
This enables sharing with diff.

Kubernetes-commit: d016fdcc834099dee721f42a384e1bc1f710e599
2023-03-14 12:12:00 +00:00
Katrina Verey a038484b5c Allow conformant CRDs to be ApplySet parents
Kubernetes-commit: 923d9b63fd87e9446f5746f544237c7e0de009a0
2023-03-07 11:29:50 -05:00
Katrina Verey ca98377c3e Applyset dry run tests + ID value (#116265)
* Test for ApplySet with --dry-run=client|server

* Use the real format for ApplySet ID

* Incorporate feedback

* Adjustments from rebase

Kubernetes-commit: 6a31757f45693fec5ea4723bcb405ce4437e31ca
2023-03-15 11:17:56 +00:00
Justin SB 0567f1e464 prunev2: Implement basic pruning
Implement the basic prune strategy where we find-by-label and then
delete unknown objects.

Kubernetes-commit: f17a319dc60374a46be1b37a453227d134ac479e
2023-02-22 21:40:25 -05:00
Katrina Verey 250ef6fa54 Feedback and linter
Kubernetes-commit: 3b0e13482e4459f9cb6a006cac2da76333992efd
2023-03-03 11:50:16 -05:00
Katrina Verey a04ac8a907 Create and update the ApplySet parent object
Kubernetes-commit: 7f874c91017eefd12df3d824793ab7e9b0be088e
2023-02-27 18:40:59 -05:00
Justin SB 78b973156e prunev2: Add labels for objects that we apply
As we apply objects when using apply/prune v2, we want to be sure they
include the label that ties them back to the applyset they are part
of.

Co-Authored-By: Katrina Verey <katrina.verey@shopify.com>

Kubernetes-commit: ab058308401b35b4865424cfa43ed75a554af2a3
2023-02-22 22:06:48 -05:00
Katrina Verey 530dea246b Introduce CLI for ApplySet-based pruning (#115979)
* Introduce CLI for ApplySet-based pruning

* Address feedback from justinsb

* Fix parent namespace sourcing and restrict types. Increase test coverage.

Kubernetes-commit: 0dd346673c00158247c8232f9e81a308fb741463
2023-02-27 12:20:40 -05:00
Sean Sullivan 7efcc7e0ac Fixes prune for server-side applied objects
Kubernetes-commit: 21393f1b1d859cecdcc9aeee01f7dbf9aab71120
2022-10-25 21:59:31 +00:00
Chok Yip Lau 3fea4735ad Removed factory from apply command flag struct
Kubernetes-commit: cdd84a28bfc2e1e7ad552de128cd1644c7deeae7
2022-11-20 15:53:05 -05:00
Sean Sullivan 7c10c1c878 Unexport OpenAPIGetter factory method
Kubernetes-commit: 1da46b2f28267421dad9a8e5164e6bce16ae9fcb
2022-12-12 16:01:05 -08:00
inosato 8272d71ba6 Remove ioutil from kubectl
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 774ab1349bfd553c97a99b992e9f38659f541c84
2022-07-30 22:31:16 +09:00
Paco Xu 6c2e12e0be kubectl-apply: add prune test cases for non-namespaced resources
Signed-off-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: 7263aba71bfdd2286200ffd7ef79766950c5fcd9
2022-11-09 07:43:43 +08: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
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
Arda Güçlü 89edfadfa3 Use OpenAPI to determine patch type in kubectl apply patching
Currently `kubectl apply` determines correct patch type for given
GVKs by trying to register schema and if it succeeds, it uses
strategic-merge-patch.

But OpenAPI endpoint already stores which patch types are supported
by GVKs. This PR checks OpenAPI endpoint to retrieve patch type,
if OpenAPI is enabled. If it is not enabled, patch type determination
will be done as conventional registration method.

Kubernetes-commit: cddbb0c56397448ac0489f0473a26601c1feece8
2022-06-08 13:12:16 +03:00
Sean Sullivan e23896b42c gofmt update
Kubernetes-commit: d84abe868d673de917b5714cd2460f21413ac745
2022-07-24 23:46:44 -07:00
Sean Sullivan acec06e5c9 disallow --force and --prune in client-side apply
Kubernetes-commit: e02a26d74a2e346b4a5607c99180e5b748923e5f
2022-07-24 16:26:57 -07:00
Jefftree ef358291b5 googleapis/gnostic -> google/gnostic
Kubernetes-commit: 8a1d5947ad34ba275192341baa4e5fef8e6c7f24
2022-03-15 20:36:21 -07:00
Julian V. Modesto 04f62ffb0b Cache the OpenAPI schema for server-side dry-run.
Currently, server-side dry-run fetches the OpenAPI schema for every
single object.

This change fetches the OpenAPI schema only once.

Kubernetes-commit: caa158610dfb53de3582ed6df0eb37359206fc66
2021-01-19 16:36:14 -05: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
Yuvaraj Kakaraparthi 36c221e3cf kubectl: cannot use --force with --server-side
Kubernetes-commit: f93ad0204eeeb21e567df3d5841847373bf7a646
2020-07-06 10:07:26 -07: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 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
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
danielqsj 4b914450ab unify alias of api errors under pkg and staging
Kubernetes-commit: 5bc0e26c1902e7e28abfc828de19a2dbb3e492c2
2019-11-12 16:26:59 +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
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
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