From 9b271d7dd80f8ea4a3fd021fbf41f6f851ce1473 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 30 Aug 2022 14:22:10 -0400 Subject: [PATCH] Fix error about unimplemented HcpbWorkers call (#2361) Although there is a compile time check on the type, it will always succeed due to the Unimplemented embedding requirement. As a result, this PR also changes Unimplemented calls to Unsafe calls, which were added later "for those that prefer their code to break"; the comments on these state: // UnsafeXServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to XServiceServer will // result in compilation errors. See https://github.com/grpc/grpc-go/issues/4500#issuecomment-852597871 for some more context. I think we're fine with compilation errors though; we own both the server and client side of things and generally are going to add new methods only when we intend to also add them on the client side. Notably, what the comment does not indicate is that it will break at runtime; already it should return a suitable (404 or 405) error if the client requests a method that does not exist. --- .../cluster/handlers/multihop_service.go | 6 +++--- .../daemon/cluster/handlers/worker_service.go | 14 +++++++------- .../handlers/accounts/account_service.go | 6 +++--- .../handlers/authmethods/authmethod_service.go | 6 +++--- .../handlers/authtokens/authtoken_service.go | 6 +++--- .../credentiallibrary_service.go | 6 +++--- .../handlers/credentials/credential_service.go | 6 +++--- .../credentialstore_service.go | 6 +++--- .../handlers/groups/group_service.go | 6 +++--- .../controller/handlers/health/health.go | 4 +++- .../host_catalogs/host_catalog_service.go | 4 ++-- .../handlers/host_sets/host_set_service.go | 4 ++-- .../controller/handlers/hosts/host_service.go | 4 ++-- .../managed_groups/managed_group_service.go | 6 +++--- .../controller/handlers/roles/role_service.go | 6 +++--- .../handlers/scopes/scope_service.go | 6 +++--- .../handlers/sessions/session_service.go | 6 +++--- .../handlers/targets/target_service.go | 6 +++--- .../controller/handlers/users/user_service.go | 6 +++--- .../handlers/workers/worker_service.go | 6 +++--- internal/daemon/worker/worker_proxy_service.go | 18 +++++++++++------- 21 files changed, 72 insertions(+), 66 deletions(-) diff --git a/internal/daemon/cluster/handlers/multihop_service.go b/internal/daemon/cluster/handlers/multihop_service.go index a5407b4d0..c6b411913 100644 --- a/internal/daemon/cluster/handlers/multihop_service.go +++ b/internal/daemon/cluster/handlers/multihop_service.go @@ -16,7 +16,7 @@ import ( ) type multihopServiceServer struct { - multihop.UnimplementedMultihopServiceServer + multihop.UnsafeMultihopServiceServer storage nodeenrollment.Storage direct bool @@ -24,6 +24,8 @@ type multihopServiceServer struct { options []nodeenrollment.Option } +var _ multihop.MultihopServiceServer = (*multihopServiceServer)(nil) + // NewMultihopServiceServer creates a new service implementing // MultihopServiceServer, storing values used for the implementing functions. func NewMultihopServiceServer(storage nodeenrollment.Storage, direct bool, client *atomic.Value, opt ...nodeenrollment.Option) (*multihopServiceServer, error) { @@ -44,8 +46,6 @@ func NewMultihopServiceServer(storage nodeenrollment.Storage, direct bool, clien }, nil } -var _ multihop.MultihopServiceServer = (*multihopServiceServer)(nil) - // FetchNodeCredentials implements the MultihopServiceServer interface. If it's // direct (e.g. running on a controller) it handles the request directly, // otherwise sends it to its next hop. diff --git a/internal/daemon/cluster/handlers/worker_service.go b/internal/daemon/cluster/handlers/worker_service.go index fbdb60c0d..c486e11a0 100644 --- a/internal/daemon/cluster/handlers/worker_service.go +++ b/internal/daemon/cluster/handlers/worker_service.go @@ -25,8 +25,8 @@ import ( const ManagedWorkerTagKey = "boundary.cloud.hashicorp.com:managed" type workerServiceServer struct { - pbs.UnimplementedServerCoordinationServiceServer - pbs.UnimplementedSessionServiceServer + pbs.UnsafeServerCoordinationServiceServer + pbs.UnsafeSessionServiceServer serversRepoFn common.ServersRepoFactory sessionRepoFn common.SessionRepoFactory @@ -35,6 +35,11 @@ type workerServiceServer struct { kms *kms.Kms } +var ( + _ pbs.SessionServiceServer = &workerServiceServer{} + _ pbs.ServerCoordinationServiceServer = &workerServiceServer{} +) + func NewWorkerServiceServer( serversRepoFn common.ServersRepoFactory, sessionRepoFn common.SessionRepoFactory, @@ -51,11 +56,6 @@ func NewWorkerServiceServer( } } -var ( - _ pbs.SessionServiceServer = &workerServiceServer{} - _ pbs.ServerCoordinationServiceServer = &workerServiceServer{} -) - func (ws *workerServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) { const op = "workers.(workerServiceServer).Status" // TODO: on the worker, if we get errors back from this repeatedly, do we diff --git a/internal/daemon/controller/handlers/accounts/account_service.go b/internal/daemon/controller/handlers/accounts/account_service.go index b82fd955a..2dd60e6e2 100644 --- a/internal/daemon/controller/handlers/accounts/account_service.go +++ b/internal/daemon/controller/handlers/accounts/account_service.go @@ -96,12 +96,14 @@ func init() { // Service handles request as described by the pbs.AccountServiceServer interface. type Service struct { - pbs.UnimplementedAccountServiceServer + pbs.UnsafeAccountServiceServer pwRepoFn common.PasswordAuthRepoFactory oidcRepoFn common.OidcAuthRepoFactory } +var _ pbs.AccountServiceServer = (*Service)(nil) + // NewService returns a account service which handles account related requests to boundary. func NewService(pwRepo common.PasswordAuthRepoFactory, oidcRepo common.OidcAuthRepoFactory) (Service, error) { const op = "accounts.NewService" @@ -114,8 +116,6 @@ func NewService(pwRepo common.PasswordAuthRepoFactory, oidcRepo common.OidcAuthR return Service{pwRepoFn: pwRepo, oidcRepoFn: oidcRepo}, nil } -var _ pbs.AccountServiceServer = Service{} - // ListAccounts implements the interface pbs.AccountServiceServer. func (s Service) ListAccounts(ctx context.Context, req *pbs.ListAccountsRequest) (*pbs.ListAccountsResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/authmethods/authmethod_service.go b/internal/daemon/controller/handlers/authmethods/authmethod_service.go index e708c4ca2..9559e677b 100644 --- a/internal/daemon/controller/handlers/authmethods/authmethod_service.go +++ b/internal/daemon/controller/handlers/authmethods/authmethod_service.go @@ -76,7 +76,7 @@ var ( // Service handles request as described by the pbs.AuthMethodServiceServer interface. type Service struct { - pbs.UnimplementedAuthMethodServiceServer + pbs.UnsafeAuthMethodServiceServer kms *kms.Kms pwRepoFn common.PasswordAuthRepoFactory @@ -85,6 +85,8 @@ type Service struct { atRepoFn common.AuthTokenRepoFactory } +var _ pbs.AuthMethodServiceServer = (*Service)(nil) + // NewService returns a auth method service which handles auth method related requests to boundary. func NewService(kms *kms.Kms, pwRepoFn common.PasswordAuthRepoFactory, oidcRepoFn common.OidcAuthRepoFactory, iamRepoFn common.IamRepoFactory, atRepoFn common.AuthTokenRepoFactory, opt ...handlers.Option) (Service, error) { const op = "authmethods.NewService" @@ -108,8 +110,6 @@ func NewService(kms *kms.Kms, pwRepoFn common.PasswordAuthRepoFactory, oidcRepoF return s, nil } -var _ pbs.AuthMethodServiceServer = Service{} - // ListAuthMethods implements the interface pbs.AuthMethodServiceServer. func (s Service) ListAuthMethods(ctx context.Context, req *pbs.ListAuthMethodsRequest) (*pbs.ListAuthMethodsResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/authtokens/authtoken_service.go b/internal/daemon/controller/handlers/authtokens/authtoken_service.go index 5efdfaa90..be3450e91 100644 --- a/internal/daemon/controller/handlers/authtokens/authtoken_service.go +++ b/internal/daemon/controller/handlers/authtokens/authtoken_service.go @@ -41,12 +41,14 @@ var ( // Service handles request as described by the pbs.AuthTokenServiceServer interface. type Service struct { - pbs.UnimplementedAuthTokenServiceServer + pbs.UnsafeAuthTokenServiceServer repoFn common.AuthTokenRepoFactory iamRepoFn common.IamRepoFactory } +var _ pbs.AuthTokenServiceServer = (*Service)(nil) + // NewService returns a user service which handles user related requests to boundary. func NewService(repo common.AuthTokenRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) { const op = "authtoken.NewService" @@ -59,8 +61,6 @@ func NewService(repo common.AuthTokenRepoFactory, iamRepoFn common.IamRepoFactor return Service{repoFn: repo, iamRepoFn: iamRepoFn}, nil } -var _ pbs.AuthTokenServiceServer = Service{} - // ListAuthTokens implements the interface pbs.AuthTokenServiceServer. func (s Service) ListAuthTokens(ctx context.Context, req *pbs.ListAuthTokensRequest) (*pbs.ListAuthTokensResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/credentiallibraries/credentiallibrary_service.go b/internal/daemon/controller/handlers/credentiallibraries/credentiallibrary_service.go index 09af3371e..362782b22 100644 --- a/internal/daemon/controller/handlers/credentiallibraries/credentiallibrary_service.go +++ b/internal/daemon/controller/handlers/credentiallibraries/credentiallibrary_service.go @@ -74,12 +74,14 @@ func init() { // Service handles request as described by the pbs.CredentialLibraryServiceServer interface. type Service struct { - pbs.UnimplementedCredentialLibraryServiceServer + pbs.UnsafeCredentialLibraryServiceServer iamRepoFn common.IamRepoFactory repoFn common.VaultCredentialRepoFactory } +var _ pbs.CredentialLibraryServiceServer = (*Service)(nil) + // NewService returns a credential library service which handles credential library related requests to boundary. func NewService(repo common.VaultCredentialRepoFactory, iamRepo common.IamRepoFactory) (Service, error) { const op = "credentiallibraries.NewService" @@ -92,8 +94,6 @@ func NewService(repo common.VaultCredentialRepoFactory, iamRepo common.IamRepoFa return Service{iamRepoFn: iamRepo, repoFn: repo}, nil } -var _ pbs.CredentialLibraryServiceServer = Service{} - // ListCredentialLibraries implements the interface pbs.CredentialLibraryServiceServer func (s Service) ListCredentialLibraries(ctx context.Context, req *pbs.ListCredentialLibrariesRequest) (*pbs.ListCredentialLibrariesResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/credentials/credential_service.go b/internal/daemon/controller/handlers/credentials/credential_service.go index dfb6f75e8..0211158f5 100644 --- a/internal/daemon/controller/handlers/credentials/credential_service.go +++ b/internal/daemon/controller/handlers/credentials/credential_service.go @@ -70,12 +70,14 @@ func init() { // Service handles request as described by the pbs.CredentialServiceServer interface. type Service struct { - pbs.UnimplementedCredentialServiceServer + pbs.UnsafeCredentialServiceServer iamRepoFn common.IamRepoFactory repoFn common.StaticCredentialRepoFactory } +var _ pbs.CredentialServiceServer = (*Service)(nil) + // NewService returns a credential service which handles credential related requests to boundary. func NewService(repo common.StaticCredentialRepoFactory, iamRepo common.IamRepoFactory) (Service, error) { const op = "credentials.NewService" @@ -88,8 +90,6 @@ func NewService(repo common.StaticCredentialRepoFactory, iamRepo common.IamRepoF return Service{iamRepoFn: iamRepo, repoFn: repo}, nil } -var _ pbs.CredentialServiceServer = Service{} - // ListCredentials implements the interface pbs.CredentialServiceServer func (s Service) ListCredentials(ctx context.Context, req *pbs.ListCredentialsRequest) (*pbs.ListCredentialsResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/credentialstores/credentialstore_service.go b/internal/daemon/controller/handlers/credentialstores/credentialstore_service.go index ffd766037..9052ea117 100644 --- a/internal/daemon/controller/handlers/credentialstores/credentialstore_service.go +++ b/internal/daemon/controller/handlers/credentialstores/credentialstore_service.go @@ -85,13 +85,15 @@ func init() { // Service handles request as described by the pbs.CredentialStoreServiceServer interface. type Service struct { - pbs.UnimplementedCredentialStoreServiceServer + pbs.UnsafeCredentialStoreServiceServer iamRepoFn common.IamRepoFactory vaultRepoFn common.VaultCredentialRepoFactory staticRepoFn common.StaticCredentialRepoFactory } +var _ pbs.CredentialStoreServiceServer = (*Service)(nil) + // NewService returns a credential store service which handles credential store related requests to boundary. func NewService( ctx context.Context, @@ -112,8 +114,6 @@ func NewService( return Service{iamRepoFn: iamRepo, vaultRepoFn: vaultRepo, staticRepoFn: staticRepo}, nil } -var _ pbs.CredentialStoreServiceServer = Service{} - // ListCredentialStores implements the interface pbs.CredentialStoreServiceServer func (s Service) ListCredentialStores(ctx context.Context, req *pbs.ListCredentialStoresRequest) (*pbs.ListCredentialStoresResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/groups/group_service.go b/internal/daemon/controller/handlers/groups/group_service.go index 250bfd123..d51a7c3f8 100644 --- a/internal/daemon/controller/handlers/groups/group_service.go +++ b/internal/daemon/controller/handlers/groups/group_service.go @@ -56,11 +56,13 @@ func init() { // Service handles request as described by the pbs.GroupServiceServer interface. type Service struct { - pbs.UnimplementedGroupServiceServer + pbs.UnsafeGroupServiceServer repoFn common.IamRepoFactory } +var _ pbs.GroupServiceServer = (*Service)(nil) + // NewService returns a group service which handles group related requests to boundary. func NewService(repo common.IamRepoFactory) (Service, error) { const op = "groups.NewService" @@ -70,8 +72,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) { return Service{repoFn: repo}, nil } -var _ pbs.GroupServiceServer = Service{} - // ListGroups implements the interface pbs.GroupServiceServer. func (s Service) ListGroups(ctx context.Context, req *pbs.ListGroupsRequest) (*pbs.ListGroupsResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/health/health.go b/internal/daemon/controller/handlers/health/health.go index 70fbc6eca..8c2309eec 100644 --- a/internal/daemon/controller/handlers/health/health.go +++ b/internal/daemon/controller/handlers/health/health.go @@ -9,11 +9,13 @@ import ( ) type Service struct { - pbs.UnimplementedHealthServiceServer + pbs.UnsafeHealthServiceServer replyWithServiceUnavailable bool } +var _ pbs.HealthServiceServer = (*Service)(nil) + func NewService() *Service { s := Service{} return &s diff --git a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go index f4c827707..840fcde1c 100644 --- a/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go +++ b/internal/daemon/controller/handlers/host_catalogs/host_catalog_service.go @@ -81,7 +81,7 @@ func init() { } type Service struct { - pbs.UnimplementedHostCatalogServiceServer + pbs.UnsafeHostCatalogServiceServer staticRepoFn common.StaticRepoFactory pluginHostRepoFn common.PluginHostRepoFactory @@ -89,7 +89,7 @@ type Service struct { iamRepoFn common.IamRepoFactory } -var _ pbs.HostCatalogServiceServer = Service{} +var _ pbs.HostCatalogServiceServer = (*Service)(nil) // NewService returns a host catalog Service which handles host catalog related requests to boundary and uses the provided // repositories for storage and retrieval. diff --git a/internal/daemon/controller/handlers/host_sets/host_set_service.go b/internal/daemon/controller/handlers/host_sets/host_set_service.go index 8a7e94191..b3235c7ca 100644 --- a/internal/daemon/controller/handlers/host_sets/host_set_service.go +++ b/internal/daemon/controller/handlers/host_sets/host_set_service.go @@ -75,13 +75,13 @@ func init() { } type Service struct { - pbs.UnimplementedHostSetServiceServer + pbs.UnsafeHostSetServiceServer staticRepoFn common.StaticRepoFactory pluginRepoFn common.PluginHostRepoFactory } -var _ pbs.HostSetServiceServer = Service{} +var _ pbs.HostSetServiceServer = (*Service)(nil) // NewService returns a host set Service which handles host set related requests to boundary and uses the provided // repositories for storage and retrieval. diff --git a/internal/daemon/controller/handlers/hosts/host_service.go b/internal/daemon/controller/handlers/hosts/host_service.go index 4c9ac35d7..f1799ac03 100644 --- a/internal/daemon/controller/handlers/hosts/host_service.go +++ b/internal/daemon/controller/handlers/hosts/host_service.go @@ -64,13 +64,13 @@ func init() { } type Service struct { - pbs.UnimplementedHostServiceServer + pbs.UnsafeHostServiceServer staticRepoFn common.StaticRepoFactory pluginRepoFn common.PluginHostRepoFactory } -var _ pbs.HostServiceServer = Service{} +var _ pbs.HostServiceServer = (*Service)(nil) // NewService returns a host Service which handles host related requests to boundary and uses the provided // repositories for storage and retrieval. diff --git a/internal/daemon/controller/handlers/managed_groups/managed_group_service.go b/internal/daemon/controller/handlers/managed_groups/managed_group_service.go index 15e02b3f4..0d99124c6 100644 --- a/internal/daemon/controller/handlers/managed_groups/managed_group_service.go +++ b/internal/daemon/controller/handlers/managed_groups/managed_group_service.go @@ -63,11 +63,13 @@ func init() { // Service handles request as described by the pbs.ManagedGroupServiceServer interface. type Service struct { - pbs.UnimplementedManagedGroupServiceServer + pbs.UnsafeManagedGroupServiceServer oidcRepoFn common.OidcAuthRepoFactory } +var _ pbs.ManagedGroupServiceServer = (*Service)(nil) + // NewService returns a managed group service which handles managed group related requests to boundary. func NewService(oidcRepo common.OidcAuthRepoFactory) (Service, error) { const op = "managed_groups.NewService" @@ -77,8 +79,6 @@ func NewService(oidcRepo common.OidcAuthRepoFactory) (Service, error) { return Service{oidcRepoFn: oidcRepo}, nil } -var _ pbs.ManagedGroupServiceServer = Service{} - // ListManagedGroups implements the interface pbs.ManagedGroupsServiceServer. func (s Service) ListManagedGroups(ctx context.Context, req *pbs.ListManagedGroupsRequest) (*pbs.ListManagedGroupsResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/roles/role_service.go b/internal/daemon/controller/handlers/roles/role_service.go index 7a35a521b..6134fd0d3 100644 --- a/internal/daemon/controller/handlers/roles/role_service.go +++ b/internal/daemon/controller/handlers/roles/role_service.go @@ -60,11 +60,13 @@ func init() { // Service handles request as described by the pbs.RoleServiceServer interface. type Service struct { - pbs.UnimplementedRoleServiceServer + pbs.UnsafeRoleServiceServer repoFn common.IamRepoFactory } +var _ pbs.RoleServiceServer = (*Service)(nil) + // NewService returns a role service which handles role related requests to boundary. func NewService(repo common.IamRepoFactory) (Service, error) { const op = "roles.NewService" @@ -74,8 +76,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) { return Service{repoFn: repo}, nil } -var _ pbs.RoleServiceServer = Service{} - // ListRoles implements the interface pbs.RoleServiceServer. func (s Service) ListRoles(ctx context.Context, req *pbs.ListRolesRequest) (*pbs.ListRolesResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/scopes/scope_service.go b/internal/daemon/controller/handlers/scopes/scope_service.go index 25a23e8e1..e1e8a1d17 100644 --- a/internal/daemon/controller/handlers/scopes/scope_service.go +++ b/internal/daemon/controller/handlers/scopes/scope_service.go @@ -96,11 +96,13 @@ func init() { // Service handles requests as described by the pbs.ScopeServiceServer interface. type Service struct { - pbs.UnimplementedScopeServiceServer + pbs.UnsafeScopeServiceServer repoFn common.IamRepoFactory } +var _ pbs.ScopeServiceServer = (*Service)(nil) + // NewService returns a project service which handles project related requests to boundary. func NewService(repo common.IamRepoFactory) (Service, error) { const op = "scopes.(Service).NewService" @@ -110,8 +112,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) { return Service{repoFn: repo}, nil } -var _ pbs.ScopeServiceServer = Service{} - // ListScopes implements the interface pbs.ScopeServiceServer. func (s Service) ListScopes(ctx context.Context, req *pbs.ListScopesRequest) (*pbs.ListScopesResponse, error) { if req.GetScopeId() == "" { diff --git a/internal/daemon/controller/handlers/sessions/session_service.go b/internal/daemon/controller/handlers/sessions/session_service.go index 99642f7a3..b8e530f5b 100644 --- a/internal/daemon/controller/handlers/sessions/session_service.go +++ b/internal/daemon/controller/handlers/sessions/session_service.go @@ -43,12 +43,14 @@ var ( // Service handles request as described by the pbs.SessionServiceServer interface. type Service struct { - pbs.UnimplementedSessionServiceServer + pbs.UnsafeSessionServiceServer repoFn common.SessionRepoFactory iamRepoFn common.IamRepoFactory } +var _ pbs.SessionServiceServer = (*Service)(nil) + // NewService returns a session service which handles session related requests to boundary. func NewService(repoFn common.SessionRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) { const op = "sessions.NewService" @@ -61,8 +63,6 @@ func NewService(repoFn common.SessionRepoFactory, iamRepoFn common.IamRepoFactor return Service{repoFn: repoFn, iamRepoFn: iamRepoFn}, nil } -var _ pbs.SessionServiceServer = Service{} - // GetSessions implements the interface pbs.SessionServiceServer. func (s Service) GetSession(ctx context.Context, req *pbs.GetSessionRequest) (*pbs.GetSessionResponse, error) { const op = "sessions.(Service).GetSession" diff --git a/internal/daemon/controller/handlers/targets/target_service.go b/internal/daemon/controller/handlers/targets/target_service.go index 15632a47f..2db701764 100644 --- a/internal/daemon/controller/handlers/targets/target_service.go +++ b/internal/daemon/controller/handlers/targets/target_service.go @@ -96,7 +96,7 @@ var ( // Service handles request as described by the pbs.TargetServiceServer interface. type Service struct { - pbs.UnimplementedTargetServiceServer + pbs.UnsafeTargetServiceServer repoFn common.TargetRepoFactory iamRepoFn common.IamRepoFactory @@ -109,6 +109,8 @@ type Service struct { kmsCache *kms.Kms } +var _ pbs.TargetServiceServer = (*Service)(nil) + // NewService returns a target service which handles target related requests to boundary. func NewService( ctx context.Context, @@ -160,8 +162,6 @@ func NewService( }, nil } -var _ pbs.TargetServiceServer = Service{} - // ListTargets implements the interface pbs.TargetServiceServer. func (s Service) ListTargets(ctx context.Context, req *pbs.ListTargetsRequest) (*pbs.ListTargetsResponse, error) { const op = "targets.(Service).ListSessions" diff --git a/internal/daemon/controller/handlers/users/user_service.go b/internal/daemon/controller/handlers/users/user_service.go index 526566c6e..ce8c71f28 100644 --- a/internal/daemon/controller/handlers/users/user_service.go +++ b/internal/daemon/controller/handlers/users/user_service.go @@ -58,11 +58,13 @@ func init() { // Service handles request as described by the pbs.UserServiceServer interface. type Service struct { - pbs.UnimplementedUserServiceServer + pbs.UnsafeUserServiceServer repoFn common.IamRepoFactory } +var _ pbs.UserServiceServer = (*Service)(nil) + // NewService returns a user service which handles user related requests to boundary. func NewService(repo common.IamRepoFactory) (Service, error) { const op = "users.NewService" @@ -72,8 +74,6 @@ func NewService(repo common.IamRepoFactory) (Service, error) { return Service{repoFn: repo}, nil } -var _ pbs.UserServiceServer = Service{} - // ListUsers implements the interface pbs.UserServiceServer. func (s Service) ListUsers(ctx context.Context, req *pbs.ListUsersRequest) (*pbs.ListUsersResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/controller/handlers/workers/worker_service.go b/internal/daemon/controller/handlers/workers/worker_service.go index f43657b24..9eb06ba33 100644 --- a/internal/daemon/controller/handlers/workers/worker_service.go +++ b/internal/daemon/controller/handlers/workers/worker_service.go @@ -66,12 +66,14 @@ func init() { // Service handles request as described by the pbs.WorkerServiceServer interface. type Service struct { - pbs.UnimplementedWorkerServiceServer + pbs.UnsafeWorkerServiceServer repoFn common.ServersRepoFactory iamRepoFn common.IamRepoFactory } +var _ pbs.WorkerServiceServer = (*Service)(nil) + // NewService returns a worker service which handles worker related requests to boundary. func NewService(ctx context.Context, repo common.ServersRepoFactory, iamRepoFn common.IamRepoFactory) (Service, error) { const op = "workers.NewService" @@ -84,8 +86,6 @@ func NewService(ctx context.Context, repo common.ServersRepoFactory, iamRepoFn c return Service{repoFn: repo, iamRepoFn: iamRepoFn}, nil } -var _ pbs.WorkerServiceServer = Service{} - // ListWorkers implements the interface pbs.WorkerServiceServer. func (s Service) ListWorkers(ctx context.Context, req *pbs.ListWorkersRequest) (*pbs.ListWorkersResponse, error) { if err := validateListRequest(req); err != nil { diff --git a/internal/daemon/worker/worker_proxy_service.go b/internal/daemon/worker/worker_proxy_service.go index 854bdcb60..4a737c2e6 100644 --- a/internal/daemon/worker/worker_proxy_service.go +++ b/internal/daemon/worker/worker_proxy_service.go @@ -9,13 +9,18 @@ import ( ) type workerProxyServiceServer struct { - pbs.UnimplementedServerCoordinationServiceServer - pbs.UnimplementedSessionServiceServer + pbs.UnsafeServerCoordinationServiceServer + pbs.UnsafeSessionServiceServer scsClient *atomic.Value ssClient pbs.SessionServiceClient } +var ( + _ pbs.ServerCoordinationServiceServer = (*workerProxyServiceServer)(nil) + _ pbs.SessionServiceServer = (*workerProxyServiceServer)(nil) +) + func NewWorkerProxyServiceServer( cc *grpc.ClientConn, scsClient *atomic.Value, @@ -26,11 +31,6 @@ func NewWorkerProxyServiceServer( } } -var ( - _ pbs.ServerCoordinationServiceServer = &workerProxyServiceServer{} - _ pbs.SessionServiceServer = &workerProxyServiceServer{} -) - func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusRequest) (*pbs.StatusResponse, error) { resp, err := ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).Status(ctx, req) @@ -43,6 +43,10 @@ func (ws *workerProxyServiceServer) Status(ctx context.Context, req *pbs.StatusR return resp, err } +func (ws *workerProxyServiceServer) ListHcpbWorkers(ctx context.Context, req *pbs.ListHcpbWorkersRequest) (*pbs.ListHcpbWorkersResponse, error) { + return ws.scsClient.Load().(pbs.ServerCoordinationServiceClient).ListHcpbWorkers(ctx, req) +} + func (ws *workerProxyServiceServer) LookupSession(ctx context.Context, req *pbs.LookupSessionRequest) (*pbs.LookupSessionResponse, error) { return ws.ssClient.LookupSession(ctx, req) }