Skip to content

Commit 9cd4aeb

Browse files
authored
Update cli-utils to v0.26.0 (#2550)
1 parent 3f23103 commit 9cd4aeb

File tree

12 files changed

+39
-25
lines changed

12 files changed

+39
-25
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
k8s.io/klog/v2 v2.9.0
2424
k8s.io/kubectl v0.21.1
2525
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9
26-
sigs.k8s.io/cli-utils v0.25.1-0.20210702190410-c1a7c2d0409d
26+
sigs.k8s.io/cli-utils v0.26.0
2727
sigs.k8s.io/kustomize/api v0.8.10
2828
sigs.k8s.io/kustomize/kyaml v0.11.2-0.20210920224623-c47fc4860720
2929
)

go.sum

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,9 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
268268
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
269269
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
270270
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
271-
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
272271
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
272+
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
273+
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
273274
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
274275
github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g=
275276
github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
@@ -566,6 +567,8 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
566567
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
567568
github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE=
568569
github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg=
570+
github.com/spyzhov/ajson v0.4.2 h1:JMByd/jZApPKDvNsmO90X2WWGbmT2ahDFp73QhZbg3s=
571+
github.com/spyzhov/ajson v0.4.2/go.mod h1:63V+CGM6f1Bu/p4nLIN8885ojBdt88TbLoSFzyqMuVA=
569572
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
570573
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
571574
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
@@ -769,8 +772,9 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
769772
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
770773
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
771774
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
772-
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
773775
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
776+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
777+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
774778
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
775779
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
776780
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
@@ -938,8 +942,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
938942
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
939943
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
940944
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
941-
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
942945
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
946+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
947+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
943948
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
944949
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
945950
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
@@ -988,8 +993,8 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
988993
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
989994
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
990995
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.15/go.mod h1:LEScyzhFmoF5pso/YSeBstl57mOzx9xlU9n85RGrDQg=
991-
sigs.k8s.io/cli-utils v0.25.1-0.20210702190410-c1a7c2d0409d h1:/JmSgB1dQKNcxbRviaIwTsoA4i0iLC9vJOsKMGSMG3w=
992-
sigs.k8s.io/cli-utils v0.25.1-0.20210702190410-c1a7c2d0409d/go.mod h1:uYYtfiY5dsWTRISBLwuSLGwbasAm/gc4K8yvN8eGbYw=
996+
sigs.k8s.io/cli-utils v0.26.0 h1:N1X1NVN19+daTihVimkSVNMgiVPIHG9OO3SJPh6SBQI=
997+
sigs.k8s.io/cli-utils v0.26.0/go.mod h1:myCFn83XMe7vC1ZX5CEJJIY2cqsl6IxYI727mLW1mfE=
993998
sigs.k8s.io/controller-runtime v0.9.0-beta.5.0.20210524185538-7181f1162e79 h1:unv8eVaIbf/1vh/ewJfHns6ffKF69fwUxZZpaxQOb7g=
994999
sigs.k8s.io/controller-runtime v0.9.0-beta.5.0.20210524185538-7181f1162e79/go.mod h1:rgf+cBz72pYlKXDRNhI1WFQv/S86EMUV4/ySmsEYgHk=
9951000
sigs.k8s.io/kustomize/api v0.8.8/go.mod h1:He1zoK0nk43Pc6NlV085xDXDXTNprtcyKZVm3swsdNY=

internal/cmdmigrate/migratecmd.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (mr *MigrateRunner) retrieveConfigMapInv(reader io.Reader, args []string) (
249249
func (mr *MigrateRunner) retrieveInvObjs(cmInvClient inventory.InventoryClient,
250250
invObj inventory.InventoryInfo) ([]object.ObjMetadata, error) {
251251
fmt.Fprint(mr.ioStreams.Out, " retrieve ConfigMap inventory objs...")
252-
cmObjs, err := cmInvClient.GetClusterObjs(invObj)
252+
cmObjs, err := cmInvClient.GetClusterObjs(invObj, mr.dryRunStrategy())
253253
if err != nil {
254254
return nil, err
255255
}
@@ -294,7 +294,7 @@ func (mr *MigrateRunner) migrateObjs(rgInvClient inventory.InventoryClient,
294294
return err
295295
}
296296

297-
_, err = rgInvClient.Merge(invInfo, cmObjs)
297+
_, err = rgInvClient.Merge(invInfo, cmObjs, mr.dryRunStrategy())
298298
if err != nil {
299299
return err
300300
}
@@ -307,10 +307,7 @@ func (mr *MigrateRunner) migrateObjs(rgInvClient inventory.InventoryClient,
307307
func (mr *MigrateRunner) deleteConfigMapInv(cmInvClient inventory.InventoryClient,
308308
invObj inventory.InventoryInfo) error {
309309
fmt.Fprint(mr.ioStreams.Out, " deleting old ConfigMap inventory object...")
310-
if mr.dryRun {
311-
cmInvClient.SetDryRunStrategy(common.DryRunClient)
312-
}
313-
if err := cmInvClient.DeleteInventoryObj(invObj); err != nil {
310+
if err := cmInvClient.DeleteInventoryObj(invObj, mr.dryRunStrategy()); err != nil {
314311
return err
315312
}
316313
fmt.Fprint(mr.ioStreams.Out, "success\n")
@@ -344,6 +341,14 @@ func (mr *MigrateRunner) deleteConfigMapFile() error {
344341
return nil
345342
}
346343

344+
// dryRunStrategy returns the strategy to use based on user config
345+
func (mr *MigrateRunner) dryRunStrategy() common.DryRunStrategy {
346+
if mr.dryRun {
347+
return common.DryRunClient
348+
}
349+
return common.DryRunNone
350+
}
351+
347352
// findResourceGroupInv returns the ResourceGroup inventory object from the
348353
// passed slice of objects, or nil and and error if there is a problem.
349354
func findResourceGroupInv(objs []*unstructured.Unstructured) (*unstructured.Unstructured, error) {

internal/cmdmigrate/migratecmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func TestKptMigrate_migrateObjs(t *testing.T) {
321321
}
322322
assert.NoError(t, err)
323323
// Retrieve the objects stored by the inventory client and validate.
324-
migratedObjs, err := rgInvClient.GetClusterObjs(nil)
324+
migratedObjs, err := rgInvClient.GetClusterObjs(nil, common.DryRunNone)
325325
assert.NoError(t, err)
326326
if len(tc.objs) != len(migratedObjs) {
327327
t.Errorf("expected num migrated objs (%d), got (%d)", len(tc.objs), len(migratedObjs))

pkg/live/apply-crd-task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (a *ApplyCRDTask) Action() event.ResourceAction {
4040
return event.ApplyAction
4141
}
4242

43-
func (a *ApplyCRDTask) Identifiers() []object.ObjMetadata {
43+
func (a *ApplyCRDTask) Identifiers() object.ObjMetadataSet {
4444
return object.UnstructuredsToObjMetasOrDie([]*unstructured.Unstructured{a.crd})
4545
}
4646

pkg/live/inventoryrg.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"k8s.io/apimachinery/pkg/runtime/schema"
2727
"k8s.io/klog/v2"
2828
cmdutil "k8s.io/kubectl/pkg/cmd/util"
29+
"sigs.k8s.io/cli-utils/pkg/apply/cache"
2930
"sigs.k8s.io/cli-utils/pkg/apply/event"
3031
"sigs.k8s.io/cli-utils/pkg/apply/taskrunner"
3132
"sigs.k8s.io/cli-utils/pkg/common"
@@ -109,8 +110,8 @@ func (icm *InventoryResourceGroup) ID() string {
109110

110111
// Load is an Inventory interface function returning the set of
111112
// object metadata from the wrapped ResourceGroup, or an error.
112-
func (icm *InventoryResourceGroup) Load() ([]object.ObjMetadata, error) {
113-
objs := []object.ObjMetadata{}
113+
func (icm *InventoryResourceGroup) Load() (object.ObjMetadataSet, error) {
114+
objs := object.ObjMetadataSet{}
114115
if icm.inv == nil {
115116
return objs, fmt.Errorf("inventory info is nil")
116117
}
@@ -160,7 +161,7 @@ func (icm *InventoryResourceGroup) Load() ([]object.ObjMetadata, error) {
160161
// Store is an Inventory interface function implemented to store
161162
// the object metadata in the wrapped ResourceGroup. Actual storing
162163
// happens in "GetObject".
163-
func (icm *InventoryResourceGroup) Store(objMetas []object.ObjMetadata) error {
164+
func (icm *InventoryResourceGroup) Store(objMetas object.ObjMetadataSet) error {
164165
icm.objMetas = objMetas
165166
return nil
166167
}
@@ -282,8 +283,10 @@ func InstallResourceGroupCRD(factory cmdutil.Factory) error {
282283
handleError(eventChannel, err)
283284
return
284285
}
286+
// Create a new cache map to hold the last known resource state & status
287+
resourceCache := cache.NewResourceCacheMap()
285288
// Run the task queue.
286-
runner := taskrunner.NewTaskStatusRunner(objs, statusPoller)
289+
runner := taskrunner.NewTaskStatusRunner(objs, statusPoller, resourceCache)
287290
err = runner.Run(context.Background(), taskQueue, eventChannel, taskrunner.Options{
288291
PollInterval: applyCRDPollInterval,
289292
UseCache: true,

pkg/live/inventoryrg_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func TestLoadStore(t *testing.T) {
125125
t.Fatalf("unexpected error %v received", err)
126126
return
127127
}
128-
if !object.SetEquals(tc.objs, objs) {
128+
if !objs.Equal(tc.objs) {
129129
t.Fatalf("expected inventory objs (%v), got (%v)", tc.objs, objs)
130130
}
131131
})

thirdparty/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This directory contains the files that are copied from 3rd-party projects and mo
88
- `runfn`: KRM function runner
99
- `cmdconfig`: Files copied from [cmd/config] v0.9.9 library
1010
- `commands`: Command files copied from [cmd/config]
11-
- `cli-utils`: Files copied from [cli-utils] 8200fe56434dbb4fa897912524793af3c3384828 library
11+
- `cli-utils`: Files copied from [cli-utils] v0.26.0 library
1212
- `commands`: Command files copied from [cli-utils/cmd]
1313

1414
# Copyright and Licenses
@@ -24,4 +24,4 @@ The modifications made in the 3rd-party files may be contributed to upstream. Th
2424
[kyaml]: https://github.com/kubernetes-sigs/kustomize/tree/8d72528eb5c73df80b20aae0a5e584c056879387/kyaml
2525
[cmd/config]: https://github.com/kubernetes-sigs/kustomize/tree/b9c36caa1c5c6ee64926021841ea441773d0767c/cmd/config
2626
[cli-utils]: https://github.com/kubernetes-sigs/cli-utils
27-
[cli-utils/cmd]: https://github.com/kubernetes-sigs/cli-utils/tree/8200fe56434dbb4fa897912524793af3c3384828
27+
[cli-utils/cmd]: https://github.com/kubernetes-sigs/cli-utils/tree/8b12ecd594e0bc4fa4b85ee6af3911ff33efd2aa/cmd

thirdparty/cli-utils/printers/events/formatter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (ef *formatter) FormatActionGroupEvent(age event.ActionGroupEvent, ags []ev
115115
for id, se := range c.LatestStatus() {
116116
// Only print information about objects that we actually care about
117117
// for this wait task.
118-
if found := object.ObjMetas(ag.Identifiers).Contains(id); found {
118+
if found := ag.Identifiers.Contains(id); found {
119119
ef.printResourceStatus(id, se)
120120
}
121121
}

thirdparty/cli-utils/printers/json/formatter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (jf *formatter) FormatActionGroupEvent(age event.ActionGroupEvent, ags []ev
112112
for id, se := range c.LatestStatus() {
113113
// Only print information about objects that we actually care about
114114
// for this wait task.
115-
if found := object.ObjMetas(ag.Identifiers).Contains(id); found {
115+
if found := ag.Identifiers.Contains(id); found {
116116
if err := jf.printResourceStatus(se); err != nil {
117117
return err
118118
}

0 commit comments

Comments
 (0)