feat(worker): allow hcp cluster id to be sourced from env var (#3709)

* feat(worker): allow hcp cluster id to be sourced from env var
This commit is contained in:
Irena Rindos authored and GitHub committed 2023-09-12 13:20:49 -04:00
1 parent 6f10a0ac87
commit 7bd2d2c913
4 files changed
+22 -5

No files matched your search

+6 -2
View File
@@ -363,11 +363,15 @@ func (c *Command) Run(args []string) int {
c.UI.Error(fmt.Errorf("Initial upstreams and HCPB cluster ID are mutually exclusive fields").Error())
return base.CommandUserError
}
clusterId := c.Config.HcpbClusterId
clusterId, err := parseutil.ParsePath(c.Config.HcpbClusterId)
if err != nil && !errors.Is(err, parseutil.ErrNotAUrl) {
c.UI.Error(fmt.Errorf("Failed to parse HCP Boundary cluster ID %q: %w", clusterId, err).Error())
return base.CommandUserError
}
if strings.HasPrefix(clusterId, "int-") {
clusterId = strings.TrimPrefix(clusterId, "int-")
}
_, err := uuid.ParseUUID(clusterId)
_, err = uuid.ParseUUID(clusterId)
if err != nil {
c.UI.Error(fmt.Errorf("Invalid HCP Boundary cluster ID %q: %w", clusterId, err).Error())
return base.CommandUserError