target: add controller extension to service handler
The controller extension can be used to access types unavailable in OSS.
This commit is contained in:
1 parent
47477e8fd6
commit
6d219bd5d1
3 files changed
+14
-5
No files matched your search
@@ -201,7 +201,9 @@ func (c *Controller) registerGrpcServices(s *grpc.Server) error {
|
||||
c.VaultCredentialRepoFn,
|
||||
c.StaticCredentialRepoFn,
|
||||
c.downstreamWorkers,
|
||||
c.workerStatusGracePeriod)
|
||||
c.workerStatusGracePeriod,
|
||||
c.ControllerExtension,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create target handler service: %w", err)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/db/timestamp"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/api/services"
|
||||
intglobals "github.com/hashicorp/boundary/internal/globals"
|
||||
"github.com/hashicorp/boundary/internal/host"
|
||||
"github.com/hashicorp/boundary/internal/host/plugin"
|
||||
"github.com/hashicorp/boundary/internal/host/static"
|
||||
@@ -119,6 +120,7 @@ type Service struct {
|
||||
downstreams common.Downstreamers
|
||||
kmsCache *kms.Kms
|
||||
workerStatusGracePeriod *atomic.Int64
|
||||
controllerExt intglobals.ControllerExtension
|
||||
}
|
||||
|
||||
var _ pbs.TargetServiceServer = (*Service)(nil)
|
||||
@@ -137,8 +139,12 @@ func NewService(
|
||||
staticCredRepoFn common.StaticCredentialRepoFactory,
|
||||
downstreams common.Downstreamers,
|
||||
workerStatusGracePeriod *atomic.Int64,
|
||||
controllerExt intglobals.ControllerExtension,
|
||||
) (Service, error) {
|
||||
const op = "targets.NewService"
|
||||
if kmsCache == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing kms repo")
|
||||
}
|
||||
if repoFn == nil {
|
||||
return Service{}, errors.New(ctx, errors.InvalidParameter, op, "missing target repository")
|
||||
}
|
||||
@@ -175,6 +181,7 @@ func NewService(
|
||||
downstreams: downstreams,
|
||||
kmsCache: kmsCache,
|
||||
workerStatusGracePeriod: workerStatusGracePeriod,
|
||||
controllerExt: controllerExt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ func testService(t *testing.T, ctx context.Context, conn *db.DB, kms *kms.Kms, w
|
||||
staticCredRepoFn := func() (*credstatic.Repository, error) {
|
||||
return credstatic.NewRepository(context.Background(), rw, rw, kms)
|
||||
}
|
||||
return targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod)
|
||||
return targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
@@ -2594,7 +2594,7 @@ func TestAuthorizeSession(t *testing.T) {
|
||||
|
||||
statusGracePeriod := new(atomic.Int64)
|
||||
statusGracePeriod.Store(int64(server.DefaultLiveness))
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod)
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil)
|
||||
require.NoError(t, err)
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
@@ -2763,7 +2763,7 @@ func TestAuthorizeSessionTypedCredentials(t *testing.T) {
|
||||
|
||||
statusGracePeriod := new(atomic.Int64)
|
||||
statusGracePeriod.Store(int64(server.DefaultLiveness))
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod)
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
hc := static.TestCatalogs(t, conn, proj.GetPublicId(), 1)[0]
|
||||
@@ -3336,7 +3336,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
|
||||
statusGracePeriod := new(atomic.Int64)
|
||||
statusGracePeriod.Store(int64(server.DefaultLiveness))
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod)
|
||||
s, err := targets.NewService(ctx, kms, repoFn, iamRepoFn, serversRepoFn, sessionRepoFn, pluginHostRepoFn, staticHostRepoFn, vaultCredRepoFn, staticCredRepoFn, nil, statusGracePeriod, nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Authorized user gets full permissions
|
||||
|
||||
Reference in new issue
Block a user