Add generic read/update/delete commands (#3992)
* Add generic read/update/delete commands This adds three generic commands that use the resource prefix to determine the subcommand to run and pass through args over to that subcommand. Since this occurs very early on and to avoid loading essentially every internal resource package, I moved subtype definitions to globals. This replaces #3967 Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> * De-duplicate Subtype code (#4031) Co-authored-by: Timothy Messier <tim.messier@gmail.com> --------- Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Co-authored-by: Timothy Messier <tim.messier@gmail.com>
This commit is contained in:
59 files changed
+1032
-857
No files matched your search
@@ -31,7 +31,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/resource"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
"github.com/hashicorp/boundary/internal/util"
|
||||
"github.com/hashicorp/boundary/internal/util/template"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -555,7 +554,7 @@ func (v verifier) performAuthCheck(ctx context.Context) (
|
||||
const domain = "auth"
|
||||
var acct auth.Account
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, *userData.Account.Id) {
|
||||
switch globals.ResourceInfoFromPrefix(*userData.Account.Id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, repoErr := v.passwordAuthRepoFn()
|
||||
if repoErr != nil {
|
||||
|
||||
@@ -69,7 +69,7 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = map[subtypes.Subtype]action.ActionSet{
|
||||
IdActions = map[globals.Subtype]action.ActionSet{
|
||||
password.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
@@ -165,7 +165,7 @@ func (s Service) ListAccounts(ctx context.Context, req *pbs.ListAccountsRequest)
|
||||
}
|
||||
for _, acct := range ul {
|
||||
res.Id = acct.GetPublicId()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())], requestauth.WithResource(&res)).Strings()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype], requestauth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func (s Service) GetAccount(ctx context.Context, req *pbs.GetAccountRequest) (*p
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.ManagedGroupIdsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithManagedGroupIds(mgIds))
|
||||
@@ -268,7 +268,7 @@ func (s Service) CreateAccount(ctx context.Context, req *pbs.CreateAccountReques
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, acct, outputOpts...)
|
||||
@@ -307,7 +307,7 @@ func (s Service) UpdateAccount(ctx context.Context, req *pbs.UpdateAccountReques
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, acct, outputOpts...)
|
||||
@@ -362,7 +362,7 @@ func (s Service) ChangePassword(ctx context.Context, req *pbs.ChangePasswordRequ
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, acct, outputOpts...)
|
||||
@@ -401,7 +401,7 @@ func (s Service) SetPassword(ctx context.Context, req *pbs.SetPasswordRequest) (
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, acct.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, acct.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(acct.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, acct, outputOpts...)
|
||||
@@ -417,7 +417,7 @@ func (s Service) SetPassword(ctx context.Context, req *pbs.SetPasswordRequest) (
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (auth.Account, []string, error) {
|
||||
var acct auth.Account
|
||||
var mgIds []string
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
@@ -592,7 +592,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing item")
|
||||
}
|
||||
var out auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, am.GetPublicId()) {
|
||||
switch globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype {
|
||||
case password.Subtype:
|
||||
am, err := s.createPwInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
@@ -752,7 +752,7 @@ func (s Service) updateLdapInRepo(ctx context.Context, scopeId, amId, id string,
|
||||
func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string, req *pbs.UpdateAccountRequest) (auth.Account, error) {
|
||||
const op = "accounts.(Service).updateInRepo"
|
||||
var out auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case password.Subtype:
|
||||
a, err := s.updatePwInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
@@ -788,7 +788,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
const op = "accounts.(Service).deleteFromRepo"
|
||||
var rows int
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, iErr := s.pwRepoFn()
|
||||
if iErr != nil {
|
||||
@@ -821,7 +821,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
const op = "accounts.(Service).listFromRepo"
|
||||
|
||||
var outUl []auth.Account
|
||||
switch subtypes.SubtypeFromId(domain, authMethodId) {
|
||||
switch globals.ResourceInfoFromPrefix(authMethodId).Subtype {
|
||||
case password.Subtype:
|
||||
pwRepo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
@@ -933,7 +933,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
case action.List, action.Create:
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
acct, err := pwRepo.LookupAccount(ctx, id)
|
||||
if err != nil {
|
||||
@@ -972,7 +972,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
}
|
||||
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
switch globals.ResourceInfoFromPrefix(parentId).Subtype {
|
||||
case password.Subtype:
|
||||
am, err := pwRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
@@ -1174,7 +1174,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAccountRequest) e
|
||||
if req.GetItem().GetAuthMethodId() == "" {
|
||||
badFields[authMethodIdField] = "This field is required."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetAuthMethodId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetItem().GetAuthMethodId()).Subtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != password.Subtype.String() {
|
||||
badFields[typeField] = "Doesn't match the parent resource's type."
|
||||
@@ -1255,7 +1255,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAccountRequest) e
|
||||
}
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != password.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/kms"
|
||||
"github.com/hashicorp/boundary/internal/types/action"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/accounts"
|
||||
scopepb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -280,7 +279,7 @@ func TestGet(t *testing.T) {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
|
||||
if subtypes.SubtypeFromId(domain, tc.req.Id) == oidc.Subtype {
|
||||
if globals.ResourceInfoFromPrefix(tc.req.Id).Subtype == oidc.Subtype {
|
||||
// Set up managed groups before getting. First get the current
|
||||
// managed group to make sure we have the right version.
|
||||
oidcRepo, err := oidcRepoFn()
|
||||
|
||||
@@ -64,7 +64,7 @@ const (
|
||||
var (
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = make(map[subtypes.Subtype]action.ActionSet)
|
||||
IdActions = make(map[globals.Subtype]action.ActionSet)
|
||||
|
||||
// CollectionActions contains the set of actions that can be performed on
|
||||
// this collection
|
||||
@@ -167,7 +167,7 @@ func (s Service) ListAuthMethods(ctx context.Context, req *pbs.ListAuthMethodsRe
|
||||
for _, am := range ul {
|
||||
res.Id = am.GetPublicId()
|
||||
res.ScopeId = am.GetScopeId()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, am.GetPublicId())], requestauth.WithResource(&res)).Strings()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype], requestauth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -234,7 +234,7 @@ func (s Service) GetAuthMethod(ctx context.Context, req *pbs.GetAuthMethodReques
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, am.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
@@ -279,7 +279,7 @@ func (s Service) CreateAuthMethod(ctx context.Context, req *pbs.CreateAuthMethod
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, am.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
@@ -329,7 +329,7 @@ func (s Service) UpdateAuthMethod(ctx context.Context, req *pbs.UpdateAuthMethod
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, am.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
@@ -383,7 +383,7 @@ func (s Service) ChangeState(ctx context.Context, req *pbs.ChangeStateRequest) (
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, am.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, am.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
collectionActions, err := requestauth.CalculateAuthorizedCollectionActions(ctx, authResults, collectionTypeMap, authResults.Scope.Id, am.GetPublicId())
|
||||
@@ -424,7 +424,7 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetAuthMethodId()).Subtype {
|
||||
case password.Subtype:
|
||||
if err := validateAuthenticatePasswordRequest(req); err != nil {
|
||||
return nil, err
|
||||
@@ -444,7 +444,7 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
return nil, authResults.Error
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetAuthMethodId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetAuthMethodId()).Subtype {
|
||||
case password.Subtype:
|
||||
return s.authenticatePassword(ctx, req, &authResults)
|
||||
|
||||
@@ -459,7 +459,7 @@ func (s Service) Authenticate(ctx context.Context, req *pbs.AuthenticateRequest)
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (auth.AuthMethod, error) {
|
||||
var lookupErr error
|
||||
var am auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
@@ -549,8 +549,8 @@ func (s Service) listFromRepo(ctx context.Context, scopeIds []string, authResult
|
||||
func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.AuthMethod) (auth.AuthMethod, error) {
|
||||
const op = "authmethods.(Service).createInRepo"
|
||||
var out auth.AuthMethod
|
||||
switch subtypes.SubtypeFromType(domain, item.GetType()) {
|
||||
case password.Subtype:
|
||||
switch item.GetType() {
|
||||
case password.Subtype.String():
|
||||
am, err := s.createPwInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -559,7 +559,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case oidc.Subtype:
|
||||
case oidc.Subtype.String():
|
||||
am, err := s.createOidcInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -568,7 +568,7 @@ func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.Auth
|
||||
return nil, handlers.ApiErrorWithCodeAndMessage(codes.Internal, "Unable to create auth method but no error returned from repository.")
|
||||
}
|
||||
out = am
|
||||
case ldap.Subtype:
|
||||
case ldap.Subtype.String():
|
||||
am, err := s.createLdapInRepo(ctx, scopeId, item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -587,7 +587,7 @@ func (s Service) updateInRepo(ctx context.Context, scopeId string, req *pbs.Upda
|
||||
var am auth.AuthMethod
|
||||
var dryRun bool
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case password.Subtype:
|
||||
pam, err := s.updatePwInRepo(ctx, scopeId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
@@ -635,7 +635,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
const op = "authmethods.(Service).deleteFromRepo"
|
||||
var rows int
|
||||
var dErr error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
@@ -656,7 +656,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
}
|
||||
rows, dErr = repo.DeleteAuthMethod(ctx, id)
|
||||
default:
|
||||
return false, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid auth method subtype: %q", subtypes.SubtypeFromId(domain, id)))
|
||||
return false, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid auth method subtype: %q", globals.ResourceInfoFromPrefix(id).Subtype.String()))
|
||||
}
|
||||
|
||||
if dErr != nil {
|
||||
@@ -672,7 +672,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
func (s Service) changeStateInRepo(ctx context.Context, req *pbs.ChangeStateRequest) (auth.AuthMethod, error) {
|
||||
const op = "authmethod_service.(Service).changeStateInRepo"
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
@@ -731,7 +731,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) reque
|
||||
}
|
||||
default:
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case password.Subtype:
|
||||
repo, err := s.pwRepoFn()
|
||||
if err != nil {
|
||||
@@ -987,10 +987,10 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
if req.GetItem().GetIsPrimary() {
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case password.Subtype:
|
||||
switch req.GetItem().GetType() {
|
||||
case password.Subtype.String():
|
||||
// Password attributes are not required when creating a password auth method.
|
||||
case oidc.Subtype:
|
||||
case oidc.Subtype.String():
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
if attrs == nil {
|
||||
// OIDC attributes are required when creating an OIDC auth method.
|
||||
@@ -1066,7 +1066,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
case ldap.Subtype:
|
||||
case ldap.Subtype.String():
|
||||
if len(req.GetItem().GetLdapAuthMethodsAttributes().GetUrls()) == 0 {
|
||||
badFields[urlsField] = "At least one URL is required"
|
||||
}
|
||||
@@ -1088,13 +1088,13 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), isPrimaryField) {
|
||||
badFields[isPrimaryField] = "This field is read only."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case password.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != password.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != password.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != oidc.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetOidcAuthMethodsAttributes()
|
||||
@@ -1198,7 +1198,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateAuthMethodRequest
|
||||
}
|
||||
}
|
||||
case ldap.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != ldap.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != ldap.Subtype.String() {
|
||||
badFields[typeField] = "Cannot modify the resource type."
|
||||
}
|
||||
validateLdapAttributes(ctx, req.GetItem().GetLdapAuthMethodsAttributes(), badFields)
|
||||
@@ -1241,7 +1241,7 @@ func validateChangeStateRequest(ctx context.Context, req *pbs.ChangeStateRequest
|
||||
if req == nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "Missing request")
|
||||
}
|
||||
if st := subtypes.SubtypeFromId(domain, req.GetId()); st != oidc.Subtype {
|
||||
if st := globals.ResourceInfoFromPrefix(req.GetId()).Subtype; st != oidc.Subtype {
|
||||
return handlers.NotFoundErrorf("This endpoint is only available for the %q Auth Method type.", oidc.Subtype.String())
|
||||
}
|
||||
badFields := make(map[string]string)
|
||||
@@ -1276,7 +1276,7 @@ func validateAuthenticateRequest(ctx context.Context, req *pbs.AuthenticateReque
|
||||
if strings.TrimSpace(req.GetAuthMethodId()) == "" {
|
||||
badFields[authMethodIdField] = "This is a required field."
|
||||
} else {
|
||||
st := subtypes.SubtypeFromId(domain, req.GetAuthMethodId())
|
||||
st := globals.ResourceInfoFromPrefix(req.GetAuthMethodId()).Subtype
|
||||
switch st {
|
||||
case password.Subtype, oidc.Subtype, ldap.Subtype:
|
||||
default:
|
||||
@@ -1380,7 +1380,7 @@ func transformAuthenticateRequestAttributes(msg proto.Message) error {
|
||||
if attrs == nil {
|
||||
return nil
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, authRequest.GetAuthMethodId()) {
|
||||
switch globals.ResourceInfoFromPrefix(authRequest.GetAuthMethodId()).Subtype {
|
||||
case password.Subtype:
|
||||
newAttrs := &pbs.PasswordLoginAttributes{}
|
||||
if err := handlers.StructToProto(attrs, newAttrs); err != nil {
|
||||
|
||||
+21
-21
@@ -277,7 +277,7 @@ func (s Service) UpdateCredentialLibrary(ctx context.Context, req *pbs.UpdateCre
|
||||
}
|
||||
var currentCredentialType globals.CredentialType
|
||||
var mo vault.MappingOverride
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
cur, err := repo.LookupSSHCertificateCredentialLibrary(ctx, req.Id)
|
||||
if err != nil {
|
||||
@@ -374,7 +374,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Library
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.GenericLibrarySubtype:
|
||||
cs, err := repo.LookupCredentialLibrary(ctx, id)
|
||||
if err != nil && !errors.IsNotFoundError(err) {
|
||||
@@ -400,8 +400,8 @@ func (s Service) getFromRepo(ctx context.Context, id string) (credential.Library
|
||||
func (s Service) createInRepo(ctx context.Context, scopeId string, item *pb.CredentialLibrary) (credential.Library, error) {
|
||||
const op = "credentiallibraries.(Service).createInRepo"
|
||||
var out credential.Library
|
||||
switch subtypes.SubtypeFromType(domain, item.GetType()) {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
switch item.GetType() {
|
||||
case vault.SSHCertificateLibrarySubtype.String():
|
||||
cl, err := toStorageVaultSSHCertificateLibrary(ctx, item.GetCredentialStoreId(), item)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
@@ -470,7 +470,7 @@ func (s Service) updateInRepo(
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
dbMasks = append(dbMasks, sshCertMaskManager.Translate(masks)...)
|
||||
if getMapUpdate(criticalOptionsField, masks) {
|
||||
@@ -522,7 +522,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
return false, err
|
||||
}
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
rows, err = repo.DeleteSSHCertificateCredentialLibrary(ctx, scopeId, id)
|
||||
default:
|
||||
@@ -554,7 +554,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
default:
|
||||
opts = append(opts, auth.WithId(id))
|
||||
parentId = id
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.GenericLibrarySubtype:
|
||||
cl, err := repo.LookupCredentialLibrary(ctx, id)
|
||||
if err != nil {
|
||||
@@ -590,7 +590,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
|
||||
opts = append(opts, auth.WithPin(parentId))
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
switch globals.ResourceInfoFromPrefix(parentId).Subtype {
|
||||
case vault.Subtype:
|
||||
cs, err := repo.LookupCredentialStore(ctx, parentId)
|
||||
if err != nil {
|
||||
@@ -627,7 +627,7 @@ func toProto(ctx context.Context, in credential.Library, opt ...handlers.Option)
|
||||
out.CredentialStoreId = in.GetStoreId()
|
||||
}
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = subtypes.SubtypeFromId(domain, in.GetPublicId()).String()
|
||||
out.Type = globals.ResourceInfoFromPrefix(in.GetPublicId()).Subtype.String()
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
out.Description = wrapperspb.String(in.GetDescription())
|
||||
@@ -650,7 +650,7 @@ func toProto(ctx context.Context, in credential.Library, opt ...handlers.Option)
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
out.AuthorizedActions = opts.WithAuthorizedActions
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, in.GetPublicId()) {
|
||||
switch globals.ResourceInfoFromPrefix(in.GetPublicId()).Subtype {
|
||||
case vault.GenericLibrarySubtype:
|
||||
vaultIn, ok := in.(*vault.CredentialLibrary)
|
||||
if !ok {
|
||||
@@ -879,7 +879,7 @@ func toStorageVaultSSHCertificateLibrary(ctx context.Context, storeId string, in
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetCredentialLibraryRequest) error {
|
||||
prefix := ""
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
prefix = globals.VaultSshCertificateCredentialLibraryPrefix
|
||||
default:
|
||||
@@ -891,7 +891,7 @@ func validateGetRequest(req *pbs.GetCredentialLibraryRequest) error {
|
||||
func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
return handlers.ValidateCreateRequest(req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetCredentialStoreId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetItem().GetCredentialStoreId()).Subtype {
|
||||
case vault.Subtype:
|
||||
var t string
|
||||
if version.SupportsFeature(version.Binary, version.CredentialLibraryVaultSubtype) {
|
||||
@@ -901,7 +901,7 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
// subtype of vault-generic based on the credential store's subtype.
|
||||
// To support the deprecated subtype 'vault.Subtype', convert it
|
||||
// to vault-generic.
|
||||
if t == "" || subtypes.SubtypeFromType(domain, t) == vault.Subtype {
|
||||
if t == "" || t == vault.Subtype.String() {
|
||||
// fallback to assuming subtype from credential store.
|
||||
t = vault.GenericLibrarySubtype.String()
|
||||
req.GetItem().Type = t
|
||||
@@ -927,13 +927,13 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
}
|
||||
}
|
||||
|
||||
if subtypes.SubtypeFromType(domain, t) != vault.GenericLibrarySubtype &&
|
||||
subtypes.SubtypeFromType(domain, t) != vault.SSHCertificateLibrarySubtype {
|
||||
if t != vault.GenericLibrarySubtype.String() &&
|
||||
t != vault.SSHCertificateLibrarySubtype.String() {
|
||||
badFields[globals.CredentialStoreIdField] = fmt.Sprintf("Type must be a vault subtype %q or %q", vault.GenericLibrarySubtype.String(), vault.SSHCertificateLibrarySubtype.String())
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case vault.GenericLibrarySubtype:
|
||||
switch req.GetItem().GetType() {
|
||||
case vault.GenericLibrarySubtype.String():
|
||||
isValidCred := false
|
||||
ct := req.GetItem().GetCredentialType()
|
||||
for _, t := range validCredentialTypesVaultGeneric {
|
||||
@@ -964,7 +964,7 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
badFields[httpRequestBodyField] = fmt.Sprintf("Field can only be set if %q is set to the value 'POST'.", httpMethodField)
|
||||
}
|
||||
validateMapping(badFields, globals.CredentialType(req.GetItem().GetCredentialType()), req.GetItem().CredentialMappingOverrides.AsMap())
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
case vault.SSHCertificateLibrarySubtype.String():
|
||||
if req.GetItem().GetCredentialType() != "" {
|
||||
badFields[globals.CredentialTypeField] = fmt.Sprintf("This field is read only and cannot be set.")
|
||||
}
|
||||
@@ -1001,7 +1001,7 @@ func validateCreateRequest(req *pbs.CreateCredentialLibraryRequest) error {
|
||||
|
||||
func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCredentialType globals.CredentialType) error {
|
||||
prefix := ""
|
||||
st := subtypes.SubtypeFromId(domain, req.GetId())
|
||||
st := globals.ResourceInfoFromPrefix(req.GetId()).Subtype
|
||||
switch st {
|
||||
case vault.GenericLibrarySubtype:
|
||||
prefix = globals.VaultCredentialLibraryPrefix
|
||||
@@ -1012,7 +1012,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
badFields := map[string]string{}
|
||||
switch st {
|
||||
case vault.GenericLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.GenericLibrarySubtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != vault.GenericLibrarySubtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetCredentialType() != "" && req.GetItem().GetCredentialType() != string(currentCredentialType) {
|
||||
@@ -1036,7 +1036,7 @@ func validateUpdateRequest(req *pbs.UpdateCredentialLibraryRequest, currentCrede
|
||||
validateMapping(badFields, currentCredentialType, req.GetItem().CredentialMappingOverrides.AsMap())
|
||||
}
|
||||
case vault.SSHCertificateLibrarySubtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.SSHCertificateLibrarySubtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != vault.SSHCertificateLibrarySubtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetCredentialType() != "" && req.GetItem().GetCredentialType() != string(currentCredentialType) {
|
||||
|
||||
@@ -413,7 +413,7 @@ func (s Service) updateInRepo(
|
||||
var dbMasks []string
|
||||
item := proto.Clone(in).(*pb.Credential)
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case credential.UsernamePasswordSubtype:
|
||||
dbMasks = append(dbMasks, upMaskManager.Translate(masks)...)
|
||||
if len(dbMasks) == 0 {
|
||||
@@ -808,7 +808,7 @@ func validateCreateRequest(req *pbs.CreateCredentialRequest) error {
|
||||
func validateUpdateRequest(req *pbs.UpdateCredentialRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case credential.UsernamePasswordSubtype:
|
||||
attrs := req.GetItem().GetUsernamePasswordAttributes()
|
||||
if handlers.MaskContains(req.GetUpdateMask().GetPaths(), usernameField) && attrs.GetUsername().GetValue() == "" {
|
||||
|
||||
@@ -394,7 +394,7 @@ func (s Service) listFromRepo(ctx context.Context, scopeIds []string) ([]credent
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (credential.Store, error) {
|
||||
const op = "credentialstores.(Service).getFromRepo"
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.Subtype:
|
||||
repo, err := s.vaultRepoFn()
|
||||
if err != nil {
|
||||
@@ -475,7 +475,7 @@ func (s Service) updateInRepo(ctx context.Context, projId, id string, mask []str
|
||||
return nil, handlers.InvalidArgumentErrorf("No valid fields included in the update mask.", map[string]string{"update_mask": "No valid fields provided in the update mask."})
|
||||
}
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.Subtype:
|
||||
cs, err := toStorageVaultStore(ctx, projId, item)
|
||||
if err != nil {
|
||||
@@ -518,7 +518,7 @@ func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
const op = "credentialstores.(Service).deleteFromRepo"
|
||||
var rows int
|
||||
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.Subtype:
|
||||
repo, err := s.vaultRepoFn()
|
||||
if err != nil {
|
||||
@@ -581,7 +581,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return res
|
||||
}
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.Subtype:
|
||||
cs, err := vaultRepo.LookupCredentialStore(ctx, id)
|
||||
if err != nil {
|
||||
@@ -630,7 +630,7 @@ func toProto(ctx context.Context, in credential.Store, opt ...handlers.Option) (
|
||||
out.ScopeId = in.GetProjectId()
|
||||
}
|
||||
if outputFields.Has(globals.TypeField) {
|
||||
out.Type = subtypes.SubtypeFromId(domain, in.GetPublicId()).String()
|
||||
out.Type = globals.ResourceInfoFromPrefix(in.GetPublicId()).Subtype.String()
|
||||
}
|
||||
if outputFields.Has(globals.DescriptionField) && in.GetDescription() != "" {
|
||||
out.Description = wrapperspb.String(in.GetDescription())
|
||||
@@ -657,7 +657,7 @@ func toProto(ctx context.Context, in credential.Store, opt ...handlers.Option) (
|
||||
out.AuthorizedCollectionActions = opts.WithAuthorizedCollectionActions
|
||||
}
|
||||
if outputFields.Has(globals.AttributesField) {
|
||||
switch subtypes.SubtypeFromId(domain, in.GetPublicId()) {
|
||||
switch globals.ResourceInfoFromPrefix(in.GetPublicId()).Subtype {
|
||||
case vault.Subtype:
|
||||
vaultIn, ok := in.(*vault.CredentialStore)
|
||||
if !ok {
|
||||
@@ -790,8 +790,8 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRe
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetScopeId()), scope.Project.Prefix()) {
|
||||
badFields["scope_id"] = "This field must be a valid project scope id."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case vault.Subtype:
|
||||
switch req.GetItem().GetType() {
|
||||
case vault.Subtype.String():
|
||||
attrs := req.GetItem().GetVaultCredentialStoreAttributes()
|
||||
if attrs == nil {
|
||||
badFields[globals.AttributesField] = "Attributes are required for creating a vault credential store"
|
||||
@@ -828,7 +828,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRe
|
||||
if len(cs) > 0 && pk == nil {
|
||||
badFields[clientCertField] = "Cannot set a client certificate without a private key."
|
||||
}
|
||||
case static.Subtype:
|
||||
case static.Subtype.String():
|
||||
// No additional validation required for static credential store
|
||||
default:
|
||||
badFields[globals.TypeField] = "This is a required field and must be a known credential store type."
|
||||
@@ -840,9 +840,9 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateCredentialStoreRe
|
||||
func validateUpdateRequest(ctx context.Context, req *pbs.UpdateCredentialStoreRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case vault.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != vault.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != vault.Subtype.String() {
|
||||
badFields["type"] = "Cannot modify resource type."
|
||||
}
|
||||
attrs := req.GetItem().GetVaultCredentialStoreAttributes()
|
||||
@@ -903,7 +903,7 @@ func validateListRequest(ctx context.Context, req *pbs.ListCredentialStoresReque
|
||||
func calculateAuthorizedCollectionActions(ctx context.Context, authResults auth.VerifyResults, id string) (map[string]*structpb.ListValue, error) {
|
||||
var collectionActions map[string]*structpb.ListValue
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case vault.Subtype:
|
||||
collectionActions, err = auth.CalculateAuthorizedCollectionActions(ctx, authResults, vaultCollectionTypeMap, authResults.Scope.Id, id)
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ var (
|
||||
action.List,
|
||||
}
|
||||
|
||||
collectionTypeMap = map[subtypes.Subtype]map[resource.Type]action.ActionSet{
|
||||
collectionTypeMap = map[globals.Subtype]map[resource.Type]action.ActionSet{
|
||||
static.Subtype: {
|
||||
resource.HostSet: host_sets.CollectionActions,
|
||||
resource.Host: hosts.CollectionActions,
|
||||
@@ -183,7 +183,7 @@ func (s Service) ListHostCatalogs(ctx context.Context, req *pbs.ListHostCatalogs
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authorizedActions))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype subtypes.Subtype
|
||||
var subtype globals.Subtype
|
||||
switch item.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = static.Subtype
|
||||
@@ -253,7 +253,7 @@ func (s Service) GetHostCatalog(ctx context.Context, req *pbs.GetHostCatalogRequ
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype subtypes.Subtype
|
||||
var subtype globals.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = static.Subtype
|
||||
@@ -310,7 +310,7 @@ func (s Service) CreateHostCatalog(ctx context.Context, req *pbs.CreateHostCatal
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype subtypes.Subtype
|
||||
var subtype globals.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = static.Subtype
|
||||
@@ -373,7 +373,7 @@ func (s Service) UpdateHostCatalog(ctx context.Context, req *pbs.UpdateHostCatal
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hc.GetPublicId(), IdActions).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedCollectionActionsField) {
|
||||
var subtype subtypes.Subtype
|
||||
var subtype globals.Subtype
|
||||
switch hc.(type) {
|
||||
case *static.HostCatalog:
|
||||
subtype = static.Subtype
|
||||
@@ -415,7 +415,7 @@ func (s Service) DeleteHostCatalog(ctx context.Context, req *pbs.DeleteHostCatal
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (host.Catalog, *plugins.PluginInfo, error) {
|
||||
var plg *plugins.PluginInfo
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -537,8 +537,8 @@ func (s Service) createPluginInRepo(ctx context.Context, projId string, req *pbs
|
||||
|
||||
func (s Service) createInRepo(ctx context.Context, projId string, req *pbs.CreateHostCatalogRequest) (hc host.Catalog, info *plugins.PluginInfo, err error) {
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case static.Subtype:
|
||||
switch req.GetItem().GetType() {
|
||||
case static.Subtype.String():
|
||||
hc, err = s.createStaticInRepo(ctx, projId, req.GetItem())
|
||||
default:
|
||||
hc, plg, err = s.createPluginInRepo(ctx, projId, req)
|
||||
@@ -601,7 +601,7 @@ func (s Service) updatePluginInRepo(ctx context.Context, projId, id string, mask
|
||||
|
||||
func (s Service) updateInRepo(ctx context.Context, projId string, req *pbs.UpdateHostCatalogRequest) (hc host.Catalog, plg *plugins.PluginInfo, err error) {
|
||||
const op = "host_catalogs.(Service).updateInRepo"
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case static.Subtype:
|
||||
hc, err = s.updateStaticInRepo(ctx, projId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
case hostplugin.Subtype:
|
||||
@@ -613,7 +613,7 @@ func (s Service) updateInRepo(ctx context.Context, projId string, req *pbs.Updat
|
||||
func (s Service) deleteFromRepo(ctx context.Context, id string) (bool, error) {
|
||||
const op = "host_catalogs.(Service).deleteFromRepo"
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -659,7 +659,7 @@ func (s Service) authResult(ctx context.Context, id string, a action.Type) auth.
|
||||
return res
|
||||
}
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -843,9 +843,9 @@ func validateCreateRequest(req *pbs.CreateHostCatalogRequest) error {
|
||||
if req.GetItem().GetSecretsHmac() != "" {
|
||||
badFields[globals.SecretsHmacField] = "This is a read only field."
|
||||
}
|
||||
switch subtypes.SubtypeFromType(domain, req.GetItem().GetType()) {
|
||||
case static.Subtype:
|
||||
case hostplugin.Subtype:
|
||||
switch req.GetItem().GetType() {
|
||||
case static.Subtype.String():
|
||||
case hostplugin.Subtype.String():
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
badFields[globals.PluginField] = "This is a read only field."
|
||||
}
|
||||
@@ -870,16 +870,16 @@ func validateUpdateRequest(req *pbs.UpdateHostCatalogRequest) error {
|
||||
if req.GetItem().GetSecretsHmac() != "" {
|
||||
badFields[globals.SecretsHmacField] = "This is a read only field."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != static.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
badFields[globals.PluginField] = "This field is unused for this type of host catalog."
|
||||
}
|
||||
case hostplugin.Subtype:
|
||||
if req.GetItem().GetType() != "" && subtypes.SubtypeFromType(domain, req.GetItem().GetType()) != hostplugin.Subtype {
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != hostplugin.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify resource type."
|
||||
}
|
||||
if req.GetItem().GetPlugin() != nil {
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hostcatalogs"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
scopepb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -46,7 +45,7 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var authorizedCollectionActions = map[subtypes.Subtype]map[string]*structpb.ListValue{
|
||||
var authorizedCollectionActions = map[globals.Subtype]map[string]*structpb.ListValue{
|
||||
static.Subtype: {
|
||||
"host-sets": {
|
||||
Values: []*structpb.Value{
|
||||
|
||||
@@ -35,11 +35,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
maskManager = map[subtypes.Subtype]handlers.MaskManager{}
|
||||
maskManager = map[globals.Subtype]handlers.MaskManager{}
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
idActionsTypeMap = map[subtypes.Subtype]action.ActionSet{
|
||||
idActionsTypeMap = map[globals.Subtype]action.ActionSet{
|
||||
static.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
@@ -140,7 +140,7 @@ func (s Service) ListHostSetsWithOptions(ctx context.Context, req *pbs.ListHostS
|
||||
}
|
||||
for _, item := range hl {
|
||||
res.Id = item.GetPublicId()
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, res.Id)]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(res.Id).Subtype]
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, item.GetPublicId(), idActions, auth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
@@ -204,7 +204,7 @@ func (s Service) GetHostSet(ctx context.Context, req *pbs.GetHostSetRequest) (*p
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
if plg != nil {
|
||||
@@ -246,7 +246,7 @@ func (s Service) CreateHostSet(ctx context.Context, req *pbs.CreateHostSetReques
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetItem().GetHostCatalogId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
if plg != nil {
|
||||
@@ -294,7 +294,7 @@ func (s Service) UpdateHostSet(ctx context.Context, req *pbs.UpdateHostSetReques
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ func (s Service) AddHostSetHosts(ctx context.Context, req *pbs.AddHostSetHostsRe
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ func (s Service) SetHostSetHosts(ctx context.Context, req *pbs.SetHostSetHostsRe
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ func (s Service) RemoveHostSetHosts(ctx context.Context, req *pbs.RemoveHostSetH
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, hs.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ func (s Service) getFromRepo(ctx context.Context, id string) (host.Set, []host.H
|
||||
var hs host.Set
|
||||
var hl []host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -492,7 +492,7 @@ func (s Service) createInRepo(ctx context.Context, projectId, catalogId string,
|
||||
}
|
||||
var hSet host.Set
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
switch globals.ResourceInfoFromPrefix(catalogId).Subtype {
|
||||
case static.Subtype:
|
||||
h, err := toStorageStaticSet(ctx, catalogId, item)
|
||||
if err != nil {
|
||||
@@ -596,7 +596,7 @@ func (s Service) updatePluginInRepo(ctx context.Context, projectId string, req *
|
||||
|
||||
func (s Service) updateInRepo(ctx context.Context, projectId, catalogId string, req *pbs.UpdateHostSetRequest) (hs host.Set, hosts []host.Host, plg *plugins.PluginInfo, err error) {
|
||||
const op = "host_sets.(Service).updateInRepo"
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case static.Subtype:
|
||||
hs, hosts, err = s.updateStaticInRepo(ctx, projectId, catalogId, req)
|
||||
case hostplugin.Subtype:
|
||||
@@ -608,7 +608,7 @@ func (s Service) updateInRepo(ctx context.Context, projectId, catalogId string,
|
||||
func (s Service) deleteFromRepo(ctx context.Context, projectId, id string) (bool, error) {
|
||||
const op = "host_sets.(Service).deleteFromRepo"
|
||||
rows := 0
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -635,7 +635,7 @@ func (s Service) listFromRepo(ctx context.Context, catalogId string, opt ...host
|
||||
const op = "host_sets.(Service).listFromRepo"
|
||||
var plg *plugins.PluginInfo
|
||||
var sets []host.Set
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
switch globals.ResourceInfoFromPrefix(catalogId).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -760,7 +760,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
parentId = id
|
||||
default:
|
||||
var set host.Set
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
ss, _, err := staticRepo.LookupSet(ctx, id)
|
||||
if err != nil {
|
||||
@@ -789,7 +789,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
}
|
||||
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
cs, err := staticRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
@@ -970,7 +970,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateHostSetRequest) e
|
||||
badFields[globals.PreferredEndpointsField] = fmt.Errorf("Error parsing preferred endpoints: %w.", err).Error()
|
||||
}
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetItem().GetHostCatalogId()).Subtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
@@ -1001,7 +1001,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateHostSetRequest) e
|
||||
badFields[globals.PreferredEndpointsField] = fmt.Errorf("Error parsing preferred endpoints: %w.", err).Error()
|
||||
}
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hostsets"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -45,7 +44,7 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
var testAuthorizedActions = map[subtypes.Subtype][]string{
|
||||
var testAuthorizedActions = map[globals.Subtype][]string{
|
||||
static.Subtype: {"no-op", "read", "update", "delete", "add-hosts", "set-hosts", "remove-hosts"},
|
||||
hostplugin.Subtype: {"no-op", "read", "update", "delete"},
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
idActionsTypeMap = map[subtypes.Subtype]action.ActionSet{
|
||||
idActionsTypeMap = map[globals.Subtype]action.ActionSet{
|
||||
static.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
@@ -121,7 +121,7 @@ func (s Service) ListHosts(ctx context.Context, req *pbs.ListHostsRequest) (*pbs
|
||||
}
|
||||
for _, item := range hl {
|
||||
res.Id = item.GetPublicId()
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, res.Id)]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(res.Id).Subtype]
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, item.GetPublicId(), idActions, auth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
@@ -188,7 +188,7 @@ func (s Service) GetHost(ctx context.Context, req *pbs.GetHostRequest) (*pbs.Get
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, h.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
outputOpts = append(outputOpts, handlers.WithHostSetIds(h.GetSetIds()))
|
||||
@@ -227,7 +227,7 @@ func (s Service) CreateHost(ctx context.Context, req *pbs.CreateHostRequest) (*p
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetItem().GetHostCatalogId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, h.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ func (s Service) UpdateHost(ctx context.Context, req *pbs.UpdateHostRequest) (*p
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
idActions := idActionsTypeMap[subtypes.SubtypeFromId(domain, req.GetId())]
|
||||
idActions := idActionsTypeMap[globals.ResourceInfoFromPrefix(req.GetId()).Subtype]
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, h.GetPublicId(), idActions).Strings()))
|
||||
}
|
||||
outputOpts = append(outputOpts, handlers.WithHostSetIds(h.GetSetIds()))
|
||||
@@ -301,7 +301,7 @@ func (s Service) DeleteHost(ctx context.Context, req *pbs.DeleteHostRequest) (*p
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (host.Host, *plugins.PluginInfo, error) {
|
||||
var h host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -416,7 +416,7 @@ func (s Service) deleteFromRepo(ctx context.Context, projectId, id string) (bool
|
||||
func (s Service) listFromRepo(ctx context.Context, catalogId string) ([]host.Host, *plugins.PluginInfo, error) {
|
||||
var hosts []host.Host
|
||||
var plg *plugins.PluginInfo
|
||||
switch subtypes.SubtypeFromId(domain, catalogId) {
|
||||
switch globals.ResourceInfoFromPrefix(catalogId).Subtype {
|
||||
case static.Subtype:
|
||||
repo, err := s.staticRepoFn()
|
||||
if err != nil {
|
||||
@@ -465,7 +465,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
case action.List, action.Create:
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
h, err := staticRepo.LookupHost(ctx, id)
|
||||
if err != nil {
|
||||
@@ -493,7 +493,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
}
|
||||
|
||||
var cat host.Catalog
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case static.Subtype:
|
||||
stcat, err := staticRepo.LookupCatalog(ctx, parentId)
|
||||
if err != nil {
|
||||
@@ -619,8 +619,8 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
|
||||
func validateGetRequest(req *pbs.GetHostRequest) error {
|
||||
return handlers.ValidateGetRequest(func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
ct := subtypes.SubtypeFromId(domain, req.GetId())
|
||||
if ct == subtypes.UnknownSubtype {
|
||||
ct := globals.ResourceInfoFromPrefix(req.GetId()).Subtype
|
||||
if ct == globals.UnknownSubtype {
|
||||
badFields["id"] = "Improperly formatted identifier used."
|
||||
}
|
||||
return badFields
|
||||
@@ -633,7 +633,7 @@ func validateCreateRequest(req *pbs.CreateHostRequest) error {
|
||||
if !handlers.ValidId(handlers.Id(req.GetItem().GetHostCatalogId()), globals.StaticHostCatalogPrefix) {
|
||||
badFields["host_catalog_id"] = "The field is incorrectly formatted."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetHostCatalogId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetItem().GetHostCatalogId()).Subtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
@@ -675,7 +675,7 @@ func validateCreateRequest(req *pbs.CreateHostRequest) error {
|
||||
func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case static.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != static.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
@@ -715,7 +715,7 @@ func validateUpdateRequest(req *pbs.UpdateHostRequest) error {
|
||||
func validateDeleteRequest(req *pbs.DeleteHostRequest) error {
|
||||
return handlers.ValidateDeleteRequest(func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case hostplugin.Subtype:
|
||||
badFields[globals.IdField] = "Cannot manually delete this type of host."
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/plugin/loopback"
|
||||
"github.com/hashicorp/boundary/internal/scheduler"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/hosts"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/plugins"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
|
||||
@@ -42,7 +41,7 @@ import (
|
||||
"google.golang.org/protobuf/types/known/wrapperspb"
|
||||
)
|
||||
|
||||
var testAuthorizedActions = map[subtypes.Subtype][]string{
|
||||
var testAuthorizedActions = map[globals.Subtype][]string{
|
||||
static.Subtype: {"no-op", "read", "update", "delete"},
|
||||
hostplugin.Subtype: {"no-op", "read"},
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ var (
|
||||
|
||||
// IdActions contains the set of actions that can be performed on
|
||||
// individual resources
|
||||
IdActions = map[subtypes.Subtype]action.ActionSet{
|
||||
IdActions = map[globals.Subtype]action.ActionSet{
|
||||
oidc.Subtype: {
|
||||
action.NoOp,
|
||||
action.Read,
|
||||
@@ -137,7 +137,7 @@ func (s Service) ListManagedGroups(ctx context.Context, req *pbs.ListManagedGrou
|
||||
}
|
||||
for _, mg := range ul {
|
||||
res.Id = mg.GetPublicId()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, mg.GetPublicId())], requestauth.WithResource(&res)).Strings()
|
||||
authorizedActions := authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(mg.GetPublicId()).Subtype], requestauth.WithResource(&res)).Strings()
|
||||
if len(authorizedActions) == 0 {
|
||||
continue
|
||||
}
|
||||
@@ -198,7 +198,7 @@ func (s Service) GetManagedGroup(ctx context.Context, req *pbs.GetManagedGroupRe
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, mg.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(mg.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
if outputFields.Has(globals.MemberIdsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithMemberIds(memberIds))
|
||||
@@ -240,7 +240,7 @@ func (s Service) CreateManagedGroup(ctx context.Context, req *pbs.CreateManagedG
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, mg.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(mg.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, mg, outputOpts...)
|
||||
@@ -279,7 +279,7 @@ func (s Service) UpdateManagedGroup(ctx context.Context, req *pbs.UpdateManagedG
|
||||
outputOpts = append(outputOpts, handlers.WithScope(authResults.Scope))
|
||||
}
|
||||
if outputFields.Has(globals.AuthorizedActionsField) {
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[subtypes.SubtypeFromId(domain, mg.GetPublicId())]).Strings()))
|
||||
outputOpts = append(outputOpts, handlers.WithAuthorizedActions(authResults.FetchActionSetForId(ctx, mg.GetPublicId(), IdActions[globals.ResourceInfoFromPrefix(mg.GetPublicId()).Subtype]).Strings()))
|
||||
}
|
||||
|
||||
item, err := toProto(ctx, mg, outputOpts...)
|
||||
@@ -309,7 +309,7 @@ func (s Service) DeleteManagedGroup(ctx context.Context, req *pbs.DeleteManagedG
|
||||
func (s Service) getFromRepo(ctx context.Context, id string) (auth.ManagedGroup, []string, error) {
|
||||
var out auth.ManagedGroup
|
||||
var memberIds []string
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case oidc.Subtype:
|
||||
repo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
@@ -432,7 +432,7 @@ func (s Service) createInRepo(ctx context.Context, am auth.AuthMethod, item *pb.
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing item")
|
||||
}
|
||||
var out auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, am.GetPublicId()) {
|
||||
switch globals.ResourceInfoFromPrefix(am.GetPublicId()).Subtype {
|
||||
case oidc.Subtype:
|
||||
am, err := s.createOidcInRepo(ctx, am, item)
|
||||
if err != nil {
|
||||
@@ -534,7 +534,7 @@ func (s Service) updateLdapInRepo(ctx context.Context, scopeId, amId, id string,
|
||||
func (s Service) updateInRepo(ctx context.Context, scopeId, authMethodId string, req *pbs.UpdateManagedGroupRequest) (auth.ManagedGroup, error) {
|
||||
const op = "managed_groups.(Service).updateInRepo"
|
||||
var out auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case oidc.Subtype:
|
||||
mg, err := s.updateOidcInRepo(ctx, scopeId, authMethodId, req.GetId(), req.GetUpdateMask().GetPaths(), req.GetItem())
|
||||
if err != nil {
|
||||
@@ -561,7 +561,7 @@ func (s Service) deleteFromRepo(ctx context.Context, scopeId, id string) (bool,
|
||||
const op = "managed_groups.(Service).deleteFromRepo"
|
||||
var rows int
|
||||
var err error
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case oidc.Subtype:
|
||||
repo, iErr := s.oidcRepoFn()
|
||||
if iErr != nil {
|
||||
@@ -588,7 +588,7 @@ func (s Service) listFromRepo(ctx context.Context, authMethodId string) ([]auth.
|
||||
const op = "managed_groups.(Service).listFromRepo"
|
||||
|
||||
var outUl []auth.ManagedGroup
|
||||
switch subtypes.SubtypeFromId(domain, authMethodId) {
|
||||
switch globals.ResourceInfoFromPrefix(authMethodId).Subtype {
|
||||
case oidc.Subtype:
|
||||
oidcRepo, err := s.oidcRepoFn()
|
||||
if err != nil {
|
||||
@@ -637,7 +637,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
case action.List, action.Create:
|
||||
parentId = id
|
||||
default:
|
||||
switch subtypes.SubtypeFromId(domain, id) {
|
||||
switch globals.ResourceInfoFromPrefix(id).Subtype {
|
||||
case oidc.Subtype:
|
||||
grp, err := oidcRepo.LookupManagedGroup(ctx, id)
|
||||
if err != nil {
|
||||
@@ -668,7 +668,7 @@ func (s Service) parentAndAuthResult(ctx context.Context, id string, a action.Ty
|
||||
}
|
||||
|
||||
var authMeth auth.AuthMethod
|
||||
switch subtypes.SubtypeFromId(domain, parentId) {
|
||||
switch globals.ResourceInfoFromPrefix(parentId).Subtype {
|
||||
case oidc.Subtype:
|
||||
am, err := oidcRepo.LookupAuthMethod(ctx, parentId)
|
||||
if err != nil {
|
||||
@@ -799,7 +799,7 @@ func validateCreateRequest(ctx context.Context, req *pbs.CreateManagedGroupReque
|
||||
if req.GetItem().GetAuthMethodId() == "" {
|
||||
badFields[globals.AuthMethodIdField] = "This field is required."
|
||||
}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetItem().GetAuthMethodId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetItem().GetAuthMethodId()).Subtype {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Doesn't match the parent resource's type."
|
||||
@@ -842,7 +842,7 @@ func validateUpdateRequest(ctx context.Context, req *pbs.UpdateManagedGroupReque
|
||||
}
|
||||
return handlers.ValidateUpdateRequest(req, req.GetItem(), func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
switch subtypes.SubtypeFromId(domain, req.GetId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetId()).Subtype {
|
||||
case oidc.Subtype:
|
||||
if req.GetItem().GetType() != "" && req.GetItem().GetType() != oidc.Subtype.String() {
|
||||
badFields[globals.TypeField] = "Cannot modify the resource type."
|
||||
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
serverpb "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/structpb"
|
||||
@@ -137,7 +136,7 @@ func dynamicToSessionCredential(ctx context.Context, cred credential.Dynamic) (*
|
||||
Name: l.GetName(),
|
||||
Description: l.GetDescription(),
|
||||
CredentialStoreId: l.GetStoreId(),
|
||||
Type: subtypes.SubtypeFromId(credentialDomain, l.GetPublicId()).String(),
|
||||
Type: globals.ResourceInfoFromPrefix(l.GetPublicId()).Subtype.String(),
|
||||
CredentialType: credType,
|
||||
},
|
||||
Secret: &pb.SessionSecret{
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/hashicorp/boundary/globals"
|
||||
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
|
||||
"github.com/hashicorp/boundary/internal/session"
|
||||
"github.com/hashicorp/boundary/internal/target"
|
||||
"github.com/hashicorp/boundary/internal/types/subtypes"
|
||||
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@@ -52,7 +52,7 @@ type registry struct {
|
||||
*sync.Map
|
||||
}
|
||||
|
||||
func (r registry) get(s subtypes.Subtype) (*registryEntry, error) {
|
||||
func (r registry) get(s globals.Subtype) (*registryEntry, error) {
|
||||
v, ok := r.Load(s)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("subtype %q not registered", s)
|
||||
@@ -65,7 +65,7 @@ func (r registry) get(s subtypes.Subtype) (*registryEntry, error) {
|
||||
return re, nil
|
||||
}
|
||||
|
||||
func (r registry) maskManager(s subtypes.Subtype) (handlers.MaskManager, error) {
|
||||
func (r registry) maskManager(s globals.Subtype) (handlers.MaskManager, error) {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -77,7 +77,7 @@ func (r registry) maskManager(s subtypes.Subtype) (handlers.MaskManager, error)
|
||||
// newAttribute creates an Attribute for the given subtype. It delegates the
|
||||
// allocation of the Attribute to the registered attrFunc for the given
|
||||
// subtype. An error is returned if the provided subtype is not registered
|
||||
func (r registry) newAttribute(s subtypes.Subtype, m any) (Attributes, error) {
|
||||
func (r registry) newAttribute(s globals.Subtype, m any) (Attributes, error) {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -92,7 +92,7 @@ func (r registry) newAttribute(s subtypes.Subtype, m any) (Attributes, error) {
|
||||
// setting of the specific attribute type to the registered setAttributeFunc for
|
||||
// the given subtype. An error is returned if the provided subtype is not
|
||||
// registered.
|
||||
func (r registry) setAttributes(s subtypes.Subtype, in target.Target, out *pb.Target) error {
|
||||
func (r registry) setAttributes(s globals.Subtype, in target.Target, out *pb.Target) error {
|
||||
re, err := r.get(s)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -106,7 +106,7 @@ var subtypeRegistry = registry{
|
||||
}
|
||||
|
||||
// Register registers a subtype for used by the service handler.
|
||||
func Register(s subtypes.Subtype, maskManager handlers.MaskManager, af attributeFunc, sf setAttributeFunc, vsf validateSessionStateFunc) {
|
||||
func Register(s globals.Subtype, maskManager handlers.MaskManager, af attributeFunc, sf setAttributeFunc, vsf validateSessionStateFunc) {
|
||||
if _, existed := subtypeRegistry.LoadOrStore(s, ®istryEntry{
|
||||
maskManager: maskManager,
|
||||
attrFunc: af,
|
||||
|
||||
@@ -95,7 +95,7 @@ var (
|
||||
action.List,
|
||||
}
|
||||
|
||||
validateCredentialSourcesFn = func(context.Context, subtypes.Subtype, []target.CredentialSource) error { return nil }
|
||||
validateCredentialSourcesFn = func(context.Context, globals.Subtype, []target.CredentialSource) error { return nil }
|
||||
ValidateIngressWorkerFilterFn = IngressWorkerFilterUnsupported
|
||||
AuthorizeSessionWorkerFilterFn = AuthorizeSessionWithWorkerFilter
|
||||
PostSessionAuthorizationCallback = DefaultPostSessionAuthorizationCallback
|
||||
@@ -799,7 +799,7 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
|
||||
var endpoints []*host.Endpoint
|
||||
for _, hSource := range hostSources {
|
||||
hsId := hSource.Id()
|
||||
switch subtypes.SubtypeFromId(hostDomain, hsId) {
|
||||
switch globals.ResourceInfoFromPrefix(hsId).Subtype {
|
||||
case static.Subtype:
|
||||
eps, err := staticHostRepo.Endpoints(ctx, hsId)
|
||||
if err != nil {
|
||||
@@ -2038,7 +2038,7 @@ func validateAuthorizeSessionRequest(req *pbs.AuthorizeSessionRequest) error {
|
||||
}
|
||||
}
|
||||
if req.GetHostId() != "" {
|
||||
switch subtypes.SubtypeFromId(hostDomain, req.GetHostId()) {
|
||||
switch globals.ResourceInfoFromPrefix(req.GetHostId()).Subtype {
|
||||
case static.Subtype, plugin.Subtype:
|
||||
default:
|
||||
badFields[globals.HostIdField] = "Incorrectly formatted identifier."
|
||||
|
||||
@@ -3410,7 +3410,7 @@ func TestAuthorizeSession_Errors(t *testing.T) {
|
||||
h.Address = fmt.Sprintf("%s:54321", h.GetAddress())
|
||||
repo, err := staticHostRepoFn()
|
||||
require.NoError(t, err)
|
||||
h, _, err = repo.UpdateHost(ctx, hc.GetProjectId(), h, h.GetVersion(), []string{"address"})
|
||||
_, _, err = repo.UpdateHost(ctx, hc.GetProjectId(), h, h.GetVersion(), []string{"address"})
|
||||
require.NoError(t, err)
|
||||
return apiTar.GetItem().GetVersion()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user