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
This commit is contained in:
Daniel 2022-03-27 23:41:21 -03:00 committed by Kubernetes Publisher
parent e0cc018068
commit 12ebe4811f
4 changed files with 14 additions and 8 deletions

8
go.mod
View file

@ -32,8 +32,8 @@ require (
golang.org/x/sys v0.0.0-20220209214540-3681064d5158
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.0.0-20220327010943-9431395a90d0
k8s.io/apimachinery v0.0.0-20220327010739-4d8ad187e0a0
k8s.io/cli-runtime v0.0.0-20220327013338-069021cdf734
k8s.io/apimachinery v0.0.0-20220327010740-1992dccd17de
k8s.io/cli-runtime v0.0.0-20220328052852-84e333d968d4
k8s.io/client-go v0.0.0-20220327011239-402aa66c5cad
k8s.io/component-base v0.0.0-20220327011759-ab4264d408ec
k8s.io/component-helpers v0.0.0-20220327011904-6a03ec91fb2a
@ -49,8 +49,8 @@ require (
replace (
k8s.io/api => k8s.io/api v0.0.0-20220327010943-9431395a90d0
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220327010739-4d8ad187e0a0
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20220327013338-069021cdf734
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20220327010740-1992dccd17de
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20220328052852-84e333d968d4
k8s.io/client-go => k8s.io/client-go v0.0.0-20220327011239-402aa66c5cad
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20220327010549-a207ba43f29b
k8s.io/component-base => k8s.io/component-base v0.0.0-20220327011759-ab4264d408ec

8
go.sum
View file

@ -850,10 +850,10 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20220327010943-9431395a90d0 h1:X+CjFuKiWUYmXxuNueT2v0YNHDZhiRJ0389k24Fh1cg=
k8s.io/api v0.0.0-20220327010943-9431395a90d0/go.mod h1:OHmmfP+B0EkV7rltm6KDhsy7UJUjc3nPo97jKZwLIkM=
k8s.io/apimachinery v0.0.0-20220327010739-4d8ad187e0a0 h1:vZrBcVfdctsRfR+SUOLUmY4+eU4FOnRIpsx03xNPqJ8=
k8s.io/apimachinery v0.0.0-20220327010739-4d8ad187e0a0/go.mod h1:WkN7hnr/sIpKTK8v3BZKqLkdqTMz00TBdMWqE0M0O7Q=
k8s.io/cli-runtime v0.0.0-20220327013338-069021cdf734 h1:zOz8tt84ytnEbZ+p5SP5G8iBkKv7bNePff7F3iYTa+A=
k8s.io/cli-runtime v0.0.0-20220327013338-069021cdf734/go.mod h1:hPwIJLMZ4laeS/nukP0hf4KWypJmGtqTckI3/siTQv4=
k8s.io/apimachinery v0.0.0-20220327010740-1992dccd17de h1:YQ7cVEFpw9qaBjGa5/JYzHq/Xi/mKBAeUmEt6NwljMc=
k8s.io/apimachinery v0.0.0-20220327010740-1992dccd17de/go.mod h1:WkN7hnr/sIpKTK8v3BZKqLkdqTMz00TBdMWqE0M0O7Q=
k8s.io/cli-runtime v0.0.0-20220328052852-84e333d968d4 h1:s1ybVp4XopMSOi+Yml+Pd1tECxxu4jxhRyMRknlZbiA=
k8s.io/cli-runtime v0.0.0-20220328052852-84e333d968d4/go.mod h1:hU5Muk4FAIq+AnDBXm9k2oOcYWDmHqc9n1ow7hNsdQ0=
k8s.io/client-go v0.0.0-20220327011239-402aa66c5cad h1:v2udgOBdg/+3kM7nGJtQfjvnlsjgA0wdR9sJjiX7UfQ=
k8s.io/client-go v0.0.0-20220327011239-402aa66c5cad/go.mod h1:HCq7QlEN/lEZ7hg4X9ldPo4rbktT3jtB83/5IJmurlw=
k8s.io/code-generator v0.0.0-20220327010549-a207ba43f29b/go.mod h1:K+f3PS8AJPkGO9NJoAqq6J1NMsr37Ey1IaQrQ2c97yQ=

View file

@ -151,6 +151,9 @@ var (
# Apply the JSON passed into stdin to a pod
cat pod.json | kubectl apply -f -
# Apply the configuration from all files that end with '.json' - i.e. expand wildcard characters in file names
kubectl apply -f '*.json'
# Note: --prune is still in Alpha
# Apply the configuration in manifest.yaml that matches label app=nginx and delete all other resources that are not in the file and match label app=nginx
kubectl apply --prune -f manifest.yaml -l app=nginx

View file

@ -82,6 +82,9 @@ var (
# Delete resources from a directory containing kustomization.yaml - e.g. dir/kustomization.yaml
kubectl delete -k dir
# Delete resources from all files that end with '.json' - i.e. expand wildcard characters in file names
kubectl apply -f '*.json'
# Delete a pod based on the type and name in the JSON passed into stdin
cat pod.json | kubectl delete -f -