Skip to content

Commit 06c6b07

Browse files
committed
lint: Remove embedded fields from selectors
This looks complicated, but it's just a whole lot of sed invocations. Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent e33aa68 commit 06c6b07

File tree

55 files changed

+122
-125
lines changed

Some content is hidden

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

55 files changed

+122
-125
lines changed

.golangci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ linters:
2727
- linters:
2828
- staticcheck
2929
text: "ST1005: error strings should not end with punctuation or newlines"
30-
- linters:
31-
- staticcheck
32-
text: "could remove embedded field \".*\" from selector"
3330
- path: (.+)\.go$
3431
text: SA1006
3532
paths:

docs/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Please see our dedicated document [here](MICROVERSIONS.md).
88

99
You can implement custom logging and/or limit re-auth attempts by creating a custom HTTP client
1010
like the following and setting it as the provider client's HTTP Client (via the
11-
`gophercloud.ProviderClient.HTTPClient` field):
11+
`gophercloud.HTTPClient` field):
1212

1313
```go
1414
//...

internal/acceptance/openstack/identity/v3/oauth1_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func oauth1MethodTest(t *testing.T, client *gophercloud.ServiceClient, consumer
215215
tokens.Token
216216
oauth1.TokenExt
217217
}
218-
tokenRes := tokens.Get(context.TODO(), newClient, newClient.ProviderClient.TokenID)
218+
tokenRes := tokens.Get(context.TODO(), newClient, newClient.TokenID)
219219
err = tokenRes.ExtractInto(&token)
220220
th.AssertNoErr(t, err)
221221
oauth1Roles, err := tokenRes.ExtractRoles()

internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ func TestListPortWithSubports(t *testing.T) {
7979
th.AssertEquals(t, 1, len(allPorts))
8080
port := allPorts[0]
8181

82-
th.AssertEquals(t, trunk.ID, port.TrunkDetails.TrunkID)
83-
th.AssertEquals(t, 2, len(port.TrunkDetails.SubPorts))
82+
th.AssertEquals(t, trunk.ID, port.TrunkID)
83+
th.AssertEquals(t, 2, len(port.SubPorts))
8484

8585
// Note that MAC address is not (currently) returned in list queries. We
8686
// exclude it from the comparison here in case it's ever added. MAC
@@ -92,32 +92,32 @@ func TestListPortWithSubports(t *testing.T) {
9292
SegmentationID: 1,
9393
SegmentationType: "vlan",
9494
PortID: subport1.ID,
95-
}, port.TrunkDetails.SubPorts[0].Subport)
95+
}, port.SubPorts[0].Subport)
9696
th.AssertDeepEquals(t, trunks.Subport{
9797
SegmentationID: 2,
9898
SegmentationType: "vlan",
9999
PortID: subport2.ID,
100-
}, port.TrunkDetails.SubPorts[1].Subport)
100+
}, port.SubPorts[1].Subport)
101101

102102
// Test GET port with trunk details
103103
err = ports.Get(context.TODO(), client, parentPort.ID).ExtractInto(&port)
104104
th.AssertNoErr(t, err)
105-
th.AssertEquals(t, trunk.ID, port.TrunkDetails.TrunkID)
106-
th.AssertEquals(t, 2, len(port.TrunkDetails.SubPorts))
105+
th.AssertEquals(t, trunk.ID, port.TrunkID)
106+
th.AssertEquals(t, 2, len(port.SubPorts))
107107
th.AssertDeepEquals(t, trunk_details.Subport{
108108
Subport: trunks.Subport{
109109
SegmentationID: 1,
110110
SegmentationType: "vlan",
111111
PortID: subport1.ID,
112112
},
113113
MACAddress: subport1.MACAddress,
114-
}, port.TrunkDetails.SubPorts[0])
114+
}, port.SubPorts[0])
115115
th.AssertDeepEquals(t, trunk_details.Subport{
116116
Subport: trunks.Subport{
117117
SegmentationID: 2,
118118
SegmentationType: "vlan",
119119
PortID: subport2.ID,
120120
},
121121
MACAddress: subport2.MACAddress,
122-
}, port.TrunkDetails.SubPorts[1])
122+
}, port.SubPorts[1])
123123
}

internal/acceptance/openstack/objectstorage/v1/objects_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func TestObjects(t *testing.T) {
100100
})
101101
th.AssertNoErr(t, err)
102102

103-
resp, err := client.ProviderClient.HTTPClient.Get(objURLs[i])
103+
resp, err := client.HTTPClient.Get(objURLs[i])
104104
th.AssertNoErr(t, err)
105105
if resp.StatusCode != http.StatusOK {
106106
resp.Body.Close()
@@ -121,7 +121,7 @@ func TestObjects(t *testing.T) {
121121
})
122122
th.AssertNoErr(t, err)
123123

124-
resp, err = client.ProviderClient.HTTPClient.Get(objURLs[i])
124+
resp, err = client.HTTPClient.Get(objURLs[i])
125125
th.AssertNoErr(t, err)
126126
if resp.StatusCode != http.StatusOK {
127127
resp.Body.Close()

openstack/baremetal/v1/allocations/results.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ func (r allocationResult) Extract() (*Allocation, error) {
5656
}
5757

5858
func (r allocationResult) ExtractInto(v any) error {
59-
return r.Result.ExtractIntoStructPtr(v, "")
59+
return r.ExtractIntoStructPtr(v, "")
6060
}
6161

6262
func ExtractAllocationsInto(r pagination.Page, v any) error {
63-
return r.(AllocationPage).Result.ExtractIntoSlicePtr(v, "allocations")
63+
return r.(AllocationPage).ExtractIntoSlicePtr(v, "allocations")
6464
}
6565

6666
// AllocationPage abstracts the raw results of making a List() request against

openstack/baremetal/v1/conductors/results.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ func (r conductorResult) Extract() (*Conductor, error) {
1919
}
2020

2121
func (r conductorResult) ExtractInto(v any) error {
22-
return r.Result.ExtractIntoStructPtr(v, "")
22+
return r.ExtractIntoStructPtr(v, "")
2323
}
2424

2525
func ExtractConductorInto(r pagination.Page, v any) error {
26-
return r.(ConductorPage).Result.ExtractIntoSlicePtr(v, "conductors")
26+
return r.(ConductorPage).ExtractIntoSlicePtr(v, "conductors")
2727
}
2828

2929
// Conductor represents a conductor in the OpenStack Bare Metal API.

openstack/baremetal/v1/drivers/results.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ func (r driverResult) Extract() (*Driver, error) {
1717
}
1818

1919
func (r driverResult) ExtractInto(v any) error {
20-
return r.Result.ExtractIntoStructPtr(v, "")
20+
return r.ExtractIntoStructPtr(v, "")
2121
}
2222

2323
func ExtractDriversInto(r pagination.Page, v any) error {
24-
return r.(DriverPage).Result.ExtractIntoSlicePtr(v, "drivers")
24+
return r.(DriverPage).ExtractIntoSlicePtr(v, "drivers")
2525
}
2626

2727
// Driver represents a driver in the OpenStack Bare Metal API.

openstack/baremetal/v1/nodes/results.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ func (r ValidateResult) Extract() (*NodeValidation, error) {
4747
}
4848

4949
func (r nodeResult) ExtractInto(v any) error {
50-
return r.Result.ExtractIntoStructPtr(v, "")
50+
return r.ExtractIntoStructPtr(v, "")
5151
}
5252

5353
func ExtractNodesInto(r pagination.Page, v any) error {
54-
return r.(NodePage).Result.ExtractIntoSlicePtr(v, "nodes")
54+
return r.(NodePage).ExtractIntoSlicePtr(v, "nodes")
5555
}
5656

5757
// Extract interprets a BIOSSettingsResult as an array of BIOSSetting structs, if possible.

openstack/baremetal/v1/nodes/testing/results_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func TestStandardPluginData(t *testing.T) {
1515
var pluginData nodes.PluginData
16-
err := pluginData.RawMessage.UnmarshalJSON([]byte(invtest.StandardPluginDataSample))
16+
err := pluginData.UnmarshalJSON([]byte(invtest.StandardPluginDataSample))
1717
th.AssertNoErr(t, err)
1818

1919
parsedData, err := pluginData.AsStandardData()
@@ -28,7 +28,7 @@ func TestStandardPluginData(t *testing.T) {
2828

2929
func TestInspectorPluginData(t *testing.T) {
3030
var pluginData nodes.PluginData
31-
err := pluginData.RawMessage.UnmarshalJSON([]byte(insptest.IntrospectionDataJSONSample))
31+
err := pluginData.UnmarshalJSON([]byte(insptest.IntrospectionDataJSONSample))
3232
th.AssertNoErr(t, err)
3333

3434
parsedData, err := pluginData.AsInspectorData()
@@ -43,7 +43,7 @@ func TestInspectorPluginData(t *testing.T) {
4343

4444
func TestGuessFormatUnknownDefaultsToIronic(t *testing.T) {
4545
var pluginData nodes.PluginData
46-
err := pluginData.RawMessage.UnmarshalJSON([]byte("{}"))
46+
err := pluginData.UnmarshalJSON([]byte("{}"))
4747
th.AssertNoErr(t, err)
4848

4949
irData, inspData, err := pluginData.GuessFormat()
@@ -54,7 +54,7 @@ func TestGuessFormatUnknownDefaultsToIronic(t *testing.T) {
5454

5555
func TestGuessFormatErrors(t *testing.T) {
5656
var pluginData nodes.PluginData
57-
err := pluginData.RawMessage.UnmarshalJSON([]byte("\"banana\""))
57+
err := pluginData.UnmarshalJSON([]byte("\"banana\""))
5858
th.AssertNoErr(t, err)
5959

6060
irData, inspData, err := pluginData.GuessFormat()
@@ -65,7 +65,7 @@ func TestGuessFormatErrors(t *testing.T) {
6565
failsInspectorConversion := `{
6666
"interfaces": "banana"
6767
}`
68-
err = pluginData.RawMessage.UnmarshalJSON([]byte(failsInspectorConversion))
68+
err = pluginData.UnmarshalJSON([]byte(failsInspectorConversion))
6969
th.AssertNoErr(t, err)
7070

7171
irData, inspData, err = pluginData.GuessFormat()

0 commit comments

Comments
 (0)