Added populateOrgName param in /v1/workspace api which adds orgName and displayName in result

Updated the CLI to use this new paramter to display organization name with project name with support for backward compatibility keeping original behaviour for older apis
This commit is contained in:
Rhythm Bhiwani
2024-03-03 12:12:25 +05:30
parent 2192985291
commit 756c1e5098
8 changed files with 69 additions and 37 deletions

27
cli/packages/util/init.go Normal file
View File

@@ -0,0 +1,27 @@
package util
import (
"fmt"
"github.com/Infisical/infisical-merge/packages/api"
)
func GetWorkspacesNameList(workspaceResponse api.GetWorkSpacesResponse) ([]string, error) {
workspaces := workspaceResponse.Workspaces
if len(workspaces) == 0 {
message := fmt.Sprintf("You don't have any projects created in Infisical. You must first create a project at %s", INFISICAL_TOKEN_NAME)
PrintErrorMessageAndExit(message)
}
var workspaceNames []string
for _, workspace := range workspaces {
if workspace.DisplayName != nil {
workspaceNames = append(workspaceNames, *workspace.DisplayName)
} else {
workspaceNames = append(workspaceNames, workspace.Name)
}
}
return workspaceNames, nil
}