github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/fixture/versions.go (about) 1 package fixture 2 3 import ( 4 "encoding/json" 5 "fmt" 6 "strings" 7 8 "github.com/argoproj/gitops-engine/pkg/cache" 9 "github.com/argoproj/gitops-engine/pkg/utils/kube" 10 11 "github.com/argoproj/argo-cd/v2/util/argo" 12 "github.com/argoproj/argo-cd/v2/util/errors" 13 kubeutil "github.com/argoproj/argo-cd/v2/util/kube" 14 ) 15 16 type Versions struct { 17 ServerVersion Version 18 } 19 20 type Version struct { 21 Major, Minor string 22 } 23 24 func (v Version) String() string { 25 return v.Format("%s.%s") 26 } 27 28 func (v Version) Format(format string) string { 29 return fmt.Sprintf(format, v.Major, v.Minor) 30 } 31 32 func GetVersions() *Versions { 33 output := errors.FailOnErr(Run(".", "kubectl", "version", "-o", "json")).(string) 34 version := &Versions{} 35 errors.CheckError(json.Unmarshal([]byte(output), version)) 36 return version 37 } 38 39 func GetApiResources() string { 40 kubectl := kubeutil.NewKubectl() 41 resources := errors.FailOnErr(kubectl.GetAPIResources(KubeConfig, false, cache.NewNoopSettings())).([]kube.APIResourceInfo) 42 return strings.Join(argo.APIResourcesToStrings(resources, true), ",") 43 }