From 72835084783680e0286a81a0525d90bd271ab22a Mon Sep 17 00:00:00 2001 From: Fiachra Corcoran Date: Tue, 3 Sep 2024 09:15:13 +0100 Subject: [PATCH] Upgrade kyaml --- go.mod | 5 +- go.sum | 10 ++-- internal/kpt/util/fix/fix.go | 91 ------------------------------------ 3 files changed, 9 insertions(+), 97 deletions(-) delete mode 100644 internal/kpt/util/fix/fix.go diff --git a/go.mod b/go.mod index dae12fb7..af784189 100644 --- a/go.mod +++ b/go.mod @@ -58,8 +58,8 @@ require ( k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 sigs.k8s.io/cli-utils v0.35.0 sigs.k8s.io/controller-runtime v0.18.5 - sigs.k8s.io/kustomize/api v0.14.0 - sigs.k8s.io/kustomize/kyaml v0.14.3 + sigs.k8s.io/kustomize/api v0.17.2 + sigs.k8s.io/kustomize/kyaml v0.17.2 sigs.k8s.io/yaml v1.4.0 ) @@ -183,6 +183,7 @@ require ( gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240730163845-b1a4ccb954bf // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect + gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 25337ce8..0676ea5f 100644 --- a/go.sum +++ b/go.sum @@ -679,6 +679,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= @@ -742,11 +744,11 @@ sigs.k8s.io/controller-runtime v0.18.5 h1:nTHio/W+Q4aBlQMgbnC5hZb4IjIidyrizMai9P sigs.k8s.io/controller-runtime v0.18.5/go.mod h1:TVoGrfdpbA9VRFaRnKgk9P5/atA0pMwq+f+msb9M8Sg= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kustomize/api v0.14.0 h1:6+QLmXXA8X4eDM7ejeaNUyruA1DDB3PVIjbpVhDOJRA= -sigs.k8s.io/kustomize/api v0.14.0/go.mod h1:vmOXlC8BcmcUJQjiceUbcyQ75JBP6eg8sgoyzc+eLpQ= +sigs.k8s.io/kustomize/api v0.17.2 h1:E7/Fjk7V5fboiuijoZHgs4aHuexi5Y2loXlVOAVAG5g= +sigs.k8s.io/kustomize/api v0.17.2/go.mod h1:UWTz9Ct+MvoeQsHcJ5e+vziRRkwimm3HytpZgIYqye0= sigs.k8s.io/kustomize/kyaml v0.10.21/go.mod h1:TYWhGwW9vjoRh3rWqBwB/ZOXyEGRVWe7Ggc3+KZIO+c= -sigs.k8s.io/kustomize/kyaml v0.14.3 h1:WpabVAKZe2YEp/irTSHwD6bfjwZnTtSDewd2BVJGMZs= -sigs.k8s.io/kustomize/kyaml v0.14.3/go.mod h1:npvh9epWysfQ689Rtt/U+dpOJDTBn8kUnF1O6VzvmZA= +sigs.k8s.io/kustomize/kyaml v0.17.2 h1:+AzvoJUY0kq4QAhH/ydPHHMRLijtUKiyVyh7fOSshr0= +sigs.k8s.io/kustomize/kyaml v0.17.2/go.mod h1:9V0mCjIEYjlXuCdYsSXvyoy2BTsLESH7TlGV81S282U= sigs.k8s.io/structured-merge-diff/v4 v4.0.2/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK1F7G282QMXDPYydCw= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= diff --git a/internal/kpt/util/fix/fix.go b/internal/kpt/util/fix/fix.go deleted file mode 100644 index b9894fb2..00000000 --- a/internal/kpt/util/fix/fix.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2019 The kpt and Nephio Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package fix - -import ( - "fmt" - "io" - "path/filepath" - - "sigs.k8s.io/kustomize/kyaml/fix/fixsetters" -) - -// Command fixes the local kpt package and upgrades it to use latest feature -type Command struct { - // PkgPath path to the kpt package directory - PkgPath string - - // DryRun indicates that only preview of actions should be printed without - // performing actual actions - DryRun bool - - // StdOut standard out to write messages to - StdOut io.Writer -} - -// Run runs the Command. -func (c Command) Run() error { - printFunc := printFunc(c.StdOut, c.DryRun) - printFunc("processing resource configs to identify possible fixes... ") - return c.fixV1Setters() -} - -func (c Command) fixV1Setters() error { - printFunc := printFunc(c.StdOut, c.DryRun) - f := &fixsetters.SetterFixer{ - PkgPath: c.PkgPath, - OpenAPIPath: filepath.Join(c.PkgPath, "Kptfile"), - DryRun: c.DryRun, - } - sfr, err := f.FixV1Setters() - if err != nil { - return err - } - if !sfr.NeedFix { - printFunc("package is using latest version of setters, no fix needed") - return nil - } - - for _, setter := range sfr.CreatedSetters { - printFunc("created setter with name %s", setter) - } - printFunc("created %d setters in total", len(sfr.CreatedSetters)) - - for _, subst := range sfr.CreatedSubst { - printFunc("created substitution with name %s", subst) - } - printFunc("created %d substitution in total", len(sfr.CreatedSubst)) - - for setter, err := range sfr.FailedSetters { - printFunc("failed to create setter with name %s: %v", setter, err) - } - - for subst, err := range sfr.FailedSubst { - printFunc("failed to create substitution with name %s: %v", subst, err) - } - - return err -} - -type printerFunc func(format string, a ...interface{}) - -func printFunc(w io.Writer, dryRun bool) printerFunc { - return func(format string, a ...interface{}) { - if dryRun { - format += " (dry-run)" - } - fmt.Fprintf(w, format+"\n", a...) - } -}