Propagate plugin execution dir to CreatePlugin (#2183)
* fix: Propagate plugin options to CreatePlugin Plugin options were previously only applied to the BuildPluginMap call, resulting in the plugin execution_dir variable being ineffective. Also add a test to verify functionality * fix: Support plugin execution_dir for all plugins Previously, only external host plugins would respect the plugin execution dir. Now, all uses of the embedded plugins respect the configuration.
This commit is contained in:
1 parent
5ef9496e0a
commit
d06ac0d370
5 files changed
+91
-1
No files matched your search
@@ -2,12 +2,17 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/hashicorp/boundary/internal/cmd/base"
|
||||
"github.com/hashicorp/boundary/internal/cmd/config"
|
||||
"github.com/hashicorp/boundary/internal/iam"
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
host_plugin_assets "github.com/hashicorp/boundary/plugins/host"
|
||||
"github.com/hashicorp/go-secure-stdlib/listenerutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -223,3 +228,39 @@ func TestControllerNewListenerConfig(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestController_NewPluginsConfig(t *testing.T) {
|
||||
require := require.New(t)
|
||||
testCtx := context.Background()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
tc := &TestController{
|
||||
t: t,
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
opts: nil,
|
||||
}
|
||||
|
||||
initialConfig, err := config.DevController()
|
||||
require.NoError(err)
|
||||
tmpDir := t.TempDir()
|
||||
initialConfig.Plugins.ExecutionDir = tmpDir
|
||||
conf := TestControllerConfig(t, ctx, tc, &TestControllerOpts{Config: initialConfig})
|
||||
conf.EnabledPlugins = []base.EnabledPlugin{
|
||||
base.EnabledPluginHostAws,
|
||||
base.EnabledPluginHostAzure,
|
||||
}
|
||||
|
||||
_, err = New(testCtx, conf)
|
||||
require.NoError(err)
|
||||
|
||||
// Check that both plugins were written to the temp dir
|
||||
files, err := os.ReadDir(tmpDir)
|
||||
require.NoError(err)
|
||||
require.Len(files, 2)
|
||||
var pluginNames []string
|
||||
for _, file := range files {
|
||||
pluginNames = append(pluginNames, filepath.Base(file.Name()))
|
||||
}
|
||||
expectedPluginNames := []string{host_plugin_assets.HostPluginPrefix + "aws.gz", host_plugin_assets.HostPluginPrefix + "azure.gz"}
|
||||
require.Empty(cmp.Diff(expectedPluginNames, pluginNames))
|
||||
}
|
||||
Reference in new issue
Block a user