mirror of
https://github.com/hanzokms/cli.git
synced 2026-10-30 20:30:00 +00:00
Rename all INFISICAL_ constants + env-var keys to KMS_ (no backward compat), and rebrand user-facing strings to Hanzo KMS. Preserves the one external contract: the forked keyring still reads INFISICAL_VAULT_FILE_PASSPHRASE literally. Workspace config is already .kms.json (not infisical.json); global config ~/.kms/kms-config.json.
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package util
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hanzokms/cli/packages/api"
|
|
"github.com/hanzokms/cli/packages/config"
|
|
"github.com/hanzokms/cli/packages/models"
|
|
)
|
|
|
|
func GetOrganizationsNameList(organizationResponse api.GetOrganizationsResponse) []string {
|
|
organizations := organizationResponse.Organizations
|
|
|
|
if len(organizations) == 0 {
|
|
message := fmt.Sprintf("You don't have any organization created in Hanzo KMS. You must first create a organization at %s", config.KMS_URL)
|
|
PrintErrorMessageAndExit(message)
|
|
}
|
|
|
|
var organizationNames []string
|
|
for _, workspace := range organizations {
|
|
organizationNames = append(organizationNames, workspace.Name)
|
|
}
|
|
|
|
return organizationNames
|
|
}
|
|
|
|
func GetWorkspacesInOrganization(workspaceResponse api.GetWorkSpacesResponse, orgId string) ([]models.Workspace, []string) {
|
|
workspaces := workspaceResponse.Workspaces
|
|
|
|
var filteredWorkspaces []models.Workspace
|
|
var workspaceNames []string
|
|
|
|
for _, workspace := range workspaces {
|
|
if workspace.OrganizationId == orgId {
|
|
filteredWorkspaces = append(filteredWorkspaces, workspace)
|
|
workspaceNames = append(workspaceNames, workspace.Name)
|
|
}
|
|
}
|
|
|
|
if len(filteredWorkspaces) == 0 {
|
|
message := fmt.Sprintf("You don't have any projects created in Hanzo KMS organization. You must first create a project at %s", config.KMS_URL)
|
|
PrintErrorMessageAndExit(message)
|
|
}
|
|
|
|
return filteredWorkspaces, workspaceNames
|
|
}
|