Merge remote-tracking branch 'origin/main' into llb-byow

This commit is contained in:
Jeff Mitchell committed 2022-06-15 16:45:00 -05:00
commit 704d68848c
160 files changed
+15933 -4684

No files matched your search

+3 -3
View File
@@ -146,9 +146,9 @@ func (a Type) String() string {
"change-state",
"delete:self",
"no-op",
"add-credential-libraries",
"set-credential-libraries",
"remove-credential-libraries",
"add-credential-libraries", // DEPRECATED
"set-credential-libraries", // DEPRECATED
"remove-credential-libraries", // DEPRECATED
"add-credential-sources",
"set-credential-sources",
"remove-credential-sources",
+3
View File
@@ -25,6 +25,7 @@ const (
ManagedGroup
CredentialStore
CredentialLibrary
Credential
// NOTE: When adding a new type, be sure to update:
//
// * The Grant.validateType function and test
@@ -58,6 +59,7 @@ func (r Type) String() string {
"managed-group",
"credential-store",
"credential-library",
"credential",
}[r]
}
@@ -90,4 +92,5 @@ var Map = map[string]Type{
ManagedGroup.String(): ManagedGroup,
CredentialStore.String(): CredentialStore,
CredentialLibrary.String(): CredentialLibrary,
Credential.String(): Credential,
}
+15
View File
@@ -0,0 +1,15 @@
package subtypes
// UnknownSubtypeIDError is an error type that describes an invalid
// resource sub-type identifer. For example, this authentication sub-type
// ID "ampwd_1234567890" is an error because the prefix "ampwd" is invalid.
type UnknownSubtypeIDError struct {
// ID is the resource identifier
ID string
}
// Error returns a string describing an unknown subtype based on a given resource ID
// Example: "unknown subtype in ID: ampwd_1234567890"
func (e *UnknownSubtypeIDError) Error() string {
return "unknown subtype in ID: " + e.ID
}
+11 -2
View File
@@ -2,6 +2,7 @@ package subtypes
import (
"context"
"errors"
"github.com/hashicorp/boundary/internal/daemon/controller/handlers"
"github.com/hashicorp/boundary/sdk/pbs/controller/protooptions"
@@ -297,8 +298,16 @@ func AttributeTransformerInterceptor(_ context.Context) grpc.UnaryServerIntercep
return func(interceptorCtx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
if reqMsg, ok := req.(proto.Message); ok {
if err := transformRequest(reqMsg); err != nil {
return nil, handlers.InvalidArgumentErrorf("Error in provided request.",
map[string]string{"attributes": "Attribute fields do not match the expected format."})
fieldErrs := map[string]string{
"attributes": "Attribute fields do not match the expected format.",
}
var unknownSubTypeIDErr *UnknownSubtypeIDError
if errors.As(err, &unknownSubTypeIDErr) {
fieldErrs["attributes"] = unknownSubTypeIDErr.Error()
}
return nil, handlers.InvalidArgumentErrorf("Error in provided request.", fieldErrs)
}
}