Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat edge case cluster does not have http proxy enabled #21

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}
}