github.com/argoproj/argo-cd@v1.8.7/test/e2e/fixture/versions.go (about)

     1  package fixture
     2  
     3  import (
     4  	"encoding/json"
     5  	"fmt"
     6  	"strings"
     7  
     8  	"github.com/argoproj/argo-cd/util/errors"
     9  )
    10  
    11  type Versions struct {
    12  	ServerVersion Version
    13  }
    14  
    15  type Version struct {
    16  	Major, Minor string
    17  }
    18  
    19  func (v Version) String() string {
    20  	return v.Format("%s.%s")
    21  }
    22  
    23  func (v Version) Format(format string) string {
    24  	return fmt.Sprintf(format, v.Major, v.Minor)
    25  }
    26  
    27  func GetVersions() *Versions {
    28  	output := errors.FailOnErr(Run(".", "kubectl", "version", "-o", "json")).(string)
    29  	version := &Versions{}
    30  	errors.CheckError(json.Unmarshal([]byte(output), version))
    31  	return version
    32  }
    33  
    34  func GetApiVersions() string {
    35  	output := errors.FailOnErr(Run(".", "kubectl", "api-versions")).(string)
    36  	res := strings.Replace(output, "\n", ",", -1)
    37  	return res
    38  }