From d8a8d86ac166f93ded4a553a24256492ca2a9ba6 Mon Sep 17 00:00:00 2001 From: Yong Wen Chua Date: Mon, 28 Jun 2021 10:46:43 +0800 Subject: [PATCH] Address feedback - Remove unnecessary check - Fix description - Fix some inconsistencies --- plugin/path_role_set.go | 6 +----- plugin/path_static_account.go | 2 +- plugin/path_static_account_secrets.go | 6 ++---- plugin/static_account.go | 3 ++- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/plugin/path_role_set.go b/plugin/path_role_set.go index 00053045..c9d3e72f 100644 --- a/plugin/path_role_set.go +++ b/plugin/path_role_set.go @@ -157,11 +157,7 @@ func (b *backend) pathRoleSetRead(ctx context.Context, req *logical.Request, d * } func (b *backend) pathRoleSetDelete(ctx context.Context, req *logical.Request, d *framework.FieldData) (resp *logical.Response, err error) { - nameRaw, ok := d.GetOk("name") - if !ok { - return logical.ErrorResponse("name is required"), nil - } - rsName := nameRaw.(string) + rsName := d.Get("name").(string) b.rolesetLock.Lock() defer b.rolesetLock.Unlock() diff --git a/plugin/path_static_account.go b/plugin/path_static_account.go index 4411b149..561138db 100644 --- a/plugin/path_static_account.go +++ b/plugin/path_static_account.go @@ -39,7 +39,7 @@ func pathStaticAccount(b *backend) *framework.Path { }, "token_scopes": { Type: framework.TypeCommaStringSlice, - Description: fmt.Sprintf(`List of OAuth scopes to assign to access tokens generated under this account. Ignored if secret_type not %q`, SecretTypeKey), + Description: fmt.Sprintf(`List of OAuth scopes to assign to access tokens generated under this account. Ignored if "secret_type" is not "%q"`, SecretTypeAccessToken), }, }, ExistenceCheck: b.pathStaticAccountExistenceCheck, diff --git a/plugin/path_static_account_secrets.go b/plugin/path_static_account_secrets.go index 0dc11df5..cfd75985 100644 --- a/plugin/path_static_account_secrets.go +++ b/plugin/path_static_account_secrets.go @@ -10,8 +10,7 @@ import ( func pathStaticAccountSecretServiceAccountKey(b *backend) *framework.Path { return &framework.Path{ - Pattern: fmt.Sprintf("%s/%s/key", staticAccountPathPrefix, framework.GenericNameRegex("static_account")), - Deprecated: true, + Pattern: fmt.Sprintf("%s/%s/key", staticAccountPathPrefix, framework.GenericNameRegex("static_account")), Fields: map[string]*framework.FieldSchema{ "static_account": { Type: framework.TypeString, @@ -44,8 +43,7 @@ func pathStaticAccountSecretServiceAccountKey(b *backend) *framework.Path { func pathStaticAccountSecretAccessToken(b *backend) *framework.Path { return &framework.Path{ - Pattern: fmt.Sprintf("%s/%s/token", staticAccountPathPrefix, framework.GenericNameRegex("static_account")), - Deprecated: true, + Pattern: fmt.Sprintf("%s/%s/token", staticAccountPathPrefix, framework.GenericNameRegex("static_account")), Fields: map[string]*framework.FieldSchema{ "static_account": { Type: framework.TypeString, diff --git a/plugin/static_account.go b/plugin/static_account.go index bfaa039e..f9b14501 100644 --- a/plugin/static_account.go +++ b/plugin/static_account.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "github.com/hashicorp/errwrap" "github.com/hashicorp/go-gcp-common/gcputil" "github.com/hashicorp/go-multierror" @@ -110,7 +111,7 @@ func (b *backend) createStaticAccount(ctx context.Context, req *logical.Request, if err != nil { if isGoogleAccountNotFoundErr(err) { - return fmt.Errorf("unable to create static account - service account %q should exist", input.serviceAccountEmail) + return fmt.Errorf("unable to create static account, service account %q should exist", input.serviceAccountEmail) } return errwrap.Wrapf(fmt.Sprintf("unable to create static account, could not confirm service account %q exists: {{err}}", input.serviceAccountEmail), err) }