diff --git a/internal/daemon/controller/controller.go b/internal/daemon/controller/controller.go index 90d147d78..eee430e69 100644 --- a/internal/daemon/controller/controller.go +++ b/internal/daemon/controller/controller.go @@ -71,8 +71,8 @@ type downstreamWorkersTicker interface { // Controller.downstreamWorkers field which is far better than allowing any (empty // interface) type downstreamers interface { - // Root returns the root of the downstreamers' graph - Root() string + // RootId returns the root ID of the downstreamers' graph + RootId() string } var ( diff --git a/internal/daemon/worker/worker.go b/internal/daemon/worker/worker.go index d4229d360..8e4800462 100644 --- a/internal/daemon/worker/worker.go +++ b/internal/daemon/worker/worker.go @@ -60,8 +60,8 @@ type downstreamRouter interface { // Worker.downstreamWorkers field which is far better than allowing any (empty // interface) type downstreamers interface { - // Root returns the root of the downstreamers' graph - Root() string + // RootId returns the root ID of the downstreamers' graph + RootId() string } // downstreamRouterFactory provides a simple factory which a Worker can use to diff --git a/internal/server/options.go b/internal/server/options.go index cd9ac6daf..9fc51e142 100644 --- a/internal/server/options.go +++ b/internal/server/options.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/hashicorp/boundary/version" "github.com/hashicorp/nodeenrollment/types" ) @@ -39,12 +40,13 @@ type options struct { withTestPkiWorkerAuthorized bool withTestPkiWorkerKeyId *string withWorkerType WorkerType - withRoot string + withRoot RootInfo withStopAfter uint WithCreateControllerLedActivationToken bool withReleaseVersion string withOperationalState string withActiveWorkers bool + withFeature version.Feature } func getDefaultOptions() options { @@ -180,10 +182,10 @@ func WithWorkerType(with WorkerType) Option { } } -// WithRoot provides an optional root worker id. -func WithRoot(workerId string) Option { +// WithRoot provides an optional root node +func WithRoot(root RootInfo) Option { return func(o *options) { - o.withRoot = workerId + o.withRoot = root } } @@ -221,3 +223,10 @@ func WithActiveWorkers(withActive bool) Option { o.withActiveWorkers = withActive } } + +// WithFeature provides an option to specify a filter +func WithFeature(feature version.Feature) Option { + return func(o *options) { + o.withFeature = feature + } +} diff --git a/internal/server/options_test.go b/internal/server/options_test.go index 8c4a3703d..6b9ffec03 100644 --- a/internal/server/options_test.go +++ b/internal/server/options_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "github.com/hashicorp/boundary/version" "github.com/stretchr/testify/assert" ) @@ -167,8 +168,14 @@ func Test_GetOpts(t *testing.T) { t.Run("WithRoot", func(t *testing.T) { opts := getDefaultOptions() assert.Empty(t, opts.withRoot) - opts = GetOpts(WithRoot("a")) - assert.Equal(t, "a", opts.withRoot) + opts = GetOpts(WithRoot(RootInfo{ + RootId: "a", + RootVer: "0.1.0", + })) + assert.Equal(t, RootInfo{ + RootId: "a", + RootVer: "0.1.0", + }, opts.withRoot) }) t.Run("WithStopAfter", func(t *testing.T) { opts := getDefaultOptions() @@ -202,4 +209,12 @@ func Test_GetOpts(t *testing.T) { opts = GetOpts(WithActiveWorkers(true)) assert.Equal(t, true, opts.withActiveWorkers) }) + t.Run("WithFeature", func(t *testing.T) { + opts := GetOpts(WithFeature(version.MultiHopSessionFeature)) + testOpts := getDefaultOptions() + testOpts.withFeature = version.MultiHopSessionFeature + opts.withNewIdFunc = nil + testOpts.withNewIdFunc = nil + assert.Equal(t, opts, testOpts) + }) } diff --git a/internal/server/root_info.go b/internal/server/root_info.go new file mode 100644 index 000000000..8eb9398b9 --- /dev/null +++ b/internal/server/root_info.go @@ -0,0 +1,8 @@ +package server + +type RootInfo struct { + // the ID for this node. For workers, this is workerId + RootId string + // the version of boundary the root is running + RootVer string +}