From a2dbccad62f025b07a3bb1ddc16fd7325e2a14e8 Mon Sep 17 00:00:00 2001 From: Michael Plump Date: Fri, 13 Dec 2024 23:22:42 -0500 Subject: [PATCH] fix: fix YAML serialization. A change in kustomize meant that when you import its YAML libraries, you get a repackaged version of yaml.v3 instead of the real ones. This broke YAML parsing in a very confusing way. Specifically, UnmarshalClusterVolumes no longer implemented yaml.v3/Unmarshaller. Instead it implemented sigs.k8s.io/yaml/goyaml.v3/Unmarshaller. Which means the YAML parser just never bothered to call our custom Unmarshaller logic. None of this is particularly interesting, but it took me at least 8 hours to figure it out, so I wanted to write it down. --- pkg/skaffold/schema/latest/config.go | 2 +- pkg/skaffold/schema/util/yaml.go | 2 +- pkg/skaffold/schema/v2beta11/config.go | 2 +- pkg/skaffold/schema/v2beta12/config.go | 2 +- pkg/skaffold/schema/v2beta13/config.go | 2 +- pkg/skaffold/schema/v2beta14/config.go | 2 +- pkg/skaffold/schema/v2beta15/config.go | 2 +- pkg/skaffold/schema/v2beta16/config.go | 2 +- pkg/skaffold/schema/v2beta17/config.go | 2 +- pkg/skaffold/schema/v2beta18/config.go | 2 +- pkg/skaffold/schema/v2beta19/config.go | 2 +- pkg/skaffold/schema/v2beta20/config.go | 2 +- pkg/skaffold/schema/v2beta21/config.go | 2 +- pkg/skaffold/schema/v2beta22/config.go | 2 +- pkg/skaffold/schema/v2beta23/config.go | 2 +- pkg/skaffold/schema/v2beta24/config.go | 2 +- pkg/skaffold/schema/v2beta25/config.go | 2 +- pkg/skaffold/schema/v2beta26/config.go | 2 +- pkg/skaffold/schema/v2beta27/config.go | 2 +- pkg/skaffold/schema/v2beta28/config.go | 2 +- pkg/skaffold/schema/v2beta29/config.go | 2 +- pkg/skaffold/schema/v3/config.go | 2 +- pkg/skaffold/schema/v3alpha1/config.go | 2 +- pkg/skaffold/schema/v4beta1/config.go | 2 +- pkg/skaffold/schema/v4beta10/config.go | 2 +- pkg/skaffold/schema/v4beta11/config.go | 2 +- pkg/skaffold/schema/v4beta2/config.go | 2 +- pkg/skaffold/schema/v4beta3/config.go | 2 +- pkg/skaffold/schema/v4beta4/config.go | 2 +- pkg/skaffold/schema/v4beta5/config.go | 2 +- pkg/skaffold/schema/v4beta6/config.go | 2 +- pkg/skaffold/schema/v4beta7/config.go | 2 +- pkg/skaffold/schema/v4beta8/config.go | 2 +- pkg/skaffold/schema/v4beta9/config.go | 2 +- pkg/skaffold/schema/versions_test.go | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 78354fbcda9..860efb7f673 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -19,8 +19,8 @@ package latest import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/util/yaml.go b/pkg/skaffold/schema/util/yaml.go index 0fa6f8a8d1d..85c54d60279 100644 --- a/pkg/skaffold/schema/util/yaml.go +++ b/pkg/skaffold/schema/util/yaml.go @@ -19,8 +19,8 @@ package util import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" ) // UnmarshalClusterVolumes provides a helper function to diff --git a/pkg/skaffold/schema/v2beta11/config.go b/pkg/skaffold/schema/v2beta11/config.go index d4c43cd2f04..9059057a128 100755 --- a/pkg/skaffold/schema/v2beta11/config.go +++ b/pkg/skaffold/schema/v2beta11/config.go @@ -19,8 +19,8 @@ package v2beta11 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta12/config.go b/pkg/skaffold/schema/v2beta12/config.go index e66f63e63d9..0dc6660d15f 100755 --- a/pkg/skaffold/schema/v2beta12/config.go +++ b/pkg/skaffold/schema/v2beta12/config.go @@ -19,8 +19,8 @@ package v2beta12 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta13/config.go b/pkg/skaffold/schema/v2beta13/config.go index 12e4bf70548..b9b6c951b1b 100755 --- a/pkg/skaffold/schema/v2beta13/config.go +++ b/pkg/skaffold/schema/v2beta13/config.go @@ -19,8 +19,8 @@ package v2beta13 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta14/config.go b/pkg/skaffold/schema/v2beta14/config.go index 105237d625a..4356df52e89 100755 --- a/pkg/skaffold/schema/v2beta14/config.go +++ b/pkg/skaffold/schema/v2beta14/config.go @@ -19,8 +19,8 @@ package v2beta14 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta15/config.go b/pkg/skaffold/schema/v2beta15/config.go index 6bf123f8e97..0f81566f54b 100755 --- a/pkg/skaffold/schema/v2beta15/config.go +++ b/pkg/skaffold/schema/v2beta15/config.go @@ -19,8 +19,8 @@ package v2beta15 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta16/config.go b/pkg/skaffold/schema/v2beta16/config.go index 15b0f2542af..fdf8e8cbebf 100755 --- a/pkg/skaffold/schema/v2beta16/config.go +++ b/pkg/skaffold/schema/v2beta16/config.go @@ -19,8 +19,8 @@ package v2beta16 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta17/config.go b/pkg/skaffold/schema/v2beta17/config.go index 0c2b83161ab..ca89c435e8a 100755 --- a/pkg/skaffold/schema/v2beta17/config.go +++ b/pkg/skaffold/schema/v2beta17/config.go @@ -19,8 +19,8 @@ package v2beta17 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta18/config.go b/pkg/skaffold/schema/v2beta18/config.go index 1241103ea63..490913794d8 100755 --- a/pkg/skaffold/schema/v2beta18/config.go +++ b/pkg/skaffold/schema/v2beta18/config.go @@ -19,8 +19,8 @@ package v2beta18 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta19/config.go b/pkg/skaffold/schema/v2beta19/config.go index eaf38283b70..622bcf193f0 100755 --- a/pkg/skaffold/schema/v2beta19/config.go +++ b/pkg/skaffold/schema/v2beta19/config.go @@ -19,8 +19,8 @@ package v2beta19 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta20/config.go b/pkg/skaffold/schema/v2beta20/config.go index 97477375cab..182a2e15774 100755 --- a/pkg/skaffold/schema/v2beta20/config.go +++ b/pkg/skaffold/schema/v2beta20/config.go @@ -19,8 +19,8 @@ package v2beta20 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta21/config.go b/pkg/skaffold/schema/v2beta21/config.go index bafb61d5bd2..630cdcee63f 100755 --- a/pkg/skaffold/schema/v2beta21/config.go +++ b/pkg/skaffold/schema/v2beta21/config.go @@ -19,8 +19,8 @@ package v2beta21 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta22/config.go b/pkg/skaffold/schema/v2beta22/config.go index 8c78859e528..45e9f0c22a5 100755 --- a/pkg/skaffold/schema/v2beta22/config.go +++ b/pkg/skaffold/schema/v2beta22/config.go @@ -19,8 +19,8 @@ package v2beta22 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta23/config.go b/pkg/skaffold/schema/v2beta23/config.go index 91135ae74cc..f534ffddf84 100755 --- a/pkg/skaffold/schema/v2beta23/config.go +++ b/pkg/skaffold/schema/v2beta23/config.go @@ -19,8 +19,8 @@ package v2beta23 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta24/config.go b/pkg/skaffold/schema/v2beta24/config.go index e674bae204a..89acea398c6 100755 --- a/pkg/skaffold/schema/v2beta24/config.go +++ b/pkg/skaffold/schema/v2beta24/config.go @@ -19,8 +19,8 @@ package v2beta24 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta25/config.go b/pkg/skaffold/schema/v2beta25/config.go index 6b4b267dd3b..07fe10f68cc 100755 --- a/pkg/skaffold/schema/v2beta25/config.go +++ b/pkg/skaffold/schema/v2beta25/config.go @@ -19,8 +19,8 @@ package v2beta25 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta26/config.go b/pkg/skaffold/schema/v2beta26/config.go index 3d511473b53..9eb182048a7 100755 --- a/pkg/skaffold/schema/v2beta26/config.go +++ b/pkg/skaffold/schema/v2beta26/config.go @@ -19,8 +19,8 @@ package v2beta26 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta27/config.go b/pkg/skaffold/schema/v2beta27/config.go index 966635e291b..2253810f3e4 100755 --- a/pkg/skaffold/schema/v2beta27/config.go +++ b/pkg/skaffold/schema/v2beta27/config.go @@ -19,8 +19,8 @@ package v2beta27 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta28/config.go b/pkg/skaffold/schema/v2beta28/config.go index 8899b09d4f2..61b217b59e2 100644 --- a/pkg/skaffold/schema/v2beta28/config.go +++ b/pkg/skaffold/schema/v2beta28/config.go @@ -19,8 +19,8 @@ package v2beta28 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v2beta29/config.go b/pkg/skaffold/schema/v2beta29/config.go index fe0d66f54bb..61271a8a5f6 100644 --- a/pkg/skaffold/schema/v2beta29/config.go +++ b/pkg/skaffold/schema/v2beta29/config.go @@ -19,8 +19,8 @@ package v2beta29 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v3/config.go b/pkg/skaffold/schema/v3/config.go index 48f1d0f7fcd..cdc1c79958b 100755 --- a/pkg/skaffold/schema/v3/config.go +++ b/pkg/skaffold/schema/v3/config.go @@ -19,8 +19,8 @@ package v3 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v3alpha1/config.go b/pkg/skaffold/schema/v3alpha1/config.go index ff4e8681768..d566fc57b98 100755 --- a/pkg/skaffold/schema/v3alpha1/config.go +++ b/pkg/skaffold/schema/v3alpha1/config.go @@ -19,8 +19,8 @@ package v3alpha1 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta1/config.go b/pkg/skaffold/schema/v4beta1/config.go index 6bb555051ba..19a51b41c31 100755 --- a/pkg/skaffold/schema/v4beta1/config.go +++ b/pkg/skaffold/schema/v4beta1/config.go @@ -19,8 +19,8 @@ package v4beta1 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta10/config.go b/pkg/skaffold/schema/v4beta10/config.go index bfb8ad1eefa..4308ec157c3 100755 --- a/pkg/skaffold/schema/v4beta10/config.go +++ b/pkg/skaffold/schema/v4beta10/config.go @@ -19,8 +19,8 @@ package v4beta10 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta11/config.go b/pkg/skaffold/schema/v4beta11/config.go index 5ca5152178c..8bc8959e1e9 100755 --- a/pkg/skaffold/schema/v4beta11/config.go +++ b/pkg/skaffold/schema/v4beta11/config.go @@ -19,8 +19,8 @@ package v4beta11 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta2/config.go b/pkg/skaffold/schema/v4beta2/config.go index c86f6186457..57c4aa208db 100755 --- a/pkg/skaffold/schema/v4beta2/config.go +++ b/pkg/skaffold/schema/v4beta2/config.go @@ -19,8 +19,8 @@ package v4beta2 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta3/config.go b/pkg/skaffold/schema/v4beta3/config.go index e1ffdf5dad4..b9ced577c28 100755 --- a/pkg/skaffold/schema/v4beta3/config.go +++ b/pkg/skaffold/schema/v4beta3/config.go @@ -19,8 +19,8 @@ package v4beta3 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta4/config.go b/pkg/skaffold/schema/v4beta4/config.go index 84ab8a6f3fe..9692775f19f 100755 --- a/pkg/skaffold/schema/v4beta4/config.go +++ b/pkg/skaffold/schema/v4beta4/config.go @@ -19,8 +19,8 @@ package v4beta4 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta5/config.go b/pkg/skaffold/schema/v4beta5/config.go index fbc4570871b..8bd9d1e0936 100755 --- a/pkg/skaffold/schema/v4beta5/config.go +++ b/pkg/skaffold/schema/v4beta5/config.go @@ -19,8 +19,8 @@ package v4beta5 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta6/config.go b/pkg/skaffold/schema/v4beta6/config.go index 31a41e606f6..ce81a471df8 100755 --- a/pkg/skaffold/schema/v4beta6/config.go +++ b/pkg/skaffold/schema/v4beta6/config.go @@ -19,8 +19,8 @@ package v4beta6 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta7/config.go b/pkg/skaffold/schema/v4beta7/config.go index f5aeab49701..8b9d0d0da0b 100755 --- a/pkg/skaffold/schema/v4beta7/config.go +++ b/pkg/skaffold/schema/v4beta7/config.go @@ -19,8 +19,8 @@ package v4beta7 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta8/config.go b/pkg/skaffold/schema/v4beta8/config.go index a5848e492b3..79055ea81ac 100755 --- a/pkg/skaffold/schema/v4beta8/config.go +++ b/pkg/skaffold/schema/v4beta8/config.go @@ -19,8 +19,8 @@ package v4beta8 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/v4beta9/config.go b/pkg/skaffold/schema/v4beta9/config.go index 4fe6a91ea99..0b948571df0 100755 --- a/pkg/skaffold/schema/v4beta9/config.go +++ b/pkg/skaffold/schema/v4beta9/config.go @@ -19,8 +19,8 @@ package v4beta9 import ( "encoding/json" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/util" ) diff --git a/pkg/skaffold/schema/versions_test.go b/pkg/skaffold/schema/versions_test.go index c5839fa7809..5a08d0e6448 100644 --- a/pkg/skaffold/schema/versions_test.go +++ b/pkg/skaffold/schema/versions_test.go @@ -21,9 +21,9 @@ import ( "strings" "testing" + "gopkg.in/yaml.v3" v1 "k8s.io/api/core/v1" "k8s.io/client-go/tools/clientcmd/api" - "sigs.k8s.io/kustomize/kyaml/yaml" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/build/kaniko" "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/constants"