Skip to content

Commit

Permalink
chore: gofmt -w -r 'interface{} -> any' *.go
Browse files Browse the repository at this point in the history
  • Loading branch information
ilijamt committed Feb 21, 2024
1 parent 8345928 commit 828dccc
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions entry_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions entry_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions entry_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions path_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
},
Expand Down Expand Up @@ -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)
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down
14 changes: 7 additions & 7 deletions path_config_token_autorotate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
Expand All @@ -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",
Expand All @@ -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(),
Expand All @@ -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",
Expand All @@ -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(),
Expand All @@ -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",
},
Expand All @@ -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",
Expand Down
42 changes: 21 additions & 21 deletions path_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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)
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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",
},
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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",
},
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions path_token_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 828dccc

Please sign in to comment.