Skip to content

Commit

Permalink
Fix ACP version output for standard Trident installs
Browse files Browse the repository at this point in the history
  • Loading branch information
torirevilla authored Oct 12, 2023
1 parent f68beb8 commit 3da6849
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
6 changes: 3 additions & 3 deletions cli/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ type Version struct {
}

type VersionResponse struct {
Server Version `json:"server"`
Client Version `json:"client"`
ACPServer Version `json:"acpServer,omitempty"`
Server *Version `json:"server"`
Client *Version `json:"client"`
ACPServer *Version `json:"acpServer,omitempty"`
}

type ClientVersionResponse struct {
Expand Down
52 changes: 30 additions & 22 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ func getVersionFromTunnel() (rest.GetVersionResponse, error) {
}

version := rest.GetVersionResponse{
Version: tunnelVersionResponse.Server.Version,
GoVersion: tunnelVersionResponse.Server.GoVersion,
ACPVersion: tunnelVersionResponse.ACPServer.Version,
Version: tunnelVersionResponse.Server.Version,
GoVersion: tunnelVersionResponse.Server.GoVersion,
}

if tunnelVersionResponse.ACPServer != nil {
version.ACPVersion = tunnelVersionResponse.ACPServer.Version
}

return version, nil
}

Expand All @@ -154,28 +158,32 @@ func getClientVersion() *api.ClientVersionResponse {

// addClientVersion accepts the server version and fills in the client version
func addClientVersion(serverVersion, acpServerVersion *versionutils.Version) *api.VersionResponse {
versions := api.VersionResponse{}

versions.Server.Version = serverVersion.String()
versions.Server.MajorVersion = serverVersion.MajorVersion()
versions.Server.MinorVersion = serverVersion.MinorVersion()
versions.Server.PatchVersion = serverVersion.PatchVersion()
versions.Server.PreRelease = serverVersion.PreRelease()
versions.Server.BuildMetadata = serverVersion.BuildMetadata()
versions.Server.APIVersion = config.OrchestratorAPIVersion
versions := api.VersionResponse{
Server: &api.Version{
Version: serverVersion.String(),
MajorVersion: serverVersion.MajorVersion(),
MinorVersion: serverVersion.MinorVersion(),
PatchVersion: serverVersion.PatchVersion(),
PreRelease: serverVersion.PreRelease(),
BuildMetadata: serverVersion.BuildMetadata(),
APIVersion: config.OrchestratorAPIVersion,
},
Client: &getClientVersion().Client,
}

ACPServer := &api.Version{}
if acpServerVersion != nil {
versions.ACPServer.Version = acpServerVersion.String()
versions.ACPServer.MajorVersion = acpServerVersion.MajorVersion()
versions.ACPServer.MinorVersion = acpServerVersion.MinorVersion()
versions.ACPServer.PatchVersion = acpServerVersion.PatchVersion()
versions.ACPServer.PreRelease = acpServerVersion.PreRelease()
versions.ACPServer.BuildMetadata = acpServerVersion.BuildMetadata()
versions.ACPServer.APIVersion = config.OrchestratorAPIVersion
ACPServer.Version = acpServerVersion.String()
ACPServer.MajorVersion = acpServerVersion.MajorVersion()
ACPServer.MinorVersion = acpServerVersion.MinorVersion()
ACPServer.PatchVersion = acpServerVersion.PatchVersion()
ACPServer.PreRelease = acpServerVersion.PreRelease()
ACPServer.BuildMetadata = acpServerVersion.BuildMetadata()
ACPServer.APIVersion = config.OrchestratorAPIVersion

versions.ACPServer = ACPServer
}

versions.Client = getClientVersion().Client

return &versions
}

Expand Down Expand Up @@ -218,7 +226,7 @@ func writeVersionTable(version *api.ClientVersionResponse) {

func writeVersionsTable(versions *api.VersionResponse) {
table := tablewriter.NewWriter(os.Stdout)
if versions.ACPServer.Version != "" {
if versions.ACPServer != nil {
table.SetHeader([]string{"Server Version", "Client Version", "ACP Version"})
table.Append([]string{
versions.Server.Version,
Expand Down
2 changes: 1 addition & 1 deletion operator/controllers/orchestrator/apis/netapp/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type TridentOrchestratorStatus struct {
Version string `json:"version"`
Namespace string `json:"namespace"`
CurrentInstallationParams TridentOrchestratorSpecValues `json:"currentInstallationParams"`
ACPVersion string `json:"acpVersion"`
ACPVersion string `json:"acpVersion,omitempty"`
}

type TridentOrchestratorSpecValues struct {
Expand Down

0 comments on commit 3da6849

Please sign in to comment.