merged commit for plugin rework, storage bucket sql and proto, storage bucket secret rewrapping, storage bucket repository

This commit is contained in:
Danielle Miu authored and Timothy Messier committed 2023-05-31 12:18:13 +00:00
1 parent 38723f8112
commit a4a14fc7fc
66 files changed
+2332 -980

No files matched your search

+2 -2
View File
@@ -12,7 +12,7 @@ import (
pluginhost "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/server"
"github.com/hashicorp/boundary/internal/session"
)
@@ -28,7 +28,7 @@ type (
ServersRepoFactory func() (*server.Repository, error)
StaticRepoFactory func() (*static.Repository, error)
PluginHostRepoFactory func() (*pluginhost.Repository, error)
HostPluginRepoFactory func() (*hostplugin.Repository, error)
HostPluginRepoFactory func() (*plugin.Repository, error)
ConnectionRepoFactory func() (*session.ConnectionRepository, error)
WorkerAuthRepoStorageFactory func() (*server.WorkerAuthRepositoryStorage, error)
)
+29 -11
View File
@@ -33,7 +33,7 @@ import (
"github.com/hashicorp/boundary/internal/kms"
kmsjob "github.com/hashicorp/boundary/internal/kms/job"
"github.com/hashicorp/boundary/internal/observability/event"
"github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/plugin/loopback"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/scheduler/cleaner"
@@ -44,7 +44,7 @@ import (
"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/boundary/internal/types/scope"
host_plugin_assets "github.com/hashicorp/boundary/plugins/host"
"github.com/hashicorp/boundary/sdk/pbs/plugin"
plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin"
external_plugins "github.com/hashicorp/boundary/sdk/plugins"
"github.com/hashicorp/boundary/version"
"github.com/hashicorp/go-hclog"
@@ -257,15 +257,15 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
return nil, fmt.Errorf("error creating loopback plugin: %w", err)
}
plg := loopback.NewWrappingPluginHostClient(lp)
opts := []host.Option{
host.WithDescription("Provides an initial loopback storage and host plugin in Boundary"),
host.WithPublicId(conf.DevLoopbackPluginId),
opts := []plugin.Option{
plugin.WithDescription("Provides an initial loopback storage and host plugin in Boundary"),
plugin.WithPublicId(conf.DevLoopbackPluginId),
}
// TODO(storage): Register loopback as storage supported
if _, err = conf.RegisterHostPlugin(ctx, "loopback", plg, opts...); err != nil {
if _, err = conf.RegisterPlugin(ctx, "loopback", plg, []plugin.PluginType{plugin.PluginTypeHost}, opts...); err != nil {
return nil, err
}
case base.EnabledPluginHostAzure, base.EnabledPluginAws:
case base.EnabledPluginHostAzure:
pluginType := strings.ToLower(enabledPlugin.String())
client, cleanup, err := external_plugins.CreateHostPlugin(
ctx,
@@ -280,14 +280,32 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
return nil, fmt.Errorf("error creating %s host plugin: %w", pluginType, err)
}
conf.ShutdownFuncs = append(conf.ShutdownFuncs, cleanup)
if _, err := conf.RegisterHostPlugin(ctx, pluginType, client, host.WithDescription(fmt.Sprintf("Built-in %s host plugin", enabledPlugin.String()))); err != nil {
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 base.EnabledPluginAws:
pluginType := strings.ToLower(enabledPlugin.String())
client, cleanup, err := external_plugins.CreateHostPlugin(
ctx,
pluginType,
external_plugins.WithPluginOptions(
pluginutil.WithPluginExecutionDirectory(conf.RawConfig.Plugins.ExecutionDir),
pluginutil.WithPluginsFilesystem(host_plugin_assets.HostPluginPrefix, host_plugin_assets.FileSystem()),
),
external_plugins.WithLogger(pluginLogger.Named(pluginType)),
)
if err != nil {
return nil, fmt.Errorf("error creating %s host plugin: %w", pluginType, err)
}
conf.ShutdownFuncs = append(conf.ShutdownFuncs, cleanup)
if _, err := conf.RegisterPlugin(ctx, pluginType, client, []plugin.PluginType{plugin.PluginTypeHost, plugin.PluginTypeStorage}, 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)
}
}
}
if conf.HostPlugins == nil {
conf.HostPlugins = make(map[string]plugin.HostPluginServiceClient)
conf.HostPlugins = make(map[string]plgpb.HostPluginServiceClient)
}
// Set up repo stuff
@@ -358,8 +376,8 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
c.PluginHostRepoFn = func() (*pluginhost.Repository, error) {
return pluginhost.NewRepository(dbase, dbase, c.kms, c.scheduler, c.conf.HostPlugins)
}
c.HostPluginRepoFn = func() (*host.Repository, error) {
return host.NewRepository(dbase, dbase, c.kms)
c.HostPluginRepoFn = func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, dbase, dbase, c.kms)
}
c.AuthTokenRepoFn = func() (*authtoken.Repository, error) {
return authtoken.NewRepository(dbase, dbase, c.kms,
@@ -17,12 +17,12 @@ import (
"github.com/hashicorp/boundary/internal/errors"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
pluginstore "github.com/hashicorp/boundary/internal/host/plugin/store"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/host/static/store"
"github.com/hashicorp/boundary/internal/perms"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/requests"
"github.com/hashicorp/boundary/internal/types/action"
"github.com/hashicorp/boundary/internal/types/resource"
@@ -62,7 +62,7 @@ var (
resource.HostSet: host_sets.CollectionActions,
resource.Host: hosts.CollectionActions,
},
plugin.Subtype: {
hostplugin.Subtype: {
resource.HostSet: host_sets.CollectionActions,
resource.Host: action.ActionSet{
action.List,
@@ -179,8 +179,8 @@ func (s Service) ListHostCatalogs(ctx context.Context, req *pbs.ListHostCatalogs
switch item.(type) {
case *static.HostCatalog:
subtype = static.Subtype
case *plugin.HostCatalog:
subtype = plugin.Subtype
case *hostplugin.HostCatalog:
subtype = hostplugin.Subtype
}
if subtype != "" {
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, item.GetPublicId())
@@ -191,7 +191,7 @@ func (s Service) ListHostCatalogs(ctx context.Context, req *pbs.ListHostCatalogs
}
}
switch hc := item.(type) {
case *plugin.HostCatalog:
case *hostplugin.HostCatalog:
if plgInfo, ok := pluginInfoMap[hc.GetPluginId()]; ok {
outputOpts = append(outputOpts, handlers.WithPlugin(plgInfo))
}
@@ -249,8 +249,8 @@ func (s Service) GetHostCatalog(ctx context.Context, req *pbs.GetHostCatalogRequ
switch hc.(type) {
case *static.HostCatalog:
subtype = static.Subtype
case *plugin.HostCatalog:
subtype = plugin.Subtype
case *hostplugin.HostCatalog:
subtype = hostplugin.Subtype
}
if subtype != "" {
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
@@ -306,8 +306,8 @@ func (s Service) CreateHostCatalog(ctx context.Context, req *pbs.CreateHostCatal
switch hc.(type) {
case *static.HostCatalog:
subtype = static.Subtype
case *plugin.HostCatalog:
subtype = plugin.Subtype
case *hostplugin.HostCatalog:
subtype = hostplugin.Subtype
}
if subtype != "" {
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
@@ -369,8 +369,8 @@ func (s Service) UpdateHostCatalog(ctx context.Context, req *pbs.UpdateHostCatal
switch hc.(type) {
case *static.HostCatalog:
subtype = static.Subtype
case *plugin.HostCatalog:
subtype = plugin.Subtype
case *hostplugin.HostCatalog:
subtype = hostplugin.Subtype
}
if subtype != "" {
collectionActions, err := auth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap[subtype], authResults.Scope.Id, hc.GetPublicId())
@@ -421,7 +421,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Catalog, *plu
return nil, nil, handlers.NotFoundErrorf("Host Catalog %q doesn't exist.", id)
}
cat = hc
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginHostRepoFn()
if err != nil {
return nil, nil, err
@@ -491,7 +491,7 @@ func (s Service) createStaticInRepo(ctx context.Context, projId string, item *pb
return out, nil
}
func (s Service) createPluginInRepo(ctx context.Context, projId string, req *pbs.CreateHostCatalogRequest) (*plugin.HostCatalog, *plugins.PluginInfo, error) {
func (s Service) createPluginInRepo(ctx context.Context, projId string, req *pbs.CreateHostCatalogRequest) (*hostplugin.HostCatalog, *plugins.PluginInfo, error) {
const op = "host_catalogs.(Service).createPluginInRepo"
item := req.GetItem()
pluginId := item.GetPluginId()
@@ -564,7 +564,7 @@ func (s Service) updateStaticInRepo(ctx context.Context, projId, id string, mask
return out, nil
}
func (s Service) updatePluginInRepo(ctx context.Context, projId, id string, mask []string, item *pb.HostCatalog) (*plugin.HostCatalog, *plugins.PluginInfo, error) {
func (s Service) updatePluginInRepo(ctx context.Context, projId, id string, mask []string, item *pb.HostCatalog) (*hostplugin.HostCatalog, *plugins.PluginInfo, error) {
const op = "host_catalogs.(Service).updatePluginInRepo"
h, err := toStoragePluginCatalog(ctx, projId, "", item)
if err != nil {
@@ -596,7 +596,7 @@ func (s Service) updateInRepo(ctx context.Context, projId string, req *pbs.Updat
switch subtypes.SubtypeFromId(domain, req.GetId()) {
case static.Subtype:
hc, err = s.updateStaticInRepo(ctx, projId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
case plugin.Subtype:
case hostplugin.Subtype:
hc, plg, err = s.updatePluginInRepo(ctx, projId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
}
return
@@ -615,7 +615,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
if err != nil {
return false, errors.Wrap(ctx, err, op, errors.WithMsg("unable to delete host"))
}
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginHostRepoFn()
if err != nil {
return false, errors.Wrap(ctx, err, op)
@@ -669,7 +669,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
}
parentId = cat.GetProjectId()
opts = append(opts, auth.WithId(id))
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginHostRepoFn()
if err != nil {
res.Error = err
@@ -692,7 +692,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
return auth.Verify(ctx, opts...)
}
func toPluginInfo(plg *hostplugin.Plugin) *plugins.PluginInfo {
func toPluginInfo(plg *plugin.Plugin) *plugins.PluginInfo {
if plg == nil {
return nil
}
@@ -722,8 +722,8 @@ func toProto(ctx context.Context, in host.Catalog, opt ...handlers.Option) (*pb.
switch in.(type) {
case *static.HostCatalog:
out.Type = static.Subtype.String()
case *plugin.HostCatalog:
out.Type = plugin.Subtype.String()
case *hostplugin.HostCatalog:
out.Type = hostplugin.Subtype.String()
}
}
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
@@ -754,7 +754,7 @@ func toProto(ctx context.Context, in host.Catalog, opt ...handlers.Option) (*pb.
out.AuthorizedCollectionActions = opts.WithAuthorizedCollectionActions
}
switch h := in.(type) {
case *plugin.HostCatalog:
case *hostplugin.HostCatalog:
if outputFields.Has(globals.PluginIdField) {
out.PluginId = h.GetPluginId()
}
@@ -793,22 +793,22 @@ func toStorageStaticCatalog(ctx context.Context, projectId string, item *pb.Host
return hc, nil
}
func toStoragePluginCatalog(ctx context.Context, projectId, plgId string, item *pb.HostCatalog) (*plugin.HostCatalog, error) {
func toStoragePluginCatalog(ctx context.Context, projectId, plgId string, item *pb.HostCatalog) (*hostplugin.HostCatalog, error) {
const op = "host_catalog_service.toStoragePluginCatalog"
var opts []plugin.Option
var opts []hostplugin.Option
if name := item.GetName(); name != nil {
opts = append(opts, plugin.WithName(item.GetName().GetValue()))
opts = append(opts, hostplugin.WithName(item.GetName().GetValue()))
}
if desc := item.GetDescription(); desc != nil {
opts = append(opts, plugin.WithDescription(desc.GetValue()))
opts = append(opts, hostplugin.WithDescription(desc.GetValue()))
}
if attrs := item.GetAttributes(); attrs != nil {
opts = append(opts, plugin.WithAttributes(attrs))
opts = append(opts, hostplugin.WithAttributes(attrs))
}
if secrets := item.GetSecrets(); secrets != nil {
opts = append(opts, plugin.WithSecrets(secrets))
opts = append(opts, hostplugin.WithSecrets(secrets))
}
hc, err := plugin.NewHostCatalog(ctx, projectId, plgId, opts...)
hc, err := hostplugin.NewHostCatalog(ctx, projectId, plgId, opts...)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for creation"))
}
@@ -837,7 +837,7 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
}
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
case static.Subtype:
case plugin.Subtype:
case hostplugin.Subtype:
if req.GetItem().GetPlugin() != nil {
badFields[globals.PluginField] = "This is a read only field."
}
@@ -850,7 +850,7 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
badFields[globals.PluginNameField] = "Can't set the plugin id field along with this field."
}
default:
badFields[globals.TypeField] = fmt.Sprintf("This is a required field and must be either %q or %q.", static.Subtype.String(), plugin.Subtype.String())
badFields[globals.TypeField] = fmt.Sprintf("This is a required field and must be either %q or %q.", static.Subtype.String(), hostplugin.Subtype.String())
}
return badFields
})
@@ -870,8 +870,8 @@ func validateUpdateRequest(req *pbs.UpdateHostCatalogRequest) error {
if req.GetItem().GetPlugin() != nil {
badFields[globals.PluginField] = "This field is unused for this type of host catalog."
}
case plugin.Subtype:
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != plugin.Subtype {
case hostplugin.Subtype:
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != hostplugin.Subtype {
badFields[globals.TypeField] = "Cannot modify resource type."
}
if req.GetItem().GetPlugin() != nil {
@@ -20,11 +20,11 @@ import (
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/host_catalogs"
"github.com/hashicorp/boundary/internal/db"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/plugin/loopback"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/types/scope"
@@ -61,7 +61,7 @@ var authorizedCollectionActions = map[subtypes.Subtype]map[string]*structpb.List
},
},
},
plugin.Subtype: {
hostplugin.Subtype: {
"host-sets": {
Values: []*structpb.Value{
structpb.NewStringValue("create"),
@@ -79,6 +79,7 @@ var authorizedCollectionActions = map[subtypes.Subtype]map[string]*structpb.List
var testAuthorizedActions = []string{"no-op", "read", "update", "delete"}
func TestGet_Static(t *testing.T) {
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -89,11 +90,11 @@ func TestGet_Static(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iam.TestRepo(t, conn, wrapper), nil
@@ -169,6 +170,7 @@ func TestGet_Static(t *testing.T) {
}
func TestGet_Plugin(t *testing.T) {
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -179,19 +181,19 @@ func TestGet_Plugin(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iam.TestRepo(t, conn, wrapper), nil
}
name := "test"
plg := host.TestPlugin(t, conn, name)
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), plugin.WithSecretsHmac([]byte("foobar")))
hcPrev := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), plugin.WithSecretsHmac([]byte("foobar")), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostCatalogPreviousPrefix)))
plg := plugin.TestPlugin(t, conn, name)
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), hostplugin.WithSecretsHmac([]byte("foobar")))
hcPrev := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId(), hostplugin.WithSecretsHmac([]byte("foobar")), hostplugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostCatalogPreviousPrefix)))
toMerge := &pbs.GetHostCatalogRequest{
Id: hc.GetPublicId(),
@@ -213,9 +215,9 @@ func TestGet_Plugin(t *testing.T) {
},
CreatedTime: hc.CreateTime.GetTimestamp(),
UpdatedTime: hc.UpdateTime.GetTimestamp(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions,
AuthorizedCollectionActions: authorizedCollectionActions[plugin.Subtype],
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
SecretsHmac: base58.Encode([]byte("foobar")),
}
@@ -284,6 +286,7 @@ func TestGet_Plugin(t *testing.T) {
}
func TestList(t *testing.T) {
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrapper := db.TestWrapper(t)
@@ -292,11 +295,11 @@ func TestList(t *testing.T) {
iamRepoFn := func() (*iam.Repository, error) {
return iam.TestRepo(t, conn, wrapper), nil
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -324,9 +327,9 @@ func TestList(t *testing.T) {
var testPluginCatalogs []*pb.HostCatalog
name := "test"
plg := host.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
for i := 0; i < 3; i++ {
hc := plugin.TestCatalog(t, conn, pWithCatalogs.GetPublicId(), plg.GetPublicId())
hc := hostplugin.TestCatalog(t, conn, pWithCatalogs.GetPublicId(), plg.GetPublicId())
cat := &pb.HostCatalog{
Id: hc.GetPublicId(),
ScopeId: hc.GetProjectId(),
@@ -340,9 +343,9 @@ func TestList(t *testing.T) {
Description: plg.GetDescription(),
},
Version: 1,
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions,
AuthorizedCollectionActions: authorizedCollectionActions[plugin.Subtype],
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
}
wantSomeCatalogs = append(wantSomeCatalogs, cat)
testPluginCatalogs = append(testPluginCatalogs, cat)
@@ -364,9 +367,9 @@ func TestList(t *testing.T) {
}
name = "different"
diffPlg := host.TestPlugin(t, conn, name)
diffPlg := plugin.TestPlugin(t, conn, name)
for i := 0; i < 3; i++ {
hc := plugin.TestCatalog(t, conn, pWithOtherCatalogs.GetPublicId(), diffPlg.GetPublicId())
hc := hostplugin.TestCatalog(t, conn, pWithOtherCatalogs.GetPublicId(), diffPlg.GetPublicId())
wantOtherCatalogs = append(wantOtherCatalogs, &pb.HostCatalog{
Id: hc.GetPublicId(),
ScopeId: hc.GetProjectId(),
@@ -380,9 +383,9 @@ func TestList(t *testing.T) {
Description: diffPlg.GetDescription(),
},
Version: 1,
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions,
AuthorizedCollectionActions: authorizedCollectionActions[plugin.Subtype],
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
})
}
@@ -488,6 +491,7 @@ func TestList(t *testing.T) {
func TestDelete_Static(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -498,11 +502,11 @@ func TestDelete_Static(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -558,6 +562,7 @@ func TestDelete_Static(t *testing.T) {
func TestDelete_Plugin(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -568,17 +573,17 @@ func TestDelete_Plugin(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
}
plg := host.TestPlugin(t, conn, "test")
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
plg := plugin.TestPlugin(t, conn, "test")
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
s, err := host_catalogs.NewService(repo, pluginHostRepo, pluginRepo, iamRepoFn)
require.NoError(t, err, "Couldn't create a new host catalog service.")
@@ -640,11 +645,11 @@ func TestDelete_twice(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(context.Background(), rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -666,6 +671,7 @@ func TestDelete_twice(t *testing.T) {
func TestCreate_Static(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -676,11 +682,11 @@ func TestCreate_Static(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -818,6 +824,7 @@ func TestCreate_Static(t *testing.T) {
func TestCreate_Plugin(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -828,17 +835,17 @@ func TestCreate_Plugin(t *testing.T) {
repo := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
}
name := "test"
plg := host.TestPlugin(t, conn, name)
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{
plg := plugin.TestPlugin(t, conn, name)
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginHostServer{
OnCreateCatalogFn: func(ctx context.Context, req *plgpb.OnCreateCatalogRequest) (*plgpb.OnCreateCatalogResponse, error) {
return nil, nil
@@ -846,7 +853,7 @@ func TestCreate_Plugin(t *testing.T) {
}),
})
}
defaultHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
defaultHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
defaultHcCreated := defaultHc.GetCreateTime().GetTimestamp().AsTime()
toMerge := &pbs.CreateHostCatalogRequest{}
@@ -862,7 +869,7 @@ func TestCreate_Plugin(t *testing.T) {
ScopeId: proj.GetPublicId(),
Name: &wrappers.StringValue{Value: "name"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
res: &pbs.CreateHostCatalogResponse{
@@ -878,9 +885,9 @@ func TestCreate_Plugin(t *testing.T) {
},
Name: &wrappers.StringValue{Value: "name"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions,
AuthorizedCollectionActions: authorizedCollectionActions[plugin.Subtype],
AuthorizedCollectionActions: authorizedCollectionActions[hostplugin.Subtype],
},
},
},
@@ -888,7 +895,7 @@ func TestCreate_Plugin(t *testing.T) {
name: "Cant create in org",
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
ScopeId: org.GetParentId(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
@@ -897,7 +904,7 @@ func TestCreate_Plugin(t *testing.T) {
name: "Cant create in global",
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
ScopeId: scope.Global.String(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
@@ -924,7 +931,7 @@ func TestCreate_Plugin(t *testing.T) {
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
Id: "not allowed to be set",
ScopeId: proj.GetPublicId(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
res: nil,
@@ -935,7 +942,7 @@ func TestCreate_Plugin(t *testing.T) {
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
CreatedTime: timestamppb.Now(),
ScopeId: proj.GetPublicId(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
res: nil,
@@ -946,7 +953,7 @@ func TestCreate_Plugin(t *testing.T) {
req: &pbs.CreateHostCatalogRequest{Item: &pb.HostCatalog{
UpdatedTime: timestamppb.Now(),
ScopeId: proj.GetPublicId(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PluginId: plg.GetPublicId(),
}},
res: nil,
@@ -995,6 +1002,7 @@ func TestCreate_Plugin(t *testing.T) {
func TestUpdate_Static(t *testing.T) {
t.Parallel()
ctx := context.Background()
conn, _ := db.TestSetup(t, "postgres")
wrapper := db.TestWrapper(t)
kms := kms.TestKms(t, conn, wrapper)
@@ -1005,11 +1013,11 @@ func TestUpdate_Static(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(ctx, rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -1372,7 +1380,7 @@ func TestUpdate_Plugin(t *testing.T) {
rw := db.New(conn)
name := "test"
plg := host.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
lp, err := loopback.NewLoopbackPlugin()
require.NoError(t, err)
plgm := map[string]plgpb.HostPluginServiceClient{
@@ -1382,11 +1390,11 @@ func TestUpdate_Plugin(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
pluginRepo := func() (*host.Repository, error) {
return host.NewRepository(rw, rw, kms)
pluginRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(context.Background(), rw, rw, kms)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -1472,7 +1480,7 @@ func TestUpdate_Plugin(t *testing.T) {
check: func(t *testing.T, in *pb.HostCatalog) {
assert.Equal(t, "new", in.Name.GetValue())
assert.Equal(t, "desc", in.Description.GetValue())
assert.Empty(t, cmp.Diff(authorizedCollectionActions[plugin.Subtype], in.GetAuthorizedCollectionActions(), cmpopts.IgnoreUnexported(structpb.ListValue{}, structpb.Value{})))
assert.Empty(t, cmp.Diff(authorizedCollectionActions[hostplugin.Subtype], in.GetAuthorizedCollectionActions(), cmpopts.IgnoreUnexported(structpb.ListValue{}, structpb.Value{})))
},
},
{
@@ -14,13 +14,13 @@ import (
"github.com/hashicorp/boundary/internal/errors"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
plugstore "github.com/hashicorp/boundary/internal/host/plugin/store"
"github.com/hashicorp/boundary/internal/host/static"
staticstore "github.com/hashicorp/boundary/internal/host/static/store"
"github.com/hashicorp/boundary/internal/libs/endpoint"
"github.com/hashicorp/boundary/internal/perms"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/requests"
"github.com/hashicorp/boundary/internal/types/action"
"github.com/hashicorp/boundary/internal/types/resource"
@@ -49,7 +49,7 @@ var (
action.SetHosts,
action.RemoveHosts,
},
plugin.Subtype: {
hostplugin.Subtype: {
action.NoOp,
action.Read,
action.Update,
@@ -72,7 +72,7 @@ func init() {
if maskManager[static.Subtype], err = handlers.NewMaskManager(handlers.MaskDestination{&staticstore.HostSet{}, &staticstore.UnimplementedSetFields{}}, handlers.MaskSource{&pb.HostSet{}}); err != nil {
panic(err)
}
if maskManager[plugin.Subtype], err = handlers.NewMaskManager(handlers.MaskDestination{&plugstore.HostSet{}}, handlers.MaskSource{&pb.HostSet{}}); err != nil {
if maskManager[hostplugin.Subtype], err = handlers.NewMaskManager(handlers.MaskDestination{&plugstore.HostSet{}}, handlers.MaskSource{&pb.HostSet{}}); err != nil {
panic(err)
}
}
@@ -94,7 +94,7 @@ func NewService(staticRepoFn common.StaticRepoFactory, pluginRepoFn common.Plugi
return Service{}, errors.NewDeprecated(errors.InvalidParameter, op, "missing static repository")
}
if pluginRepoFn == nil {
return Service{}, errors.NewDeprecated(errors.InvalidParameter, op, "missing plugin repository")
return Service{}, errors.NewDeprecated(errors.InvalidParameter, op, "missing hostplugin repository")
}
return Service{staticRepoFn: staticRepoFn, pluginRepoFn: pluginRepoFn}, nil
}
@@ -451,7 +451,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Set, []host.H
hl = append(hl, h)
}
hs = hset
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginRepoFn()
if err != nil {
return nil, nil, nil, err
@@ -466,7 +466,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Set, []host.H
hs = hset
plg = toPluginInfo(hsplg)
for _, h := range hset.HostIds {
hl = append(hl, &plugin.Host{
hl = append(hl, &hostplugin.Host{
Host: &plugstore.Host{
PublicId: h,
CatalogId: hset.CatalogId,
@@ -502,7 +502,7 @@ func (s Service) createInRepo(ctx context.Context, projectId, catalogId string,
return nil, nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create host set but no error returned from repository.")
}
hSet = out
case plugin.Subtype:
case hostplugin.Subtype:
h, err := toStoragePluginSet(ctx, catalogId, item)
if err != nil {
return nil, nil, err
@@ -564,7 +564,7 @@ func (s Service) updatePluginInRepo(ctx context.Context, projectId string, req *
return nil, nil, nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for update"))
}
h.PublicId = req.GetId()
dbMask := maskManager[plugin.Subtype].Translate(req.GetUpdateMask().GetPaths(), "attributes")
dbMask := maskManager[hostplugin.Subtype].Translate(req.GetUpdateMask().GetPaths(), "attributes")
if len(dbMask) == 0 {
return nil, nil, nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
}
@@ -591,7 +591,7 @@ func (s Service) updateInRepo(ctx context.Context, projectId, catalogId string,
switch subtypes.SubtypeFromId(domain, req.GetId()) {
case static.Subtype:
hs, hosts, err = s.updateStaticInRepo(ctx, projectId, catalogId, req)
case plugin.Subtype:
case hostplugin.Subtype:
hs, hosts, plg, err = s.updatePluginInRepo(ctx, projectId, req)
}
return
@@ -610,7 +610,7 @@ func (s Service) deleteFromRepo(ctx context.Context, projectId, id string) (bool
if err != nil {
return false, errors.Wrap(ctx, err, op, errors.WithMsg("unable to delete host"))
}
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginRepoFn()
if err != nil {
return false, err
@@ -640,7 +640,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string, opt ...host
for _, a := range sl {
sets = append(sets, a)
}
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginRepoFn()
if err != nil {
return nil, nil, err
@@ -763,7 +763,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return nil, res
}
set = ss
case plugin.Subtype:
case hostplugin.Subtype:
ps, _, err := pluginRepo.LookupSet(ctx, id)
if err != nil {
res.Error = err
@@ -792,7 +792,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return nil, res
}
cat = cs
case plugin.Subtype:
case hostplugin.Subtype:
pc, _, err := pluginRepo.LookupCatalog(ctx, parentId)
if err != nil {
res.Error = err
@@ -808,7 +808,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return cat, auth.Verify(ctx, opts...)
}
func toPluginInfo(plg *hostplugin.Plugin) *plugins.PluginInfo {
func toPluginInfo(plg *plugin.Plugin) *plugins.PluginInfo {
if plg == nil {
return nil
}
@@ -838,8 +838,8 @@ func toProto(ctx context.Context, in host.Set, hosts []host.Host, opt ...handler
switch in.(type) {
case *static.HostSet:
out.Type = static.Subtype.String()
case *plugin.HostSet:
out.Type = plugin.Subtype.String()
case *hostplugin.HostSet:
out.Type = hostplugin.Subtype.String()
}
}
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
@@ -873,7 +873,7 @@ func toProto(ctx context.Context, in host.Set, hosts []host.Host, opt ...handler
}
switch h := in.(type) {
case *plugin.HostSet:
case *hostplugin.HostSet:
if outputFields.Has(globals.PreferredEndpointsField) {
out.PreferredEndpoints = h.PreferredEndpoints
}
@@ -913,25 +913,25 @@ func toStorageStaticSet(ctx context.Context, catalogId string, item *pb.HostSet)
return hs, nil
}
func toStoragePluginSet(ctx context.Context, catalogId string, item *pb.HostSet) (*plugin.HostSet, error) {
func toStoragePluginSet(ctx context.Context, catalogId string, item *pb.HostSet) (*hostplugin.HostSet, error) {
const op = "host_set_service.toStoragePluginSet"
var opts []plugin.Option
var opts []hostplugin.Option
if item.GetName() != nil {
opts = append(opts, plugin.WithName(item.GetName().GetValue()))
opts = append(opts, hostplugin.WithName(item.GetName().GetValue()))
}
if item.GetDescription() != nil {
opts = append(opts, plugin.WithDescription(item.GetDescription().GetValue()))
opts = append(opts, hostplugin.WithDescription(item.GetDescription().GetValue()))
}
if item.GetAttributes() != nil {
opts = append(opts, plugin.WithAttributes(item.GetAttributes()))
opts = append(opts, hostplugin.WithAttributes(item.GetAttributes()))
}
if item.GetPreferredEndpoints() != nil {
opts = append(opts, plugin.WithPreferredEndpoints(item.GetPreferredEndpoints()))
opts = append(opts, hostplugin.WithPreferredEndpoints(item.GetPreferredEndpoints()))
}
if item.GetSyncIntervalSeconds() != nil {
opts = append(opts, plugin.WithSyncIntervalSeconds(item.GetSyncIntervalSeconds().GetValue()))
opts = append(opts, hostplugin.WithSyncIntervalSeconds(item.GetSyncIntervalSeconds().GetValue()))
}
hs, err := plugin.NewHostSet(ctx, catalogId, opts...)
hs, err := hostplugin.NewHostSet(ctx, catalogId, opts...)
if err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("Unable to build host set for creation"))
}
@@ -969,8 +969,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateHostSetRequest) e
if len(req.GetItem().PreferredEndpoints) > 0 {
badFields[globals.PreferredEndpointsField] = "This field is not yet supported for static host sets."
}
case plugin.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != plugin.Subtype.String() {
case hostplugin.Subtype:
if req.GetItem().GetType() != "" && req.GetItem().GetType() != hostplugin.Subtype.String() {
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
}
if val := req.GetItem().GetSyncIntervalSeconds(); val != nil {
@@ -997,7 +997,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateHostSetRequest) e
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
badFields[globals.TypeField] = "Cannot modify the resource type."
}
case plugin.Subtype:
case hostplugin.Subtype:
if val := req.GetItem().GetSyncIntervalSeconds(); val != nil {
if val.GetValue() == 0 || val.GetValue() < -1 {
badFields[globals.SyncIntervalSecondsField] = "Must be -1 or a positive integer."
@@ -20,11 +20,11 @@ import (
"github.com/hashicorp/boundary/internal/db"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/plugin/loopback"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/types/scope"
@@ -46,8 +46,8 @@ import (
)
var testAuthorizedActions = map[subtypes.Subtype][]string{
static.Subtype: {"no-op", "read", "update", "delete", "add-hosts", "set-hosts", "remove-hosts"},
plugin.Subtype: {"no-op", "read", "update", "delete"},
static.Subtype: {"no-op", "read", "update", "delete", "add-hosts", "set-hosts", "remove-hosts"},
hostplugin.Subtype: {"no-op", "read", "update", "delete"},
}
func TestGet_Static(t *testing.T) {
@@ -68,8 +68,8 @@ func TestGet_Static(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
hs := static.TestSets(t, conn, hc.GetPublicId(), 1)[0]
@@ -165,17 +165,17 @@ func TestGet_Plugin(t *testing.T) {
name := "test"
prefEndpoints := []string{"cidr:1.2.3.4", "cidr:2.3.4.5/24"}
plg := hostplugin.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(prefEndpoints), plugin.WithSyncIntervalSeconds(-1))
hsPrev := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(prefEndpoints), plugin.WithSyncIntervalSeconds(-1), plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostSetPreviousPrefix)))
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hs := hostplugin.TestSet(t, conn, kms, sche, hc, plgm, hostplugin.WithPreferredEndpoints(prefEndpoints), hostplugin.WithSyncIntervalSeconds(-1))
hsPrev := hostplugin.TestSet(t, conn, kms, sche, hc, plgm, hostplugin.WithPreferredEndpoints(prefEndpoints), hostplugin.WithSyncIntervalSeconds(-1), hostplugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostSetPreviousPrefix)))
toMerge := &pbs.GetHostSetRequest{}
@@ -184,7 +184,7 @@ func TestGet_Plugin(t *testing.T) {
Id: hs.GetPublicId(),
CreatedTime: hs.CreateTime.GetTimestamp(),
UpdatedTime: hs.UpdateTime.GetTimestamp(),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
Plugin: &plugins.PluginInfo{
Id: plg.GetPublicId(),
@@ -193,7 +193,7 @@ func TestGet_Plugin(t *testing.T) {
},
PreferredEndpoints: prefEndpoints,
SyncIntervalSeconds: &wrappers.Int32Value{Value: -1},
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
}
cases := []struct {
@@ -279,8 +279,8 @@ func TestList_Static(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
hcs := static.TestCatalogs(t, conn, proj.GetPublicId(), 2)
hc, hcNoHosts := hcs[0], hcs[1]
@@ -379,20 +379,20 @@ func TestList_Plugin(t *testing.T) {
return static.NewRepository(rw, rw, kms)
}
name := "test"
plg := hostplugin.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hcNoHosts := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hcNoHosts := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
preferredEndpoints := []string{"cidr:1.2.3.4", "dns:*.foobar.com"}
var wantHs []*pb.HostSet
for i := 0; i < 10; i++ {
h := plugin.TestSet(t, conn, kms, sche, hc, plgm, plugin.WithPreferredEndpoints(preferredEndpoints), plugin.WithSyncIntervalSeconds(5))
h := hostplugin.TestSet(t, conn, kms, sche, hc, plgm, hostplugin.WithPreferredEndpoints(preferredEndpoints), hostplugin.WithSyncIntervalSeconds(5))
wantHs = append(wantHs, &pb.HostSet{
Id: h.GetPublicId(),
HostCatalogId: h.GetCatalogId(),
@@ -405,8 +405,8 @@ func TestList_Plugin(t *testing.T) {
CreatedTime: h.GetCreateTime().GetTimestamp(),
UpdatedTime: h.GetUpdateTime().GetTimestamp(),
Version: h.GetVersion(),
Type: plugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
PreferredEndpoints: preferredEndpoints,
SyncIntervalSeconds: &wrappers.Int32Value{Value: 5},
})
@@ -492,8 +492,8 @@ func TestDelete_Static(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
h := static.TestSets(t, conn, hc.GetPublicId(), 1)[0]
@@ -563,17 +563,17 @@ func TestDelete_Plugin(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
name := "test"
plg := hostplugin.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := plugin.TestSet(t, conn, kms, sche, hc, plgm)
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := hostplugin.TestSet(t, conn, kms, sche, hc, plgm)
s, err := host_sets.NewService(repoFn, pluginRepoFn)
require.NoError(t, err, "Couldn't create a new host set service.")
@@ -641,8 +641,8 @@ func TestDelete_twice(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
h := static.TestSets(t, conn, hc.GetPublicId(), 1)[0]
@@ -678,8 +678,8 @@ func TestCreate_Static(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
prefEndpoints := []string{"cidr:1.2.3.4", "cidr:2.3.4.5/24"}
@@ -835,9 +835,9 @@ func TestCreate_Plugin(t *testing.T) {
return static.NewRepository(rw, rw, kms)
}
name := "test"
plg := hostplugin.TestPlugin(t, conn, name)
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{
plg := plugin.TestPlugin(t, conn, name)
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginHostServer{
OnCreateSetFn: func(ctx context.Context, req *plgpb.OnCreateSetRequest) (*plgpb.OnCreateSetResponse, error) {
return nil, nil
@@ -845,7 +845,7 @@ func TestCreate_Plugin(t *testing.T) {
}),
})
}
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
attrs := map[string]any{
"int": 1,
@@ -891,7 +891,7 @@ func TestCreate_Plugin(t *testing.T) {
HostCatalogId: hc.GetPublicId(),
Name: &wrappers.StringValue{Value: "No Attributes"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: -1},
}},
res: &pbs.CreateHostSetResponse{
@@ -906,8 +906,8 @@ func TestCreate_Plugin(t *testing.T) {
},
Name: &wrappers.StringValue{Value: "No Attributes"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: -1},
},
},
@@ -918,7 +918,7 @@ func TestCreate_Plugin(t *testing.T) {
HostCatalogId: hc.GetPublicId(),
Name: &wrappers.StringValue{Value: "With Attributes"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: 90},
Attrs: &pb.HostSet_Attributes{
Attributes: testInputAttrs,
@@ -936,9 +936,9 @@ func TestCreate_Plugin(t *testing.T) {
},
Name: &wrappers.StringValue{Value: "With Attributes"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
SyncIntervalSeconds: &wrapperspb.Int32Value{Value: 90},
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
Attrs: &pb.HostSet_Attributes{
Attributes: testOutputAttrs,
},
@@ -951,7 +951,7 @@ func TestCreate_Plugin(t *testing.T) {
HostCatalogId: hc.GetPublicId(),
Name: &wrappers.StringValue{Value: "name"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PreferredEndpoints: prefEndpoints,
}},
res: &pbs.CreateHostSetResponse{
@@ -966,9 +966,9 @@ func TestCreate_Plugin(t *testing.T) {
},
Name: &wrappers.StringValue{Value: "name"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PreferredEndpoints: prefEndpoints,
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
},
},
},
@@ -978,7 +978,7 @@ func TestCreate_Plugin(t *testing.T) {
HostCatalogId: hc.GetPublicId(),
Name: &wrappers.StringValue{Value: "name"},
Description: &wrappers.StringValue{Value: "desc"},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
PreferredEndpoints: append(prefEndpoints, "foobar:1.2.3.4"),
}},
err: handlers.ApiErrorWithCode(codes.InvalidArgument),
@@ -1012,8 +1012,8 @@ func TestCreate_Plugin(t *testing.T) {
},
Name: &wrappers.StringValue{Value: "no type name"},
Description: &wrappers.StringValue{Value: "no type desc"},
Type: plugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
},
},
},
@@ -1130,8 +1130,8 @@ func TestUpdate_Static(t *testing.T) {
Id: hs.GetPublicId(),
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
tested, err := host_sets.NewService(repoFn, plgRepoFn)
require.NoError(t, err, "Failed to create a new host set service.")
@@ -1475,7 +1475,7 @@ func TestUpdate_Plugin(t *testing.T) {
rw := db.New(conn)
name := "test"
plg := hostplugin.TestPlugin(t, conn, name)
plg := plugin.TestPlugin(t, conn, name)
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
@@ -1483,8 +1483,8 @@ func TestUpdate_Plugin(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepo := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginHostRepo := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
iamRepoFn := func() (*iam.Repository, error) {
return iamRepo, nil
@@ -1492,7 +1492,7 @@ func TestUpdate_Plugin(t *testing.T) {
tested, err := host_sets.NewService(repoFn, pluginHostRepo)
require.NoError(t, err, "Failed to create a new host catalog service.")
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
ctx := auth.DisabledAuthTestContext(iamRepoFn, proj.GetPublicId())
freshSet := func(t *testing.T) *pb.HostSet {
@@ -1504,7 +1504,7 @@ func TestUpdate_Plugin(t *testing.T) {
HostCatalogId: hc.GetPublicId(),
Name: wrapperspb.String("default"),
Description: wrapperspb.String("default"),
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
Attrs: &pb.HostSet_Attributes{
Attributes: attr,
},
@@ -1820,8 +1820,8 @@ func TestAddHostSetHosts(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
s, err := host_sets.NewService(repoFn, plgRepoFn)
require.NoError(t, err, "Error when getting new host set service.")
@@ -1941,8 +1941,8 @@ func TestSetHostSetHosts(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
s, err := host_sets.NewService(repoFn, plgRepoFn)
require.NoError(t, err, "Error when getting new host set service.")
@@ -2058,8 +2058,8 @@ func TestRemoveHostSetHosts(t *testing.T) {
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plgRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
plgRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
s, err := host_sets.NewService(repoFn, plgRepoFn)
require.NoError(t, err, "Error when getting new host set service.")
@@ -16,11 +16,11 @@ import (
"github.com/hashicorp/boundary/internal/errors"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/host/static/store"
"github.com/hashicorp/boundary/internal/perms"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
plugin "github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/requests"
"github.com/hashicorp/boundary/internal/types/action"
"github.com/hashicorp/boundary/internal/types/resource"
@@ -43,7 +43,7 @@ var (
action.Update,
action.Delete,
},
plugin.Subtype: {
hostplugin.Subtype: {
action.NoOp,
action.Read,
},
@@ -310,7 +310,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Host, *plugin
if h == nil {
return nil, nil, handlers.NotFoundErrorf("Host %q doesn't exist.", id)
}
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginRepoFn()
if err != nil {
return nil, nil, err
@@ -425,7 +425,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string) ([]host.Hos
for _, h := range hl {
hosts = append(hosts, h)
}
case plugin.Subtype:
case hostplugin.Subtype:
repo, err := s.pluginRepoFn()
if err != nil {
return nil, nil, err
@@ -473,7 +473,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return nil, res
}
parentId = h.GetCatalogId()
case plugin.Subtype:
case hostplugin.Subtype:
h, _, err := pluginRepo.LookupHost(ctx, id)
if err != nil {
res.Error = err
@@ -501,7 +501,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return nil, res
}
cat = stcat
case plugin.Subtype:
case hostplugin.Subtype:
plcat, _, err := pluginRepo.LookupCatalog(ctx, parentId)
if err != nil {
res.Error = err
@@ -517,7 +517,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
return cat, auth.Verify(ctx, opts...)
}
func toPluginInfo(plg *hostplugin.Plugin) *plugins.PluginInfo {
func toPluginInfo(plg *plugin.Plugin) *plugins.PluginInfo {
if plg == nil {
return nil
}
@@ -546,8 +546,8 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
switch in.(type) {
case *static.Host:
out.Type = static.Subtype.String()
case *plugin.Host:
out.Type = plugin.Subtype.String()
case *hostplugin.Host:
out.Type = hostplugin.Subtype.String()
}
}
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
@@ -588,7 +588,7 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
out.Plugin = opts.WithPlugin
}
switch h := in.(type) {
case *plugin.Host:
case *hostplugin.Host:
if outputFields.Has(globals.IpAddressesField) {
out.IpAddresses = h.IpAddresses
}
@@ -661,7 +661,7 @@ func validateCreateRequest(req *pbs.CreateHostRequest) error {
}
}
}
case plugin.Subtype:
case hostplugin.Subtype:
badFields[globals.HostCatalogIdField] = "Cannot manually create hosts for this type of catalog."
}
return badFields
@@ -699,7 +699,7 @@ func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
}
}
}
case plugin.Subtype:
case hostplugin.Subtype:
badFields[globals.IdField] = "Cannot modify this type of host."
default:
badFields["id"] = "Improperly formatted identifier used."
@@ -712,7 +712,7 @@ func validateDeleteRequest(req *pbs.DeleteHostRequest) error {
return handlers.ValidateDeleteRequest(func() map[string]string {
badFields := map[string]string{}
switch subtypes.SubtypeFromId(domain, req.GetId()) {
case plugin.Subtype:
case hostplugin.Subtype:
badFields[globals.IdField] = "Cannot manually delete this type of host."
}
return badFields
@@ -19,11 +19,11 @@ import (
"github.com/hashicorp/boundary/internal/daemon/controller/handlers/hosts"
"github.com/hashicorp/boundary/internal/db"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
hostplugin "github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/plugin/loopback"
"github.com/hashicorp/boundary/internal/scheduler"
"github.com/hashicorp/boundary/internal/types/scope"
@@ -43,8 +43,8 @@ import (
)
var testAuthorizedActions = map[subtypes.Subtype][]string{
static.Subtype: {"no-op", "read", "update", "delete"},
plugin.Subtype: {"no-op", "read"},
static.Subtype: {"no-op", "read", "update", "delete"},
hostplugin.Subtype: {"no-op", "read"},
}
func TestGet_Static(t *testing.T) {
@@ -62,8 +62,8 @@ func TestGet_Static(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -152,27 +152,27 @@ func TestGet_Plugin(t *testing.T) {
org, proj := iam.TestScopes(t, iamRepo)
plg := hostplugin.TestPlugin(t, conn, "test")
plg := plugin.TestPlugin(t, conn, "test")
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test", plugin.WithExternalName("test-ext-name"))
hPrev := plugin.TestHost(t, conn, hc.GetPublicId(), "test-prev",
plugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)),
plugin.WithExternalName("test-prev-name"),
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := hostplugin.TestHost(t, conn, hc.GetPublicId(), "test", hostplugin.WithExternalName("test-ext-name"))
hPrev := hostplugin.TestHost(t, conn, hc.GetPublicId(), "test-prev",
hostplugin.WithPublicId(fmt.Sprintf("%s_1234567890", globals.PluginHostPreviousPrefix)),
hostplugin.WithExternalName("test-prev-name"),
)
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm)
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h, hPrev})
hs := hostplugin.TestSet(t, conn, kms, sche, hc, plgm)
hostplugin.TestSetMembers(t, conn, hs.GetPublicId(), []*hostplugin.Host{h, hPrev})
pHost := &pb.Host{
HostCatalogId: hc.GetPublicId(),
@@ -180,7 +180,7 @@ func TestGet_Plugin(t *testing.T) {
CreatedTime: h.CreateTime.GetTimestamp(),
UpdatedTime: h.UpdateTime.GetTimestamp(),
Scope: &scopes.ScopeInfo{Id: proj.GetPublicId(), Type: scope.Project.String(), ParentScopeId: org.GetPublicId()},
Type: plugin.Subtype.String(),
Type: hostplugin.Subtype.String(),
Plugin: &plugins.PluginInfo{
Id: plg.GetPublicId(),
Name: plg.GetName(),
@@ -189,7 +189,7 @@ func TestGet_Plugin(t *testing.T) {
HostSetIds: []string{hs.GetPublicId()},
ExternalId: "test",
ExternalName: "test-ext-name",
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
}
cases := []struct {
@@ -271,8 +271,8 @@ func TestList_Static(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -383,28 +383,28 @@ func TestList_Plugin(t *testing.T) {
}
org, proj := iam.TestScopes(t, iamRepo)
plg := hostplugin.TestPlugin(t, conn, "test")
plg := plugin.TestPlugin(t, conn, "test")
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
}
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
hcs := plugin.TestCatalogs(t, conn, proj.GetPublicId(), plg.GetPublicId(), 2)
hcs := hostplugin.TestCatalogs(t, conn, proj.GetPublicId(), plg.GetPublicId(), 2)
hc, hcNoHosts := hcs[0], hcs[1]
hs := plugin.TestSet(t, conn, kms, sche, hc, plgm)
hs := hostplugin.TestSet(t, conn, kms, sche, hc, plgm)
var wantHs []*pb.Host
for i := 0; i < 10; i++ {
extId := fmt.Sprintf("host %d", i)
h := plugin.TestHost(t, conn, hc.GetPublicId(), extId, plugin.WithExternalName(fmt.Sprintf("ext-name-%d", i)))
plugin.TestSetMembers(t, conn, hs.GetPublicId(), []*plugin.Host{h})
h := hostplugin.TestHost(t, conn, hc.GetPublicId(), extId, hostplugin.WithExternalName(fmt.Sprintf("ext-name-%d", i)))
hostplugin.TestSetMembers(t, conn, hs.GetPublicId(), []*hostplugin.Host{h})
wantHs = append(wantHs, &pb.Host{
Id: h.GetPublicId(),
HostCatalogId: h.GetCatalogId(),
@@ -420,8 +420,8 @@ func TestList_Plugin(t *testing.T) {
Version: 1,
ExternalId: extId,
ExternalName: fmt.Sprintf("ext-name-%d", i),
Type: plugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[plugin.Subtype],
Type: hostplugin.Subtype.String(),
AuthorizedActions: testAuthorizedActions[hostplugin.Subtype],
})
}
sort.Slice(wantHs, func(i, j int) bool {
@@ -513,8 +513,8 @@ func TestDelete(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -522,9 +522,9 @@ func TestDelete(t *testing.T) {
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
h := static.TestHosts(t, conn, hc.GetPublicId(), 1)[0]
plg := hostplugin.TestPlugin(t, conn, "test")
pluginHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginH := plugin.TestHost(t, conn, pluginHc.GetPublicId(), "test")
plg := plugin.TestPlugin(t, conn, "test")
pluginHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginH := hostplugin.TestHost(t, conn, pluginHc.GetPublicId(), "test")
s, err := hosts.NewService(repoFn, pluginRepoFn)
require.NoError(t, err, "Couldn't create a new host set service.")
@@ -597,8 +597,8 @@ func TestDelete_twice(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -634,16 +634,16 @@ func TestCreate(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
plg := hostplugin.TestPlugin(t, conn, "test")
pluginHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
plg := plugin.TestPlugin(t, conn, "test")
pluginHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
defaultHcCreated := hc.GetCreateTime().GetTimestamp().AsTime()
@@ -870,8 +870,8 @@ func TestUpdate_Static(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
@@ -1337,16 +1337,16 @@ func TestUpdate_Plugin(t *testing.T) {
rw := db.New(conn)
sche := scheduler.TestScheduler(t, conn, wrapper)
pluginRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
repoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
plg := hostplugin.TestPlugin(t, conn, "test")
hc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := plugin.TestHost(t, conn, hc.GetPublicId(), "test")
plg := plugin.TestPlugin(t, conn, "test")
hc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
h := hostplugin.TestHost(t, conn, hc.GetPublicId(), "test")
tested, err := hosts.NewService(repoFn, pluginRepoFn)
require.NoError(t, err)
@@ -33,11 +33,11 @@ import (
"github.com/hashicorp/boundary/internal/db"
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
authpb "github.com/hashicorp/boundary/internal/gen/controller/auth"
"github.com/hashicorp/boundary/internal/host/plugin"
hostplugin "github.com/hashicorp/boundary/internal/host/plugin"
"github.com/hashicorp/boundary/internal/host/static"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/plugin/host"
"github.com/hashicorp/boundary/internal/plugin"
"github.com/hashicorp/boundary/internal/plugin/loopback"
"github.com/hashicorp/boundary/internal/requests"
"github.com/hashicorp/boundary/internal/scheduler"
@@ -104,8 +104,8 @@ func testService(t *testing.T, ctx context.Context, conn *db.DB, kms *kms.Kms, w
staticHostRepoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
vaultCredRepoFn := func() (*vault.Repository, error) {
return vault.NewRepository(rw, rw, kms, sche)
@@ -1366,9 +1366,9 @@ func TestAddTargetHostSources(t *testing.T) {
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
hs := static.TestSets(t, conn, hc.GetPublicId(), 2)
plg := host.TestPlugin(t, conn, "test")
pluginHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := plugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg := plugin.TestPlugin(t, conn, "test")
pluginHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := hostplugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
})
@@ -1528,9 +1528,9 @@ func TestSetTargetHostSources(t *testing.T) {
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
hs := static.TestSets(t, conn, hc.GetPublicId(), 2)
plg := host.TestPlugin(t, conn, "test")
pluginHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := plugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg := plugin.TestPlugin(t, conn, "test")
pluginHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := hostplugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
})
@@ -1678,9 +1678,9 @@ func TestRemoveTargetHostSources(t *testing.T) {
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
hs := static.TestSets(t, conn, hc.GetPublicId(), 2)
plg := host.TestPlugin(t, conn, "test")
pluginHc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := plugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg := plugin.TestPlugin(t, conn, "test")
pluginHc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
pluginHs := hostplugin.TestSet(t, conn, kms, sche, pluginHc, map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(&loopback.TestPluginServer{}),
})
@@ -2455,7 +2455,7 @@ func TestAuthorizeSession(t *testing.T) {
return ldap.NewRepository(ctx, rw, rw, kms)
}
plg := host.TestPlugin(t, conn, "test")
plg := plugin.TestPlugin(t, conn, "test")
plgm := map[string]plgpb.HostPluginServiceClient{
plg.GetPublicId(): loopback.NewWrappingPluginHostClient(loopback.TestPluginHostServer{
ListHostsFn: func(_ context.Context, req *plgpb.ListHostsRequest) (*plgpb.ListHostsResponse, error) {
@@ -2480,8 +2480,8 @@ func TestAuthorizeSession(t *testing.T) {
},
}),
}
pluginHostRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, plgm)
pluginHostRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, plgm)
}
loginName := "foo@bar.com"
@@ -2527,11 +2527,11 @@ func TestAuthorizeSession(t *testing.T) {
hWithPort, _, err = staticRepo.UpdateHost(ctx, hcWithPort.GetProjectId(), hWithPort, hWithPort.GetVersion(), []string{"address"})
require.NoError(t, err)
phc := plugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
phs := plugin.TestSet(t, conn, kms, sche, phc, plgm, plugin.WithPreferredEndpoints([]string{"cidr:10.0.0.0/24"}))
phc := hostplugin.TestCatalog(t, conn, proj.GetPublicId(), plg.GetPublicId())
phs := hostplugin.TestSet(t, conn, kms, sche, phc, plgm, hostplugin.WithPreferredEndpoints([]string{"cidr:10.0.0.0/24"}))
// Sync the boundary db from the plugins
plugin.TestRunSetSync(t, conn, kms, plgm)
hostplugin.TestRunSetSync(t, conn, kms, plgm)
v := vault.NewTestVaultServer(t)
v.MountPKI(t, vault.WithTestMountPath("pki/"+userName))
@@ -2740,8 +2740,8 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
atRepoFn := func() (*authtoken.Repository, error) {
return authtoken.NewRepository(rw, rw, kms)
}
pluginHostRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
org, proj := iam.TestScopes(t, iamRepo)
@@ -3320,8 +3320,8 @@ func TestAuthorizeSession_Errors(t *testing.T) {
staticHostRepoFn := func() (*static.Repository, error) {
return static.NewRepository(rw, rw, kms)
}
pluginHostRepoFn := func() (*plugin.Repository, error) {
return plugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
pluginHostRepoFn := func() (*hostplugin.Repository, error) {
return hostplugin.NewRepository(rw, rw, kms, sche, map[string]plgpb.HostPluginServiceClient{})
}
vaultCredRepoFn := func() (*vault.Repository, error) {
return vault.NewRepository(rw, rw, kms, sche)