Skip to content

Commit

Permalink
add delete setter cmd from kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
Jijie Wei committed Jul 4, 2020
1 parent 3134e8f commit dd8e244
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 17 deletions.
12 changes: 11 additions & 1 deletion commands/configcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func GetConfigCommand(name string) *cobra.Command {
createSetter.Long = cfgdocs.CreateSetterShort + "\n" + cfgdocs.CreateSetterLong
createSetter.Example = cfgdocs.CreateSetterExamples

deleteSetter := DeleteSetterCommand(name)
deleteSetter.Short = cfgdocs.DeleteSetterShort
deleteSetter.Long = cfgdocs.DeleteSetterShort + "\n" + cfgdocs.DeleteSetterLong
deleteSetter.Example = cfgdocs.DeleteSetterExamples

createSubstitution := CreateSubstCommand(name)
createSubstitution.Short = cfgdocs.CreateSubstShort
createSubstitution.Long = cfgdocs.CreateSubstShort + "\n" + cfgdocs.CreateSubstLong
Expand Down Expand Up @@ -94,7 +99,7 @@ func GetConfigCommand(name string) *cobra.Command {
tree.Long = cfgdocs.TreeShort + "\n" + cfgdocs.TreeLong
tree.Example = cfgdocs.TreeExamples

cfgCmd.AddCommand(an, cat, count, createSetter, createSubstitution, fmt,
cfgCmd.AddCommand(an, cat, count, createSetter, deleteSetter, createSubstitution, fmt,
grep, listSetters, set, tree)
return cfgCmd
}
Expand All @@ -104,6 +109,11 @@ func CreateSetterCommand(parent string) *cobra.Command {
return configcobra.CreateSetter(parent)
}

func DeleteSetterCommand(parent string) *cobra.Command {
fieldmeta.SetShortHandRef(ShortHandRef)
return configcobra.DeleteSetter(parent)
}

func CreateSubstCommand(parent string) *cobra.Command {
fieldmeta.SetShortHandRef(ShortHandRef)
return configcobra.CreateSubstitution(parent)
Expand Down
19 changes: 13 additions & 6 deletions e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ func TestKptGetSet(t *testing.T) {
"Kptfile": {
` setBy: package-default
value: "5"`,
` value: "7"`,
` value: "7"
isSet: true`,
},
},
},
Expand All @@ -62,7 +63,8 @@ func TestKptGetSet(t *testing.T) {
"Kptfile": {
` setBy: package-default
value: "5"`,
` value: "7"`,
` value: "7"
isSet: true`,
},
},
},
Expand All @@ -72,7 +74,8 @@ func TestKptGetSet(t *testing.T) {
"Kptfile": {
` setBy: package-default
value: "5"`,
` value: "7"`,
` value: "7"
isSet: true`,
},
},
},
Expand All @@ -83,7 +86,8 @@ func TestKptGetSet(t *testing.T) {
"Kptfile": {
` setBy: package-default
value: "5"`,
` value: "7"`,
` value: "7"
isSet: true`,
},
},
},
Expand All @@ -95,7 +99,8 @@ func TestKptGetSet(t *testing.T) {
` setBy: package-default
value: "5"`,
` setBy: foo
value: "7"`,
value: "7"
isSet: true`,
},
},
},
Expand All @@ -113,7 +118,8 @@ func TestKptGetSet(t *testing.T) {
"Kptfile": {
` setBy: package-default
value: "5"`,
` value: "7"`,
` value: "7"
isSet: true`,
},
},
},
Expand Down Expand Up @@ -378,6 +384,7 @@ openAPI:
name: replicas
value: "4"
setBy: pw
isSet: true
`,
expectedResources: `
apiVersion: apps/v1
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/go-errors/errors v1.0.1
github.com/go-openapi/spec v0.19.5
github.com/gogo/protobuf v1.3.1 // indirect
github.com/google/addlicense v0.0.0-20200622132530-df58acafd6d5 // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/pkg/errors v0.9.1
github.com/posener/complete/v2 v2.0.1-alpha.12
Expand All @@ -25,6 +24,6 @@ require (
// Once there is a 0.18 release, we can import a semver release.
k8s.io/kubectl v0.0.0-20191219154910-1528d4eea6dd
sigs.k8s.io/cli-utils v0.15.0
sigs.k8s.io/kustomize/cmd/config v0.3.0
sigs.k8s.io/kustomize/kyaml v0.3.1-0.20200618190311-fb6830c98a78
sigs.k8s.io/kustomize/cmd/config v0.0.0-20200629173832-441581b74521
sigs.k8s.io/kustomize/kyaml v0.3.2
)
13 changes: 6 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995/go.mod h1:lJgMEyOkYFkPcDKwRXegd+iM6E7matEszMG5HhwytU8=
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e/go.mod h1:0AA//k/eakGydO4jKRoRL2j92ZKSzTgj9tclaCrvXHk=
github.com/google/addlicense v0.0.0-20200622132530-df58acafd6d5 h1:m6Z1Cm53o4VecQFxKCnvULGfIT0Igo3MX131i+00IIo=
github.com/google/addlicense v0.0.0-20200622132530-df58acafd6d5/go.mod h1:EMjYTRimagHs1FwlIqKyX3wAM0u3rA+McvlIIWmSamA=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
Expand Down Expand Up @@ -644,19 +642,20 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
sigs.k8s.io/cli-utils v0.12.0 h1:+CvYwQAEtKvcx/NaUVF9rDKvY91VwJj+i7D2lWBMYc0=
sigs.k8s.io/cli-utils v0.12.0/go.mod h1:H35YA5iJIM7EVNgqDTjX2dgt4wE23zmnXOTSTlyD+PE=
sigs.k8s.io/cli-utils v0.15.0 h1:QiGX8wfBaegKQhejZg2EsqCPYGtyavIpEjNTMdpzUlY=
sigs.k8s.io/cli-utils v0.15.0/go.mod h1:H35YA5iJIM7EVNgqDTjX2dgt4wE23zmnXOTSTlyD+PE=
sigs.k8s.io/controller-runtime v0.4.0 h1:wATM6/m+3w8lj8FXNaO6Fs/rq/vqoOjO1Q116Z9NPsg=
sigs.k8s.io/controller-runtime v0.4.0/go.mod h1:ApC79lpY3PHW9xj/w9pj+lYkLgwAAUZwfXkME1Lajns=
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/kustomize/cmd/config v0.3.0 h1:MXbJgQXeO45DAdttKjQKUgO7WJ3B8+BopDcMZw/qKbw=
sigs.k8s.io/kustomize/cmd/config v0.3.0/go.mod h1:3fEoJyrBJLE1Nag7glwmpqd+uH0JzMTrpumYxmhbj/8=
sigs.k8s.io/kustomize/cmd/config v0.0.0-20200629173832-441581b74521 h1:5Ph1WKZMOa1/0R4WUtRatC/jwE8YKa/YkRSqHapFCG8=
sigs.k8s.io/kustomize/cmd/config v0.0.0-20200629173832-441581b74521/go.mod h1:0gcINVqp3BKKS/cDUuU5GLxVz0Y4UoW6MBBuEhrTgYU=
sigs.k8s.io/kustomize/kyaml v0.1.4/go.mod h1:461i94nj0h0ylJ6w83jLkR4SqqVhn1iY6fjD0JSTQeE=
sigs.k8s.io/kustomize/kyaml v0.3.0/go.mod h1:LjuK+fiy63C7cz/6I0OqxIth8nZzytzzDOgpjBHCtG8=
sigs.k8s.io/kustomize/kyaml v0.3.1-0.20200618190311-fb6830c98a78 h1:uiGRG+4yLkXIq8/ilseSdQDl1iLp/nPbrujY2Vq2lhM=
sigs.k8s.io/kustomize/kyaml v0.3.1-0.20200618190311-fb6830c98a78/go.mod h1:Z9y2rjGUGzVhgdYtDphESD9Hz+JZKOofKYObQYtMyVI=
sigs.k8s.io/kustomize/kyaml v0.1.13/go.mod h1:72/rLkSi+L/pHM1oCjwrf3ClU+tH5kZQvvdLSqIHwWU=
sigs.k8s.io/kustomize/kyaml v0.3.2 h1:0AorBQuNiz/JwYBOULcjQTltif/vrPRjsEhGkE1FZig=
sigs.k8s.io/kustomize/kyaml v0.3.2/go.mod h1:Z9y2rjGUGzVhgdYtDphESD9Hz+JZKOofKYObQYtMyVI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA=
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18=
Expand Down

0 comments on commit dd8e244

Please sign in to comment.