Skip to content

Commit

Permalink
use k8s yaml tool instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Nov 8, 2023
1 parent f54e786 commit 43e3ce2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
16 changes: 13 additions & 3 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,8 +57,7 @@ var validateCmd = &cobra.Command{
}

if printfile {
_ = yaml.NewEncoder(os.Stdout).Encode(ra)
fmt.Println("")
printRA(ra)
}

err = radixvalidators.IsRadixApplicationValid(ra)
Expand All @@ -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")
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 43e3ce2

Please sign in to comment.