diff --git a/cmd/validate.go b/cmd/validate.go index 9383ed6..6ae8a55 100644 --- a/cmd/validate.go +++ b/cmd/validate.go @@ -18,11 +18,12 @@ import ( "fmt" "os" + radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" "github.com/equinor/radix-operator/pkg/apis/radixvalidators" "github.com/equinor/radix-operator/pkg/apis/utils" "github.com/pkg/errors" "github.com/spf13/cobra" - "gopkg.in/yaml.v3" + "sigs.k8s.io/yaml" ) // logoutCmd represents the logout command @@ -56,8 +57,7 @@ var validateCmd = &cobra.Command{ } if printfile { - _ = yaml.NewEncoder(os.Stdout).Encode(ra) - fmt.Println("") + printRA(ra) } err = radixvalidators.IsRadixApplicationValid(ra) @@ -72,6 +72,16 @@ var validateCmd = &cobra.Command{ }, } +func printRA(ra *radixv1.RadixApplication) { + b, err := yaml.Marshal(ra) + if err != nil { + fmt.Println(err) + return + } + + fmt.Printf("%s\n", b) +} + func init() { rootCmd.AddCommand(validateCmd) validateCmd.Flags().StringP("config-file", "f", "radixconfig.yaml", "Name of the radixconfig file. Defaults to radixconfig.yaml in current directory") diff --git a/go.mod b/go.mod index 39d8945..35aed85 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.7.0 k8s.io/utils v0.0.0-20230505201702-9f6742963106 + sigs.k8s.io/yaml v1.3.0 ) require ( @@ -27,7 +28,6 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.10.2 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/analysis v0.21.4 // indirect @@ -91,5 +91,4 @@ require ( sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/secrets-store-csi-driver v1.3.3 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect ) diff --git a/go.sum b/go.sum index 9b4b860..a249df6 100644 --- a/go.sum +++ b/go.sum @@ -39,12 +39,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/equinor/radix-common v1.5.0 h1:z5hQHlKG2x16/NnV4b9ynf9n5ZageYUewE4MANdA96Y= github.com/equinor/radix-common v1.5.0/go.mod h1:UZ69U56VFtTxABi5JjGdaqn9Df5ilfTTqzUQ0riofVM= -github.com/equinor/radix-operator v1.43.0 h1:25vXiqy0BZrTu1VjA/kFgP7IGQ/UoFAtx0QCq0Irm8E= -github.com/equinor/radix-operator v1.43.0/go.mod h1:fa1yXgnhluKtqlBP+k/VldbkpFRpkK5eBGfGhuilqNc= github.com/equinor/radix-operator v1.44.1 h1:ogaVIERfEbeD5QexsXXZSN6k4v4hgbtFDFHoLgBkNjA= github.com/equinor/radix-operator v1.44.1/go.mod h1:9YBEz5p/s2YCL8FGzjvRUXgPjtrBojnjw/tAXQNzwx0= -github.com/equinor/radix-operator v1.99.1000-0.20231102102524-b631c3a617bb h1:DYIK/6f7McCNF2tMAhsFfA/ml841NEItjzVCV7o1lug= -github.com/equinor/radix-operator v1.99.1000-0.20231102102524-b631c3a617bb/go.mod h1:j/Lb9bcof4L+KjtHVv5GD6MqYVsxHSGsliIP6C2F8YU= github.com/evanphx/json-patch v5.6.0+incompatible h1:jBYDEEiFBPxA0v50tFdvOzQQTCvpL6mnFh5mB2/l16U= github.com/evanphx/json-patch v5.6.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=