Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions internal/errors/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (
KeyNotFound Code = 105 // KeyNotFound represents that a key/version was not found in the KMS
TicketAlreadyRedeemed Code = 106 // TicketAlreadyRedeemed represents that the ticket version has already been redeemed
TicketNotFound Code = 107 // TicketNotFound represents that the ticket was not found
Io Code = 108 // Io represents that an io error occurred in an underlying call (i.e binary.Write)
Io Code = 108 // Io represents that an io error occurred in an underlying call (i.e. binary.Write)
InvalidTimeStamp Code = 109 // InvalidTimeStamp represents an invalid time stamp for an operation
SessionNotFound Code = 110 // SessionNotFound represents that the session was not found
InvalidSessionState Code = 111 // InvalidSessionState represents that the session was in an invalid state
Expand All @@ -44,7 +44,7 @@ const (
AuthAttemptExpired Code = 198 // AuthAttemptExpired represents an expired authentication attempt
AuthMethodInactive Code = 199 // AuthMethodInactive represents an error that means the auth method is not active.

// PasswordTooShort results from attempting to set a password which is to short.
// PasswordTooShort results from attempting to set a password which is too short.
PasswordTooShort Code = 200

// PasswordUnsupportedConfiguration results from attempting to perform an
Expand All @@ -70,7 +70,7 @@ const (
// client and server error codes
Unauthorized Code = 401 // Unauthorized represents the operation is unauthorized
Forbidden Code = 403 // Forbidden represents the operation is forbidden
Internal Code = 500 // InternalError represents the system encountered an unexpected condition.
Internal Code = 500 // Internal represents the system encountered an unexpected condition.

// DB errors are reserved Codes from 1000-1999
CheckConstraint Code = 1000 // CheckConstraint represents a check constraint error
Expand Down Expand Up @@ -107,10 +107,15 @@ const (
VaultTokenNotRenewable Code = 3012 // VaultTokenNotRenewable represents an error for a Vault token that is not renewable
VaultTokenMissingCapabilities Code = 3013 // VaultTokenMissingCapabilities represents an error for a Vault token that is missing capabilities
VaultCredentialRequest Code = 3014 // VaultCredentialRequest represents an error returned from Vault when retrieving a credential
VaultEmptySecret Code = 3015 // VaultEmptySecret represents a empty secret was returned from Vault without error
VaultEmptySecret Code = 3015 // VaultEmptySecret represents an empty secret was returned from Vault without error
VaultInvalidMappingOverride Code = 3016 // VaultInvalidMappingOverride represents an error returned when a credential mapping is unknown or does not match a credential type
VaultInvalidCredentialMapping Code = 3017 // VaultInvalidCredentialMapping represents an error returned when a Vault secret failed to be mapped to a specific credential type

// OIDC authentication provided errors
OidcProviderCallbackError Code = 4000 // OidcProviderCallbackError represents an error that is passed by the OIDC provider to the callback endpoint

// Plugin specific srrors are codes 5000-5999
PluginInvalidParameter Code = 5000 // PluginInvalidParameter represents a plugin error with an invalid parameter for an operation
PluginFailedPrecondition Code = 5001 // PluginFailedPrecondition represents a plugin error where the system is not in the state required for an operation
PluginAborted Code = 5002 // PluginAborted represents a plugin error where a non-native library call was not able to run to completion
)
20 changes: 17 additions & 3 deletions internal/host/plugin/repository_host_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,14 @@ func (r *Repository) CreateCatalog(ctx context.Context, c *HostCatalog, _ ...Opt
if !pluginCalledSuccessfully {
plgResp, err = plgClient.OnCreateCatalog(ctx, &plgpb.OnCreateCatalogRequest{Catalog: plgHc})
if err != nil {
if status.Code(err) != codes.Unimplemented {
switch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add tests to verify these behave as expected? For the changes in this file and the repository_host_set file.

case status.Code(err) == codes.InvalidArgument:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginInvalidParameter))
case status.Code(err) == codes.FailedPrecondition:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginFailedPrecondition))
case status.Code(err) == codes.Aborted:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginAborted))
case status.Code(err) != codes.Unimplemented:
return errors.Wrap(ctx, err, op)
}
}
Expand Down Expand Up @@ -380,7 +387,14 @@ func (r *Repository) UpdateCatalog(ctx context.Context, c *HostCatalog, version
Persisted: currentCatalogPersisted,
})
if err != nil {
if status.Code(err) != codes.Unimplemented {
switch {
case status.Code(err) == codes.InvalidArgument:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginInvalidParameter))
case status.Code(err) == codes.FailedPrecondition:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginFailedPrecondition))
case status.Code(err) == codes.Aborted:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginAborted))
case status.Code(err) != codes.Unimplemented:
return errors.Wrap(ctx, err, op)
}
}
Expand Down Expand Up @@ -685,7 +699,7 @@ func (r *Repository) getPlugin(ctx context.Context, plgId string) (*hostplugin.P
return plg, nil
}

// toPluginCatalog returns a host catalog, with it's secret if available, in the format expected
// toPluginCatalog returns a host catalog, with its secret if available, in the format expected
// by the host plugin system.
func toPluginCatalog(ctx context.Context, in *HostCatalog) (*pb.HostCatalog, error) {
const op = "plugin.toPluginCatalog"
Expand Down
18 changes: 16 additions & 2 deletions internal/host/plugin/repository_host_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,14 @@ func (r *Repository) CreateSet(ctx context.Context, scopeId string, s *HostSet,

if !calledPluginSuccessfully {
if _, err := plgClient.OnCreateSet(ctx, &plgpb.OnCreateSetRequest{Catalog: plgHc, Set: plgHs, Persisted: per}); err != nil {
if status.Code(err) != codes.Unimplemented {
switch {
case status.Code(err) == codes.InvalidArgument:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginInvalidParameter))
case status.Code(err) == codes.FailedPrecondition:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginFailedPrecondition))
case status.Code(err) == codes.Aborted:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginAborted))
case status.Code(err) != codes.Unimplemented:
return errors.Wrap(ctx, err, op)
}
}
Expand Down Expand Up @@ -472,7 +479,14 @@ func (r *Repository) UpdateSet(ctx context.Context, scopeId string, s *HostSet,
Persisted: persisted,
})
if err != nil {
if status.Code(err) != codes.Unimplemented {
switch {
case status.Code(err) == codes.InvalidArgument:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginInvalidParameter))
case status.Code(err) == codes.FailedPrecondition:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginFailedPrecondition))
case status.Code(err) == codes.Aborted:
return errors.Wrap(ctx, err, op, errors.WithCode(errors.PluginAborted))
case status.Code(err) != codes.Unimplemented:
return errors.Wrap(ctx, err, op)
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/host/mains/aws/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/boundary/plugins/host/mains/aws
go 1.17

require (
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20211206232153-e565bad02701
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20220309191650-d24a1def65f3
github.com/hashicorp/boundary/sdk v0.0.12-0.20211112235128-46a1edcb3b7b
github.com/hashicorp/go-hclog v1.0.0
)
Expand Down
2 changes: 2 additions & 0 deletions plugins/host/mains/aws/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB7
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20211206232153-e565bad02701 h1:u7uhXKouEi2Do2645NBCOxzqWyUNXPGxebDAKeWaygM=
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20211206232153-e565bad02701/go.mod h1:5sbsaBwfSDftXIXLpwU0LvPlhqkXWUFsZn4obxz5Hj8=
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20220309191650-d24a1def65f3 h1:sRbTVafG/21uWDJVdOXZlhtrbKz6eLgKMJhMOQbD1oM=
github.com/hashicorp/boundary-plugin-host-aws v0.0.0-20220309191650-d24a1def65f3/go.mod h1:5sbsaBwfSDftXIXLpwU0LvPlhqkXWUFsZn4obxz5Hj8=
github.com/hashicorp/boundary/sdk v0.0.12-0.20211112235128-46a1edcb3b7b h1:qURjJaF3/TUbDcPCUAg9PG9a95NCgPrrcrOsurBJ7Rc=
github.com/hashicorp/boundary/sdk v0.0.12-0.20211112235128-46a1edcb3b7b/go.mod h1:Krt7KLGTnDPQTaVlgSygV5SeqWDrOfbYyVBmB0KILD4=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down