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

@@ -34,6 +34,7 @@ import (
"github.com/hashicorp/boundary/internal/util"
"github.com/hashicorp/boundary/version"
"github.com/hashicorp/go-secure-stdlib/base62"
"github.com/hashicorp/go-secure-stdlib/parseutil"
"github.com/hashicorp/nodeenrollment"
"github.com/hashicorp/nodeenrollment/multihop"
"github.com/hashicorp/nodeenrollment/protocol"
@@ -72,7 +73,11 @@ func (w *Worker) StartControllerConnections() error {
if len(initialAddrs) == 0 {
if w.conf.RawConfig.HcpbClusterId != "" && HandleHcpbClusterId != nil {
clusterAddress := HandleHcpbClusterId(w.conf.RawConfig.HcpbClusterId)
clusterId, err := parseutil.ParsePath(w.conf.RawConfig.HcpbClusterId)
if err != nil && !errors.Is(err, parseutil.ErrNotAUrl) {
return fmt.Errorf("failed to parse HCP Boundary cluster ID: %q: %w", clusterId, err)
}
clusterAddress := HandleHcpbClusterId(clusterId)
initialAddrs = append(initialAddrs, clusterAddress)
event.WriteSysEvent(w.baseContext, op, fmt.Sprintf("Setting HCP Boundary cluster address %s as upstream address", clusterAddress))
} else {