diff --git a/mesheryctl/internal/cli/root/cfg/cfg.go b/mesheryctl/internal/cli/root/cfg/cfg.go deleted file mode 100644 index da99c4058f4..00000000000 --- a/mesheryctl/internal/cli/root/cfg/cfg.go +++ /dev/null @@ -1,90 +0,0 @@ -package cfg - -import ( - "github.com/spf13/viper" -) - -// PerfCfg stores the perf subcommand configurations -type PerfCfg struct { - baseURL string - // AuthTokenURI stores the URI for the token endpoint - AuthTokenURI string `json:"AuthtokenURI"` - // LoadTestSmpURI stores the URI for the load test SMP endpoint - LoadTestSmpURI string `json:"loadTestSmpURI"` - LoadTestURI string `json:"loadTestURI"` -} - -// Version unmarshals the json response from the server's version api -type Version struct { - Build string `json:"build,omitempty"` - CommitSHA string `json:"commitsha,omitempty"` - ReleaseChannel string `json:"release_channel,omitempty"` -} - -// MesheryCtl stores the configurations used by mesheryctl CLI -// Default config: -// baseMesheryURL: "http://localhost:9081/api", -// perf: -// authTokenURI: "/gettoken", -// loadTestSmpURI: "/perf/load-test-smp", -// loadTestURI: "/perf/load-test", -type MesheryCtl struct { - // BaseMesheryURL is the base URL of the meshery server - BaseMesheryURL string `json:"baseMesheryURL"` - // Perf stores the perf subcommand configurations - Perf *PerfCfg `json:"perf"` - - CtlVersion *Version `json:"ctl_version"` -} - -// GetMesheryCtl returns a reference to the mesheryctl configuration object. -func GetMesheryCtl(v *viper.Viper) (*MesheryCtl, error) { - c := &MesheryCtl{} - // Load the config data into the object - err := v.Unmarshal(&c) - if err != nil { - return nil, err - } - return c, err -} - -// GetBaseMesheryURL returns the base meshery server URL -func (mc *MesheryCtl) GetBaseMesheryURL() string { - return mc.BaseMesheryURL -} - -// GetPerf returns a reference to the perf configuration object -func (mc *MesheryCtl) GetPerf() *PerfCfg { - mc.Perf.baseURL = mc.BaseMesheryURL - return mc.Perf -} - -// GetAuthTokenURL returns a fully qualified URL to the token endpoint -func (pc *PerfCfg) GetAuthTokenURL() string { - return pc.baseURL + pc.AuthTokenURI -} - -// GetLoadTestSmpURL returns a fully qualified URL to the Load Test SMP endpoint -func (pc *PerfCfg) GetLoadTestSmpURL() string { - return pc.baseURL + pc.LoadTestSmpURI -} - -// GetLoadTestURL returns a fully qualified URL to the Load Test endpoint -func (pc *PerfCfg) GetLoadTestURL() string { - return pc.baseURL + pc.LoadTestURI -} - -// GetVersion returns the version details of this binary -func (mc *MesheryCtl) GetVersion() *Version { - return mc.CtlVersion -} - -// GetBuild returns the build number for the binary -func (v *Version) GetBuild() string { - return v.Build -} - -// GetCommitSHA returns the commit sha for the binary -func (v *Version) GetCommitSHA() string { - return v.CommitSHA -} diff --git a/mesheryctl/internal/cli/root/version.go b/mesheryctl/internal/cli/root/version.go index 94b7b609278..0ec5193d58b 100644 --- a/mesheryctl/internal/cli/root/version.go +++ b/mesheryctl/internal/cli/root/version.go @@ -21,7 +21,6 @@ import ( "net/http" "github.com/layer5io/meshery/handlers" - "github.com/layer5io/meshery/mesheryctl/internal/cli/root/cfg" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/config" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -54,7 +53,7 @@ var versionCmd = &cobra.Command{ build := version commitsha := commitsha - version := cfg.Version{ + version := config.Version{ Build: "unavailable", CommitSHA: "unavailable", ReleaseChannel: "unavailable",