From 828dcccf3120209520d81e54797cf0b8817167c3 Mon Sep 17 00:00:00 2001 From: Ilija Matoski Date: Wed, 21 Feb 2024 21:13:34 +0100 Subject: [PATCH] chore: gofmt -w -r 'interface{} -> any' *.go --- entry_config.go | 4 +-- entry_role.go | 4 +-- entry_token.go | 6 ++-- path_config_test.go | 14 +++++----- path_config_token_autorotate_test.go | 14 +++++----- path_role_test.go | 42 ++++++++++++++-------------- path_token_role_test.go | 4 +-- utils.go | 2 +- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/entry_config.go b/entry_config.go index 5147ab2..47c6cc0 100644 --- a/entry_config.go +++ b/entry_config.go @@ -16,13 +16,13 @@ type EntryConfig struct { RevokeAutoRotatedToken bool `json:"revoke_auto_rotated_token" structs:"revoke_auto_rotated_token" mapstructure:"revoke_auto_rotated_token"` } -func (e EntryConfig) LogicalResponseData() map[string]interface{} { +func (e EntryConfig) LogicalResponseData() map[string]any { var tokenExpiresAt = "" if !e.TokenExpiresAt.IsZero() { tokenExpiresAt = e.TokenExpiresAt.Format(time.RFC3339) } - return map[string]interface{}{ + return map[string]any{ "max_ttl": int64(e.MaxTTL / time.Second), "base_url": e.BaseURL, "token": e.Token, diff --git a/entry_role.go b/entry_role.go index db9c330..aa0a9e9 100644 --- a/entry_role.go +++ b/entry_role.go @@ -17,8 +17,8 @@ type entryRole struct { TokenType TokenType `json:"token_type" structs:"token_type" mapstructure:"token_type"` } -func (e entryRole) LogicalResponseData() map[string]interface{} { - return map[string]interface{}{ +func (e entryRole) LogicalResponseData() map[string]any { + return map[string]any{ "role_name": e.RoleName, "path": e.Path, "name": e.Name, diff --git a/entry_token.go b/entry_token.go index 319ea6a..8f07020 100644 --- a/entry_token.go +++ b/entry_token.go @@ -16,8 +16,8 @@ type EntryToken struct { AccessLevel AccessLevel `json:"access_level"` // not used for personal access tokens } -func (e EntryToken) SecretResponse() (map[string]interface{}, map[string]interface{}) { - return map[string]interface{}{ +func (e EntryToken) SecretResponse() (map[string]any, map[string]any) { + return map[string]any{ "name": e.Name, "token": e.Token, "path": e.Path, @@ -26,7 +26,7 @@ func (e EntryToken) SecretResponse() (map[string]interface{}, map[string]interfa "created_at": e.CreatedAt, "expires_at": e.ExpiresAt, }, - map[string]interface{}{ + map[string]any{ "path": e.Path, "name": e.Name, "user_id": e.UserID, diff --git a/path_config_test.go b/path_config_test.go index 2a14789..0300020 100644 --- a/path_config_test.go +++ b/path_config_test.go @@ -46,7 +46,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": int((32 * time.Hour).Seconds()), }, @@ -102,7 +102,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{}, + Data: map[string]any{}, }) require.Error(t, err) @@ -120,7 +120,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": time.Hour * 23, }, @@ -140,7 +140,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": 0, }, @@ -160,7 +160,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": 0, }, @@ -180,7 +180,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": 366 * 24 * time.Hour, }, @@ -200,7 +200,7 @@ func TestPathConfig(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "token", "max_ttl": 14 * 24 * time.Hour, }, diff --git a/path_config_token_autorotate_test.go b/path_config_token_autorotate_test.go index 287cd06..a3e1aae 100644 --- a/path_config_token_autorotate_test.go +++ b/path_config_token_autorotate_test.go @@ -17,7 +17,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", }, }) @@ -32,7 +32,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", "auto_rotate_before": "2h", @@ -49,7 +49,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", "auto_rotate_before": (gitlab.DefaultAutoRotateBeforeMaxTTL + time.Hour).String(), @@ -65,7 +65,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", "auto_rotate_before": "48h", @@ -82,7 +82,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", "auto_rotate_before": (gitlab.DefaultAutoRotateBeforeMinTTL - time.Hour).String(), @@ -98,7 +98,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", }, @@ -114,7 +114,7 @@ func TestPathConfig_AutoRotate(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "token": "super-secret-token", "max_ttl": "48h", "auto_rotate_before": "10h", diff --git a/path_role_test.go b/path_role_test.go index 8009918..31a4003 100644 --- a/path_role_test.go +++ b/path_role_test.go @@ -28,7 +28,7 @@ func TestPathRolesList(t *testing.T) { } func TestPathRoles(t *testing.T) { - var defaultConfig = map[string]interface{}{"token": "random-token"} + var defaultConfig = map[string]any{"token": "random-token"} t.Run("delete non existing role", func(t *testing.T) { var b, l, err = getBackend() require.NoError(t, err) @@ -62,7 +62,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypePersonal.String(), "token_type": gitlab.TokenTypePersonal.String(), @@ -79,7 +79,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypePersonal.String(), "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -99,7 +99,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypeProject.String(), "token_type": gitlab.TokenTypeProject.String(), @@ -115,7 +115,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypeProject.String(), "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -136,7 +136,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypeGroup.String(), "token_type": gitlab.TokenTypeGroup.String(), @@ -152,7 +152,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": gitlab.TokenTypeGroup.String(), "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -176,7 +176,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{}, + Data: map[string]any{}, }) require.Error(t, err) require.NotNil(t, resp) @@ -193,7 +193,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example user personal token", "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -211,7 +211,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example project personal token", "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -233,7 +233,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -250,7 +250,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -273,7 +273,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example user personal token", "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -291,7 +291,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/%d", gitlab.PathRoleStorage, time.Now().UnixNano()), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": "Example user personal token", "access_level": gitlab.AccessLevelOwnerPermissions.String(), @@ -315,7 +315,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "max_ttl": (10 * 24 * time.Hour).Seconds(), "token": "token", }, @@ -324,7 +324,7 @@ func TestPathRoles(t *testing.T) { require.NotNil(t, resp) }() - var roleData = map[string]interface{}{ + var roleData = map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -360,7 +360,7 @@ func TestPathRoles(t *testing.T) { var b, l, err = getBackendWithConfig(defaultConfig) require.NoError(t, err) - var roleData = map[string]interface{}{ + var roleData = map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -396,7 +396,7 @@ func TestPathRoles(t *testing.T) { var b, l, err = getBackendWithConfig(defaultConfig) require.NoError(t, err) - var roleData = map[string]interface{}{ + var roleData = map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -431,7 +431,7 @@ func TestPathRoles(t *testing.T) { var b, l, err = getBackendWithConfig(defaultConfig) require.NoError(t, err) - var roleData = map[string]interface{}{ + var roleData = map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), @@ -485,7 +485,7 @@ func TestPathRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.UpdateOperation, Path: gitlab.PathConfigStorage, Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "max_ttl": (10 * 24 * time.Hour).Seconds(), "token": "token", }, @@ -494,7 +494,7 @@ func TestPathRoles(t *testing.T) { require.NotNil(t, resp) }() - var roleData = map[string]interface{}{ + var roleData = map[string]any{ "path": "user", "name": "Example user personal token", "token_type": gitlab.TokenTypePersonal.String(), diff --git a/path_token_role_test.go b/path_token_role_test.go index 8f79652..4b19cbb 100644 --- a/path_token_role_test.go +++ b/path_token_role_test.go @@ -10,7 +10,7 @@ import ( ) func TestPathTokenRoles(t *testing.T) { - var defaultConfig = map[string]interface{}{"token": "random-token"} + var defaultConfig = map[string]any{"token": "random-token"} t.Run("role not found", func(t *testing.T) { var b, l, err = getBackend() @@ -41,7 +41,7 @@ func TestPathTokenRoles(t *testing.T) { resp, err := b.HandleRequest(context.Background(), &logical.Request{ Operation: logical.CreateOperation, Path: fmt.Sprintf("%s/test", gitlab.PathRoleStorage), Storage: l, - Data: map[string]interface{}{ + Data: map[string]any{ "path": "user", "name": tokenType.String(), "token_type": tokenType.String(), diff --git a/utils.go b/utils.go index 1b4b600..dfe38b5 100644 --- a/utils.go +++ b/utils.go @@ -2,7 +2,7 @@ package gitlab import "fmt" -func allowedValues(values ...string) (ret []interface{}) { +func allowedValues(values ...string) (ret []any) { for _, value := range values { ret = append(ret, value) }