feat(gcp): add GCP plugin (#5229)

Add GCP as a supported plugin for dynamic host catalogs
This commit is contained in:
Elim Tsiagbey authored and GitHub committed 2024-11-08 11:09:29 -05:00
1 parent f227020b67
commit 514bcc19f6
8 files changed
+428 -4

No files matched your search

+3
View File
@@ -38,6 +38,7 @@ const (
EnabledPluginAws
EnabledPluginHostAzure
EnabledPluginMinio
EnabledPluginGCP
)
// MinioEnabled controls if the Minio storage plugin should be initiated or not
@@ -53,6 +54,8 @@ func (e EnabledPlugin) String() string {
return "Azure"
case EnabledPluginMinio:
return "MinIO"
case EnabledPluginGCP:
return "GCP"
default:
return ""
}
+1 -1
View File
@@ -821,7 +821,7 @@ func (c *Command) Run(args []string) int {
}
{
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginAws, base.EnabledPluginHostAzure)
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginAws, base.EnabledPluginHostAzure, base.EnabledPluginGCP)
if base.MinioEnabled {
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginMinio)
}
+1 -1
View File
@@ -492,7 +492,7 @@ func (c *Command) Run(args []string) int {
}
}
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginAws, base.EnabledPluginHostAzure)
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginAws, base.EnabledPluginHostAzure, base.EnabledPluginGCP)
if base.MinioEnabled {
c.EnabledPlugins = append(c.EnabledPlugins, base.EnabledPluginMinio)
}
+2
View File
@@ -320,6 +320,8 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
if _, err := conf.RegisterPlugin(ctx, pluginType, client, []plugin.PluginType{plugin.PluginTypeHost}, plugin.WithDescription(fmt.Sprintf("Built-in %s host plugin", enabledPlugin.String()))); err != nil {
return nil, fmt.Errorf("error registering %s host plugin: %w", pluginType, err)
}
case enabledPlugin == base.EnabledPluginGCP && !c.conf.SkipPlugins:
fallthrough
case enabledPlugin == base.EnabledPluginAws && !c.conf.SkipPlugins:
pluginType := strings.ToLower(enabledPlugin.String())
client, cleanup, err := external_plugins.CreateHostPlugin(
@@ -257,6 +257,7 @@ func TestController_NewPluginsConfig(t *testing.T) {
conf.EnabledPlugins = []base.EnabledPlugin{
base.EnabledPluginAws,
base.EnabledPluginHostAzure,
base.EnabledPluginGCP,
}
_, err = New(testCtx, conf)
@@ -265,14 +266,15 @@ func TestController_NewPluginsConfig(t *testing.T) {
// Check that both plugins were written to the temp dir
files, err := os.ReadDir(tmpDir)
require.NoError(err)
require.Len(files, 2)
require.Len(files, 3)
for _, file := range files {
name := filepath.Base(file.Name())
// Remove random chars and hyphen
name = name[0 : len(name)-6]
switch name {
case boundary_plugin_assets.PluginPrefix + "aws",
boundary_plugin_assets.PluginPrefix + "azure":
boundary_plugin_assets.PluginPrefix + "azure",
boundary_plugin_assets.PluginPrefix + "gcp":
default:
require.Fail("unexpected name", name)
}