Skip to content

Commit

Permalink
Merge pull request #21 from hashicorp/biazmoreira/improvements-4
Browse files Browse the repository at this point in the history
Treat edge case cluster does not have http proxy enabled
  • Loading branch information
biazmoreira authored Dec 5, 2023
2 parents 0def575 + 97b4970 commit c2eefc2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,12 @@ func (c *HCPConnectCommand) getCluster(organizationID string, projectID string,
u := strings.Repeat("-", len(title))
c.Ui.Info(fmt.Sprintf("%s\n%s: %s\n", u, title, cluster.ID))

proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil
if cluster.DNSNames.Proxy != "" {
proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil
} else {
return "", errors.New("cluster does not have HTTP Proxy enabled")
}
}
}

Expand Down Expand Up @@ -319,8 +323,14 @@ func (c *HCPConnectCommand) listClusters(organizationID string, projectID string
if !ok {
return "", errors.New(fmt.Sprintf("invalid cluster: %s", userInput))
}
proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil

if cluster.DNSNames.Proxy != "" {
proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil
} else {
return "", errors.New("cluster does not have HTTP Proxy enabled")
}

default:
cluster := clustersResp.GetPayload().Clusters[0]
if *cluster.State != hcpvsm.HashicorpCloudVault20201125ClusterStateRUNNING {
Expand All @@ -329,7 +339,11 @@ func (c *HCPConnectCommand) listClusters(organizationID string, projectID string
projectID = cluster.ResourceID
c.Ui.Info(fmt.Sprintf("HCP Vault Cluster: %s", cluster.ID))

proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil
if cluster.DNSNames.Proxy != "" {
proxyAddr = "https://" + cluster.DNSNames.Proxy
return proxyAddr, nil
} else {
return "", errors.New("cluster does not have HTTP Proxy enabled")
}
}
}

0 comments on commit c2eefc2

Please sign in to comment.