Skip to content

Commit

Permalink
Fix issue with lowercasing of HCP resources (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
VioletHynes authored Jul 4, 2024
1 parent 2312b38 commit a5c058a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
9 changes: 3 additions & 6 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ func (c *HCPConnectCommand) getOrganization() (organizationID string, err error)
for _, org := range organizationsResp.GetPayload().Organizations {
if *org.State == hcprmm.HashicorpCloudResourcemanagerOrganizationOrganizationStateACTIVE {
c.Ui.Info(fmt.Sprintf("Organization name: %s", org.Name))
name := strings.ToLower(org.Name)
orgs[name] = org
orgs[org.Name] = org
}
}
userInput, err := c.Ui.Ask(fmt.Sprintf("\nChoose a organization: "))
Expand Down Expand Up @@ -288,8 +287,7 @@ func (c *HCPConnectCommand) getProject(organizationID string) (projectID string,
for _, proj := range projectResp.GetPayload().Projects {
if *proj.State == hcprmm.HashicorpCloudResourcemanagerProjectProjectStateACTIVE {
c.Ui.Info(fmt.Sprintf("Project name: %s", proj.Name))
name := strings.ToLower(proj.Name)
projs[name] = proj
projs[proj.Name] = proj
}
}
userInput, err := c.Ui.Ask(fmt.Sprintf("\nChoose a project: "))
Expand Down Expand Up @@ -366,8 +364,7 @@ func (c *HCPConnectCommand) listClusters(organizationID string, projectID string
for _, cluster := range clustersResp.GetPayload().Clusters {
if *cluster.State == hcpvsm.HashicorpCloudVault20201125ClusterStateRUNNING {
c.Ui.Info(fmt.Sprintf("Cluster identification: %s", cluster.ID))
id := strings.ToLower(cluster.ID)
clusters[id] = cluster
clusters[cluster.ID] = cluster
}
}
userInput, err := c.Ui.Ask("\nChoose a cluster:")
Expand Down
14 changes: 7 additions & 7 deletions connect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func Test_HCPConnectCommand(t *testing.T) {
Projects: []*models.HashicorpCloudResourcemanagerProject{
{
ID: uuid.New().String(),
Name: "mock-project-1",
Name: "Mock-project-1",
State: models.NewHashicorpCloudResourcemanagerProjectProjectState(
models.HashicorpCloudResourcemanagerProjectProjectStateACTIVE,
),
Expand Down Expand Up @@ -260,7 +260,7 @@ func Test_getOrganization(t *testing.T) {
// Test multiple organizations
// UI interaction required
"multiple organizations": {
userInputOrganizationName: "mock-organization-2\n",
userInputOrganizationName: "MOCK-organization-2\n",
expectedOrganizationID: organizationIDTwo,
organizationServiceListResponse: &hcprmo.OrganizationServiceListOK{
Payload: &models.HashicorpCloudResourcemanagerOrganizationListResponse{
Expand All @@ -272,7 +272,7 @@ func Test_getOrganization(t *testing.T) {
},
{
ID: organizationIDTwo,
Name: "mock-organization-2",
Name: "MOCK-organization-2",
State: models.NewHashicorpCloudResourcemanagerOrganizationOrganizationState(models.HashicorpCloudResourcemanagerOrganizationOrganizationStateACTIVE),
},
{
Expand Down Expand Up @@ -382,7 +382,7 @@ func Test_getProject(t *testing.T) {
// Test multiple projects
// UI interaction required
"multiple projects": {
userInputProjectName: "mock-project-2\n",
userInputProjectName: "MOCK_-project-2\n",
expectedProjectID: projectIDTwo,
projectServiceListResponse: &hcprmp.ProjectServiceListOK{
Payload: &models.HashicorpCloudResourcemanagerProjectListResponse{
Expand All @@ -394,7 +394,7 @@ func Test_getProject(t *testing.T) {
},
{
ID: projectIDTwo,
Name: "mock-project-2",
Name: "MOCK_-project-2",
State: models.NewHashicorpCloudResourcemanagerProjectProjectState(models.HashicorpCloudResourcemanagerProjectProjectStateACTIVE),
},
{
Expand Down Expand Up @@ -529,7 +529,7 @@ func Test_getCluster(t *testing.T) {
// UI interaction required
"multiple clusters": {
expectedProxyAddr: "https://hcp-proxy-cluster-2.addr:8200",
userInputCluster: "cluster-2\n",
userInputCluster: "CLUSTER-2\n",
listClustersServiceListResponse: &hcpvs.ListOK{
Payload: &hcpvsm.HashicorpCloudVault20201125ListResponse{
Clusters: []*hcpvsm.HashicorpCloudVault20201125Cluster{
Expand All @@ -544,7 +544,7 @@ func Test_getCluster(t *testing.T) {
},
},
{
ID: "cluster-2",
ID: "CLUSTER-2",
DNSNames: &hcpvsm.HashicorpCloudVault20201125ClusterDNSNames{Proxy: "hcp-proxy-cluster-2.addr:8200"},
State: hcpvsm.NewHashicorpCloudVault20201125ClusterState(hcpvsm.HashicorpCloudVault20201125ClusterStateRUNNING),
Config: &hcpvsm.HashicorpCloudVault20201125ClusterConfig{
Expand Down

0 comments on commit a5c058a

Please sign in to comment.