diff --git a/go.mod b/go.mod index 04a7647fec..0ac3bf0f6d 100644 --- a/go.mod +++ b/go.mod @@ -35,7 +35,6 @@ require ( google.golang.org/grpc v1.42.0 google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 - istio.io/client-go v1.13.3 k8s.io/api v0.23.3 k8s.io/apiextensions-apiserver v0.23.1 k8s.io/apimachinery v0.23.3 @@ -163,8 +162,6 @@ require ( gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect - istio.io/api v0.0.0-20220413180505-1574de06b7bd // indirect - istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e // indirect k8s.io/cluster-bootstrap v0.0.0 // indirect k8s.io/component-helpers v0.23.1 // indirect k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect diff --git a/go.sum b/go.sum index 2142d58b22..f45bf974f5 100644 --- a/go.sum +++ b/go.sum @@ -1480,12 +1480,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -istio.io/api v0.0.0-20220413180505-1574de06b7bd h1:2i0e183JpTuZkZzqgXlv3mosCBxv7Bt9uUB4cNe7iSM= -istio.io/api v0.0.0-20220413180505-1574de06b7bd/go.mod h1:8ZZgyVgYrHhsFQarEgTfPnMGpdgTDZbxSjYhdwTUuAQ= -istio.io/client-go v1.13.3 h1:xbEgTX4NRlvVRI/JsCmMI0ATvCc9P85HkQ20SphEGZ4= -istio.io/client-go v1.13.3/go.mod h1:DeT/l4yO+bwyv0ZgavSTj7BfkA2cTckHD0jtluwtXhE= -istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e h1:z2WI3y55w0K3c6hmarcp5EcOiP4vVpTBXA8nYstP+cE= -istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e/go.mod h1:vJDAniIqryf/z///fgZqVPKJ7N2lBk7Gg8DCTB7oCfU= k8s.io/api v0.23.1 h1:ncu/qfBfUoClqwkTGbeRqqOqBCRoUAflMuOaOD7J0c8= k8s.io/api v0.23.1/go.mod h1:WfXnOnwSqNtG62Y1CdjoMxh7r7u9QXGCkA1u0na2jgo= k8s.io/apiextensions-apiserver v0.23.1 h1:xxE0q1vLOVZiWORu1KwNRQFsGWtImueOrqSl13sS5EU= diff --git a/pkg/kubectl-argo-rollouts/cmd/lint/lint.go b/pkg/kubectl-argo-rollouts/cmd/lint/lint.go index de50a3f599..2969b53034 100644 --- a/pkg/kubectl-argo-rollouts/cmd/lint/lint.go +++ b/pkg/kubectl-argo-rollouts/cmd/lint/lint.go @@ -14,14 +14,10 @@ import ( "github.com/ghodss/yaml" "github.com/spf13/cobra" goyaml "gopkg.in/yaml.v2" - istioNetworkingv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3" - istioNetworkingv1beta1 "istio.io/client-go/pkg/apis/networking/v1beta1" v1 "k8s.io/api/core/v1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" networkingv1 "k8s.io/api/networking/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/validation/field" ) @@ -113,7 +109,7 @@ func (l *LintOptions) lintResource(path string) error { } fileRollouts = append(fileRollouts, ro) } - err = buildAllReferencedResources(gvk, valueBytes, &refResource) + err = buildAllReferencedResources(un, &refResource) if err != nil { return err } @@ -144,7 +140,14 @@ func (l *LintOptions) lintResource(path string) error { // buildAllReferencedResources This builds a ReferencedResources object that has all the external resources for every // rollout resource in the manifest. We will need to later match each referenced resource to its own rollout resource // before passing the rollout object and its managed reference on to validation. -func buildAllReferencedResources(gvk schema.GroupVersionKind, valueBytes []byte, refResource *validation.ReferencedResources) error { +func buildAllReferencedResources(un unstructured.Unstructured, refResource *validation.ReferencedResources) error { + + valueBytes, err := un.MarshalJSON() + if err != nil { + return err + } + + gvk := un.GroupVersionKind() switch { case gvk.Group == v1.GroupName && gvk.Kind == "Service": var svc v1.Service @@ -156,35 +159,8 @@ func buildAllReferencedResources(gvk schema.GroupVersionKind, valueBytes []byte, Service: &svc, }) - case gvk.Group == istioNetworkingv1beta1.GroupName && gvk.Kind == "VirtualService": - var virtualServicev1beta1 istioNetworkingv1beta1.VirtualService - var virtualServicev1alpha3 istioNetworkingv1alpha3.VirtualService - if gvk.Version == "v1alpha3" { - err := unmarshal(valueBytes, &virtualServicev1alpha3) - if err != nil { - return err - } - - vsvcUn, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&virtualServicev1alpha3) - if err != nil { - return err - } - refResource.VirtualServices = append(refResource.VirtualServices, unstructured.Unstructured{ - Object: vsvcUn, - }) - } else if gvk.Version == "v1beta1" { - err := unmarshal(valueBytes, &virtualServicev1beta1) - if err != nil { - return err - } - vsvcUn, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&virtualServicev1beta1) - if err != nil { - return err - } - refResource.VirtualServices = append(refResource.VirtualServices, unstructured.Unstructured{ - Object: vsvcUn, - }) - } + case gvk.Group == "networking.istio.io" && gvk.Kind == "VirtualService": + refResource.VirtualServices = append(refResource.VirtualServices, un) case (gvk.Group == networkingv1.GroupName || gvk.Group == extensionsv1beta1.GroupName) && gvk.Kind == "Ingress": var ing networkingv1.Ingress