Skip to content

Commit de76eeb

Browse files
committed
trivial: Replace 'interface{}' with any
Add some syntactic sugar 🍭. sed -i 's/interface{}/any/g' $(ag 'interface{}' -Q -l) gofmt -w ./.. Signed-off-by: Stephen Finucane <[email protected]>
1 parent a7ecc2e commit de76eeb

File tree

368 files changed

+2063
-2063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

368 files changed

+2063
-2063
lines changed

Diff for: auth_options.go

+24-24
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,21 @@ type AuthScope struct {
107107

108108
// ToTokenV2CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder
109109
// interface in the v2 tokens package
110-
func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) {
110+
func (opts AuthOptions) ToTokenV2CreateMap() (map[string]any, error) {
111111
// Populate the request map.
112-
authMap := make(map[string]interface{})
112+
authMap := make(map[string]any)
113113

114114
if opts.Username != "" {
115115
if opts.Password != "" {
116-
authMap["passwordCredentials"] = map[string]interface{}{
116+
authMap["passwordCredentials"] = map[string]any{
117117
"username": opts.Username,
118118
"password": opts.Password,
119119
}
120120
} else {
121121
return nil, ErrMissingInput{Argument: "Password"}
122122
}
123123
} else if opts.TokenID != "" {
124-
authMap["token"] = map[string]interface{}{
124+
authMap["token"] = map[string]any{
125125
"id": opts.TokenID,
126126
}
127127
} else {
@@ -135,12 +135,12 @@ func (opts AuthOptions) ToTokenV2CreateMap() (map[string]interface{}, error) {
135135
authMap["tenantName"] = opts.TenantName
136136
}
137137

138-
return map[string]interface{}{"auth": authMap}, nil
138+
return map[string]any{"auth": authMap}, nil
139139
}
140140

141141
// ToTokenV3CreateMap allows AuthOptions to satisfy the AuthOptionsBuilder
142142
// interface in the v3 tokens package
143-
func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[string]interface{}, error) {
143+
func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]any) (map[string]any, error) {
144144
type domainReq struct {
145145
ID *string `json:"id,omitempty"`
146146
Name *string `json:"name,omitempty"`
@@ -392,15 +392,15 @@ func (opts *AuthOptions) ToTokenV3CreateMap(scope map[string]interface{}) (map[s
392392
}
393393

394394
if len(scope) != 0 {
395-
b["auth"].(map[string]interface{})["scope"] = scope
395+
b["auth"].(map[string]any)["scope"] = scope
396396
}
397397

398398
return b, nil
399399
}
400400

401401
// ToTokenV3ScopeMap builds a scope from AuthOptions and satisfies interface in
402402
// the v3 tokens package.
403-
func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
403+
func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]any, error) {
404404
// For backwards compatibility.
405405
// If AuthOptions.Scope was not set, try to determine it.
406406
// This works well for common scenarios.
@@ -418,15 +418,15 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
418418
}
419419

420420
if opts.Scope.System {
421-
return map[string]interface{}{
422-
"system": map[string]interface{}{
421+
return map[string]any{
422+
"system": map[string]any{
423423
"all": true,
424424
},
425425
}, nil
426426
}
427427

428428
if opts.Scope.TrustID != "" {
429-
return map[string]interface{}{
429+
return map[string]any{
430430
"OS-TRUST:trust": map[string]string{
431431
"id": opts.Scope.TrustID,
432432
},
@@ -445,20 +445,20 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
445445

446446
if opts.Scope.DomainID != "" {
447447
// ProjectName + DomainID
448-
return map[string]interface{}{
449-
"project": map[string]interface{}{
448+
return map[string]any{
449+
"project": map[string]any{
450450
"name": &opts.Scope.ProjectName,
451-
"domain": map[string]interface{}{"id": &opts.Scope.DomainID},
451+
"domain": map[string]any{"id": &opts.Scope.DomainID},
452452
},
453453
}, nil
454454
}
455455

456456
if opts.Scope.DomainName != "" {
457457
// ProjectName + DomainName
458-
return map[string]interface{}{
459-
"project": map[string]interface{}{
458+
return map[string]any{
459+
"project": map[string]any{
460460
"name": &opts.Scope.ProjectName,
461-
"domain": map[string]interface{}{"name": &opts.Scope.DomainName},
461+
"domain": map[string]any{"name": &opts.Scope.DomainName},
462462
},
463463
}, nil
464464
}
@@ -472,8 +472,8 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
472472
}
473473

474474
// ProjectID
475-
return map[string]interface{}{
476-
"project": map[string]interface{}{
475+
return map[string]any{
476+
"project": map[string]any{
477477
"id": &opts.Scope.ProjectID,
478478
},
479479
}, nil
@@ -484,15 +484,15 @@ func (opts *AuthOptions) ToTokenV3ScopeMap() (map[string]interface{}, error) {
484484
}
485485

486486
// DomainID
487-
return map[string]interface{}{
488-
"domain": map[string]interface{}{
487+
return map[string]any{
488+
"domain": map[string]any{
489489
"id": &opts.Scope.DomainID,
490490
},
491491
}, nil
492492
} else if opts.Scope.DomainName != "" {
493493
// DomainName
494-
return map[string]interface{}{
495-
"domain": map[string]interface{}{
494+
return map[string]any{
495+
"domain": map[string]any{
496496
"name": &opts.Scope.DomainName,
497497
},
498498
}, nil
@@ -512,6 +512,6 @@ func (opts AuthOptions) CanReauth() bool {
512512

513513
// ToTokenV3HeadersMap allows AuthOptions to satisfy the AuthOptionsBuilder
514514
// interface in the v3 tokens package.
515-
func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]interface{}) (map[string]string, error) {
515+
func (opts *AuthOptions) ToTokenV3HeadersMap(map[string]any) (map[string]string, error) {
516516
return nil, nil
517517
}

Diff for: errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (e ErrMissingInput) Error() string {
4141
// ErrInvalidInput is an error type used for most non-HTTP Gophercloud errors.
4242
type ErrInvalidInput struct {
4343
ErrMissingInput
44-
Value interface{}
44+
Value any
4545
}
4646

4747
func (e ErrInvalidInput) Error() string {

Diff for: internal/acceptance/clients/http.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ func (lrt *LogRoundTripper) logResponse(original io.ReadCloser, contentType stri
101101
// formatJSON will try to pretty-format a JSON body.
102102
// It will also mask known fields which contain sensitive information.
103103
func (lrt *LogRoundTripper) formatJSON(raw []byte) string {
104-
var rawData interface{}
104+
var rawData any
105105

106106
err := json.Unmarshal(raw, &rawData)
107107
if err != nil {
108108
log.Printf("[DEBUG] Unable to parse OpenStack JSON: %s", err)
109109
return string(raw)
110110
}
111111

112-
data, ok := rawData.(map[string]interface{})
112+
data, ok := rawData.(map[string]any)
113113
if !ok {
114114
pretty, err := json.MarshalIndent(rawData, "", " ")
115115
if err != nil {
@@ -121,24 +121,24 @@ func (lrt *LogRoundTripper) formatJSON(raw []byte) string {
121121
}
122122

123123
// Mask known password fields
124-
if v, ok := data["auth"].(map[string]interface{}); ok {
125-
if v, ok := v["identity"].(map[string]interface{}); ok {
126-
if v, ok := v["password"].(map[string]interface{}); ok {
127-
if v, ok := v["user"].(map[string]interface{}); ok {
124+
if v, ok := data["auth"].(map[string]any); ok {
125+
if v, ok := v["identity"].(map[string]any); ok {
126+
if v, ok := v["password"].(map[string]any); ok {
127+
if v, ok := v["user"].(map[string]any); ok {
128128
v["password"] = "***"
129129
}
130130
}
131-
if v, ok := v["application_credential"].(map[string]interface{}); ok {
131+
if v, ok := v["application_credential"].(map[string]any); ok {
132132
v["secret"] = "***"
133133
}
134-
if v, ok := v["token"].(map[string]interface{}); ok {
134+
if v, ok := v["token"].(map[string]any); ok {
135135
v["id"] = "***"
136136
}
137137
}
138138
}
139139

140140
// Ignore the catalog
141-
if v, ok := data["token"].(map[string]interface{}); ok {
141+
if v, ok := data["token"].(map[string]any); ok {
142142
if _, ok := v["catalog"]; ok {
143143
return ""
144144
}

Diff for: internal/acceptance/openstack/baremetal/v1/baremetal.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func CreateNode(t *testing.T, client *gophercloud.ServiceClient) (*nodes.Node, e
2222
Driver: "ipmi",
2323
BootInterface: "ipxe",
2424
RAIDInterface: "agent",
25-
DriverInfo: map[string]interface{}{
25+
DriverInfo: map[string]any{
2626
"ipmi_port": "6230",
2727
"ipmi_username": "admin",
2828
"deploy_kernel": "http://172.22.0.1/images/tinyipa-stable-rocky.vmlinuz",
@@ -86,7 +86,7 @@ func CreateFakeNode(t *testing.T, client *gophercloud.ServiceClient) (*nodes.Nod
8686
Driver: "fake-hardware",
8787
BootInterface: "fake",
8888
DeployInterface: "fake",
89-
DriverInfo: map[string]interface{}{
89+
DriverInfo: map[string]any{
9090
"ipmi_port": "6230",
9191
"ipmi_username": "admin",
9292
"deploy_kernel": "http://172.22.0.1/images/tinyipa-stable-rocky.vmlinuz",

Diff for: internal/acceptance/openstack/baremetal/v1/nodes_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func TestNodesRAIDConfig(t *testing.T) {
167167
IsRootVolume: &isTrue,
168168
RAIDLevel: nodes.RAID5,
169169
Controller: "software",
170-
PhysicalDisks: []interface{}{
170+
PhysicalDisks: []any{
171171
map[string]string{
172172
"size": "> 100",
173173
},

Diff for: internal/acceptance/openstack/blockstorage/v3/quotaset_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ var UpdateQuotaOpts = quotasets.UpdateOpts{
5656
Backups: gophercloud.IntToPointer(2),
5757
BackupGigabytes: gophercloud.IntToPointer(300),
5858
Groups: gophercloud.IntToPointer(350),
59-
Extra: map[string]interface{}{
59+
Extra: map[string]any{
6060
"volumes_foo": gophercloud.IntToPointer(100),
6161
},
6262
}
@@ -133,7 +133,7 @@ func TestQuotasetUpdate(t *testing.T) {
133133

134134
// unpopulate resultQuotas.Extra as it is different per cloud and test
135135
// rest of the quotaSet
136-
resultQuotas.Extra = map[string]interface{}(nil)
136+
resultQuotas.Extra = map[string]any(nil)
137137
th.AssertDeepEquals(t, UpdatedQuotas, *resultQuotas)
138138
}
139139

Diff for: internal/acceptance/openstack/compute/v2/aggregates_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestAggregatesSetRemoveMetadata(t *testing.T) {
107107
defer DeleteAggregate(t, client, aggregate)
108108

109109
opts := aggregates.SetMetadataOpts{
110-
Metadata: map[string]interface{}{"key": "value"},
110+
Metadata: map[string]any{"key": "value"},
111111
}
112112

113113
aggregateWithMetadata, err := aggregates.SetMetadata(context.TODO(), client, aggregate.ID, opts).Extract()
@@ -120,7 +120,7 @@ func TestAggregatesSetRemoveMetadata(t *testing.T) {
120120
}
121121

122122
optsToRemove := aggregates.SetMetadataOpts{
123-
Metadata: map[string]interface{}{"key": nil},
123+
Metadata: map[string]any{"key": nil},
124124
}
125125

126126
aggregateWithRemovedKey, err := aggregates.SetMetadata(context.TODO(), client, aggregate.ID, optsToRemove).Extract()

Diff for: internal/acceptance/openstack/compute/v2/attachinterfaces_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func TestAttachDetachInterface(t *testing.T) {
3535
th.AssertNoErr(t, err)
3636

3737
var found bool
38-
for _, networkAddresses := range server.Addresses[choices.NetworkName].([]interface{}) {
39-
address := networkAddresses.(map[string]interface{})
38+
for _, networkAddresses := range server.Addresses[choices.NetworkName].([]any) {
39+
address := networkAddresses.(map[string]any)
4040
if address["OS-EXT-IPS:type"] == "fixed" {
4141
fixedIP := address["addr"].(string)
4242

Diff for: internal/acceptance/openstack/db/v1/configurations_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestConfigurationsCRUD(t *testing.T) {
3434
}
3535
createOpts.Datastore = &datastore
3636

37-
values := make(map[string]interface{})
37+
values := make(map[string]any)
3838
values["collation_server"] = "latin1_swedish_ci"
3939
createOpts.Values = values
4040

Diff for: internal/acceptance/openstack/identity/v3/groups_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestGroupCRUD(t *testing.T) {
2323
createOpts := groups.CreateOpts{
2424
Description: description,
2525
DomainID: domainID,
26-
Extra: map[string]interface{}{
26+
Extra: map[string]any{
2727
"email": "[email protected]",
2828
},
2929
}
@@ -43,7 +43,7 @@ func TestGroupCRUD(t *testing.T) {
4343
description = ""
4444
updateOpts := groups.UpdateOpts{
4545
Description: &description,
46-
Extra: map[string]interface{}{
46+
Extra: map[string]any{
4747
"email": "[email protected]",
4848
},
4949
}

Diff for: internal/acceptance/openstack/identity/v3/policies_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestPoliciesCRUD(t *testing.T) {
3838
createOpts := policies.CreateOpts{
3939
Type: "application/json",
4040
Blob: []byte("{'foobar_user': 'role:compute-user'}"),
41-
Extra: map[string]interface{}{
41+
Extra: map[string]any{
4242
"description": "policy for foobar_user",
4343
},
4444
}
@@ -124,7 +124,7 @@ func TestPoliciesCRUD(t *testing.T) {
124124
updateOpts := policies.UpdateOpts{
125125
Type: "text/plain",
126126
Blob: []byte("'foobar_user': 'role:compute-user'"),
127-
Extra: map[string]interface{}{
127+
Extra: map[string]any{
128128
"description": "updated policy for foobar_user",
129129
},
130130
}

Diff for: internal/acceptance/openstack/identity/v3/regions_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestRegionsCRUD(t *testing.T) {
6363
createOpts := regions.CreateOpts{
6464
ID: "testregion",
6565
Description: "Region for testing",
66-
Extra: map[string]interface{}{
66+
Extra: map[string]any{
6767
"email": "[email protected]",
6868
},
6969
}
@@ -84,7 +84,7 @@ func TestRegionsCRUD(t *testing.T) {
8484
// is not updatable, see: https://bugs.launchpad.net/keystone/+bug/1729933
8585
// The following lines should be uncommented once the fix is merged.
8686
87-
Extra: map[string]interface{}{
87+
Extra: map[string]any{
8888
"email": "[email protected]",
8989
},
9090
*/

Diff for: internal/acceptance/openstack/identity/v3/roles_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestRolesCRUD(t *testing.T) {
5959

6060
createOpts := roles.CreateOpts{
6161
Name: "testrole",
62-
Extra: map[string]interface{}{
62+
Extra: map[string]any{
6363
"description": "test role description",
6464
},
6565
}
@@ -92,7 +92,7 @@ func TestRolesCRUD(t *testing.T) {
9292
th.AssertEquals(t, found, true)
9393

9494
updateOpts := roles.UpdateOpts{
95-
Extra: map[string]interface{}{
95+
Extra: map[string]any{
9696
"description": "updated test role description",
9797
},
9898
}
@@ -114,7 +114,7 @@ func TestRolesFilterList(t *testing.T) {
114114

115115
createOpts := roles.CreateOpts{
116116
Name: "testrole",
117-
Extra: map[string]interface{}{
117+
Extra: map[string]any{
118118
"description": "test role description",
119119
},
120120
}
@@ -798,7 +798,7 @@ func TestCRUDRoleInferenceRule(t *testing.T) {
798798

799799
priorRoleCreateOpts := roles.CreateOpts{
800800
Name: "priorRole",
801-
Extra: map[string]interface{}{
801+
Extra: map[string]any{
802802
"description": "prior_role description",
803803
},
804804
}
@@ -811,7 +811,7 @@ func TestCRUDRoleInferenceRule(t *testing.T) {
811811

812812
impliedRoleCreateOpts := roles.CreateOpts{
813813
Name: "impliedRole",
814-
Extra: map[string]interface{}{
814+
Extra: map[string]any{
815815
"description": "implied_role description",
816816
},
817817
}

0 commit comments

Comments
 (0)