Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 9000de5

Browse files
Merge pull request #202 from secrethub/feature/clarify-user-managed
Rename ValidateGCPServiceAccountEmail to ValidateGCPUserManagedServic…
2 parents c91e33e + 5e56021 commit 9000de5

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

internals/api/credential.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var credentialTypesMetadata = map[CredentialType]map[string]func(string) error{
8585
CredentialMetadataAWSKMSKey: nil,
8686
},
8787
CredentialTypeGCPServiceAccount: {
88-
CredentialMetadataGCPServiceAccountEmail: ValidateGCPServiceAccountEmail,
88+
CredentialMetadataGCPServiceAccountEmail: ValidateGCPUserManagedServiceAccountEmail,
8989
CredentialMetadataGCPKMSKeyResourceID: ValidateGCPKMSKeyResourceID,
9090
},
9191
CredentialTypeBackupCode: {},

internals/api/patterns.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ func ValidateShortCredentialFingerprint(fingerprint string) error {
301301
return nil
302302
}
303303

304-
// ValidateGCPServiceAccountEmail validates whether the given string is potentially a valid email for a GCP
305-
// Service Account. The function does a best-effort check. If no error is returned, this does not mean the value is
306-
// accepted by GCP.
307-
func ValidateGCPServiceAccountEmail(v string) error {
304+
// ValidateGCPUserManagedServiceAccountEmail validates whether the given string is potentially a valid email for a
305+
// user-managed GCP Service Account. The function does a best-effort check. If no error is returned, this does not mean
306+
// the value is accepted by GCP.
307+
func ValidateGCPUserManagedServiceAccountEmail(v string) error {
308308
if !govalidator.IsEmail(v) {
309309
return ErrInvalidGCPServiceAccountEmail
310310
}
@@ -320,7 +320,7 @@ func ValidateGCPServiceAccountEmail(v string) error {
320320
// ProjectIDFromGCPEmail returns the project ID included in the email of a GCP Service Account.
321321
// If the input is not a valid user-managed GCP Service Account email, an error is returned.
322322
func ProjectIDFromGCPEmail(in string) (string, error) {
323-
err := ValidateGCPServiceAccountEmail(in)
323+
err := ValidateGCPUserManagedServiceAccountEmail(in)
324324
if err != nil {
325325
return "", err
326326
}

internals/api/patterns_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func TestValidateGCPServiceAccountEmail(t *testing.T) {
501501

502502
for name, tc := range cases {
503503
t.Run(name, func(t *testing.T) {
504-
err := api.ValidateGCPServiceAccountEmail(tc.in)
504+
err := api.ValidateGCPUserManagedServiceAccountEmail(tc.in)
505505

506506
assert.Equal(t, err != nil, tc.expectErr)
507507
})

internals/gcp/service_creator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type CredentialCreator struct {
2323
// NewCredentialCreator returns a CredentialCreator that uses the provided GCP KMS key and Service Account Email to create a new credential.
2424
// The GCP client is configured with the optionally provided option.ClientOption.
2525
func NewCredentialCreator(serviceAccountEmail, keyResourceID string, gcpOptions ...option.ClientOption) (*CredentialCreator, map[string]string, error) {
26-
if err := api.ValidateGCPServiceAccountEmail(serviceAccountEmail); err != nil {
26+
if err := api.ValidateGCPUserManagedServiceAccountEmail(serviceAccountEmail); err != nil {
2727
return nil, nil, err
2828
}
2929
if err := api.ValidateGCPKMSKeyResourceID(keyResourceID); err != nil {

0 commit comments

Comments
 (0)