From adbe8ebe8b1e7cb27cb93fb8daac3c33757eb83f Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 10:53:40 +0100 Subject: [PATCH 01/10] Bump golangci-lint to latest version Done by bumping the version in the Makefile and running the 'golangci-lint migrate' command via podman as we do in the Makefile. podman run -t --rm -v $PWD:/app -w /app \ golangci/golangci-lint:v2.1.6 \ golangci-lint migrate This yields a number of news error from staticcheck, listed below, which we temporarily ignore pending a fix. S1038: should use fmt.Fprintf instead of fmt.Fprint(fmt.Sprintf(...)) ST1005: error strings should not be capitalized ST1005: error strings should not end with punctuation or newlines ST1017: don't use Yoda conditions ST1019: package ".*" is being imported more than once ST1019(related information): other import of ".*" ST1023: should omit type .* from declaration; it will be inferred from the right-hand side QF1011: could omit type .* from declaration; it will be inferred from the right-hand side QF1001: could apply De Morgan's law QF1003: could use tagged switch on .* QF1004: could use strings.ReplaceAll instead QF1008: could remove embedded field ".*" from selector Signed-off-by: Stephen Finucane --- .golangci.yaml | 77 ++++++++++++++++++++++++++++++++++++++++++-------- Makefile | 2 +- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 828a099a40..d11ed705a8 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,19 +1,72 @@ ---- +version: "2" linters: - disable-all: true + default: none enable: - errcheck - - gofmt - - goimports - govet - staticcheck - unparam - unused - -issues: - exclude: - - SA1006 # printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck) - exclude-rules: - - linters: - - staticcheck - text: 'SA1019: (x509.EncryptPEMBlock|strings.Title)' + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - staticcheck + text: "S1038: should use fmt.Fprintf instead of fmt.Fprint" + - linters: + - staticcheck + text: "SA1019: (x509.EncryptPEMBlock|strings.Title)" + - linters: + - staticcheck + text: "ST1005: error strings should not be capitalized" + - linters: + - staticcheck + text: "ST1005: error strings should not end with punctuation or newlines" + - linters: + - staticcheck + text: "ST1017: don't use Yoda conditions" + - linters: + - staticcheck + text: "ST1019: package \".*\" is being imported more than once" + - linters: + - staticcheck + text: "ST1019\\(related information\\): other import of \".*\"" + - linters: + - staticcheck + text: "ST1023: should omit type .* from declaration; it will be inferred from the right-hand side" + - linters: + - staticcheck + text: "QF1001: could apply De Morgan's law" + - linters: + - staticcheck + text: "QF1003: could use tagged switch on .*" + - linters: + - staticcheck + text: "QF1004: could use strings.ReplaceAll instead" + - linters: + - staticcheck + text: "QF1011: could omit type .* from declaration; it will be inferred from the right-hand side" + - linters: + - staticcheck + text: "could remove embedded field \".*\" from selector" + - path: (.+)\.go$ + text: SA1006 + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/Makefile b/Makefile index 5dfd8ad2f1..3b53abc9d1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ undefine GOFLAGS -GOLANGCI_LINT_VERSION?=v1.62.2 +GOLANGCI_LINT_VERSION?=v2.1.6 GO_TEST?=go run gotest.tools/gotestsum@latest --format testname -- TIMEOUT := "60m" From 536e908d33ce53ed9ddbd058a4af7b8d0b26173b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:13:31 +0100 Subject: [PATCH 02/10] lint: Remove duplicate imports Signed-off-by: Stephen Finucane --- .golangci.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index d11ed705a8..8dddf0772b 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -30,12 +30,6 @@ linters: - linters: - staticcheck text: "ST1017: don't use Yoda conditions" - - linters: - - staticcheck - text: "ST1019: package \".*\" is being imported more than once" - - linters: - - staticcheck - text: "ST1019\\(related information\\): other import of \".*\"" - linters: - staticcheck text: "ST1023: should omit type .* from declaration; it will be inferred from the right-hand side" From 338e3aa62cb0d418e5472bbe2307e56918f68f23 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:14:04 +0100 Subject: [PATCH 03/10] lint: Remove unnecessary explicit type declarations Signed-off-by: Stephen Finucane --- .golangci.yaml | 6 ------ internal/acceptance/openstack/identity/v3/domains_test.go | 6 +++--- internal/acceptance/openstack/identity/v3/projects_test.go | 2 +- internal/acceptance/openstack/identity/v3/users_test.go | 2 +- openstack/identity/v3/domains/doc.go | 4 ++-- openstack/identity/v3/services/doc.go | 2 +- openstack/messaging/v2/queues/testing/requests_test.go | 2 +- .../v2/extensions/agents/testing/requests_test.go | 2 +- .../v2/extensions/external/testing/requests_test.go | 2 +- 9 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 8dddf0772b..0fa4d35f6e 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -30,9 +30,6 @@ linters: - linters: - staticcheck text: "ST1017: don't use Yoda conditions" - - linters: - - staticcheck - text: "ST1023: should omit type .* from declaration; it will be inferred from the right-hand side" - linters: - staticcheck text: "QF1001: could apply De Morgan's law" @@ -42,9 +39,6 @@ linters: - linters: - staticcheck text: "QF1004: could use strings.ReplaceAll instead" - - linters: - - staticcheck - text: "QF1011: could omit type .* from declaration; it will be inferred from the right-hand side" - linters: - staticcheck text: "could remove embedded field \".*\" from selector" diff --git a/internal/acceptance/openstack/identity/v3/domains_test.go b/internal/acceptance/openstack/identity/v3/domains_test.go index 3d1208ae9c..28cbea7f70 100644 --- a/internal/acceptance/openstack/identity/v3/domains_test.go +++ b/internal/acceptance/openstack/identity/v3/domains_test.go @@ -35,7 +35,7 @@ func TestDomainsList(t *testing.T) { client, err := clients.NewIdentityV3Client() th.AssertNoErr(t, err) - var iTrue bool = true + var iTrue = true listOpts := domains.ListOpts{ Enabled: &iTrue, } @@ -78,7 +78,7 @@ func TestDomainsCRUD(t *testing.T) { client, err := clients.NewIdentityV3Client() th.AssertNoErr(t, err) - var iTrue bool = true + var iTrue = true var description = "Testing Domain" createOpts := domains.CreateOpts{ Description: description, @@ -93,7 +93,7 @@ func TestDomainsCRUD(t *testing.T) { th.AssertEquals(t, domain.Description, description) - var iFalse bool = false + var iFalse = false description = "" updateOpts := domains.UpdateOpts{ Description: &description, diff --git a/internal/acceptance/openstack/identity/v3/projects_test.go b/internal/acceptance/openstack/identity/v3/projects_test.go index 528a30b2a7..12bac084fe 100644 --- a/internal/acceptance/openstack/identity/v3/projects_test.go +++ b/internal/acceptance/openstack/identity/v3/projects_test.go @@ -35,7 +35,7 @@ func TestProjectsList(t *testing.T) { client, err := clients.NewIdentityV3Client() th.AssertNoErr(t, err) - var iTrue bool = true + var iTrue = true listOpts := projects.ListOpts{ Enabled: &iTrue, } diff --git a/internal/acceptance/openstack/identity/v3/users_test.go b/internal/acceptance/openstack/identity/v3/users_test.go index 9b2e63bfdf..31b04b7512 100644 --- a/internal/acceptance/openstack/identity/v3/users_test.go +++ b/internal/acceptance/openstack/identity/v3/users_test.go @@ -20,7 +20,7 @@ func TestUsersList(t *testing.T) { client, err := clients.NewIdentityV3Client() th.AssertNoErr(t, err) - var iTrue bool = true + var iTrue = true listOpts := users.ListOpts{ Enabled: &iTrue, } diff --git a/openstack/identity/v3/domains/doc.go b/openstack/identity/v3/domains/doc.go index 618b2f6d42..34611f5c18 100644 --- a/openstack/identity/v3/domains/doc.go +++ b/openstack/identity/v3/domains/doc.go @@ -3,7 +3,7 @@ Package domains manages and retrieves Domains in the OpenStack Identity Service. Example to List Domains - var iTrue bool = true + var iTrue = true listOpts := domains.ListOpts{ Enabled: &iTrue, } @@ -38,7 +38,7 @@ Example to Update a Domain domainID := "0fe36e73809d46aeae6705c39077b1b3" - var iFalse bool = false + var iFalse = false updateOpts := domains.UpdateOpts{ Enabled: &iFalse, } diff --git a/openstack/identity/v3/services/doc.go b/openstack/identity/v3/services/doc.go index 3d980b4349..51659f9fa7 100644 --- a/openstack/identity/v3/services/doc.go +++ b/openstack/identity/v3/services/doc.go @@ -41,7 +41,7 @@ Example to Update a Service serviceID := "3c7bbe9a6ecb453ca1789586291380ed" - var iFalse bool = false + var iFalse = false updateOpts := services.UpdateOpts{ Enabled: &iFalse, Extra: map[string]any{ diff --git a/openstack/messaging/v2/queues/testing/requests_test.go b/openstack/messaging/v2/queues/testing/requests_test.go index 8f882cf12c..d64c374561 100644 --- a/openstack/messaging/v2/queues/testing/requests_test.go +++ b/openstack/messaging/v2/queues/testing/requests_test.go @@ -42,7 +42,7 @@ func TestCreate(t *testing.T) { fakeServer := th.SetupHTTP() defer fakeServer.Teardown() HandleCreateSuccessfully(t, fakeServer) - var enableEncrypted *bool = new(bool) + var enableEncrypted = new(bool) createOpts := queues.CreateOpts{ QueueName: QueueName, diff --git a/openstack/networking/v2/extensions/agents/testing/requests_test.go b/openstack/networking/v2/extensions/agents/testing/requests_test.go index e5b5888c43..a48d629eb5 100644 --- a/openstack/networking/v2/extensions/agents/testing/requests_test.go +++ b/openstack/networking/v2/extensions/agents/testing/requests_test.go @@ -355,7 +355,7 @@ func TestListL3Routers(t *testing.T) { }, } - var snat bool = true + var snat = true gw := routers.GatewayInfo{ EnableSNAT: &snat, NetworkID: "ae34051f-aa6c-4c75-abf5-50dc9ac99ef3", diff --git a/openstack/networking/v2/extensions/external/testing/requests_test.go b/openstack/networking/v2/extensions/external/testing/requests_test.go index aa60ee4424..6b6c3017dc 100644 --- a/openstack/networking/v2/extensions/external/testing/requests_test.go +++ b/openstack/networking/v2/extensions/external/testing/requests_test.go @@ -9,7 +9,7 @@ import ( ) func TestListExternal(t *testing.T) { - var iTrue bool = true + var iTrue = true networkListOpts := networks.ListOpts{ ID: "d32019d3-bc6e-4319-9c1d-6722fc136a22", From df5600e692ee183be713673393914fdad9684891 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:19:00 +0100 Subject: [PATCH 04/10] lint: Simplify conditionals Signed-off-by: Stephen Finucane --- .golangci.yaml | 6 ------ internal/acceptance/clients/conditions.go | 4 ++-- .../networking/v2/extensions/agents/agents_test.go | 4 ++-- openstack/networking/v2/extensions/agents/results.go | 2 +- openstack/orchestration/v1/stacks/template.go | 2 +- openstack/orchestration/v1/stacks/utils.go | 2 +- params.go | 2 +- testhelper/convenience.go | 4 ++-- 8 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 0fa4d35f6e..28bf5ecf15 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -27,12 +27,6 @@ linters: - linters: - staticcheck text: "ST1005: error strings should not end with punctuation or newlines" - - linters: - - staticcheck - text: "ST1017: don't use Yoda conditions" - - linters: - - staticcheck - text: "QF1001: could apply De Morgan's law" - linters: - staticcheck text: "QF1003: could use tagged switch on .*" diff --git a/internal/acceptance/clients/conditions.go b/internal/acceptance/clients/conditions.go index 6077f4bdef..f5eaa578b3 100644 --- a/internal/acceptance/clients/conditions.go +++ b/internal/acceptance/clients/conditions.go @@ -94,7 +94,7 @@ func IsCurrentAbove(t *testing.T, release string) bool { if isReleaseNumeral(current) && !isReleaseNumeral(release) { return true } - if current > release && !(!isReleaseNumeral(current) && isReleaseNumeral(release)) { + if current > release && (isReleaseNumeral(current) || !isReleaseNumeral(release)) { return true } } @@ -118,7 +118,7 @@ func IsCurrentBelow(t *testing.T, release string) bool { if isReleaseNumeral(release) && !isReleaseNumeral(current) { return true } - if release > current && !(!isReleaseNumeral(release) && isReleaseNumeral(current)) { + if release > current && (isReleaseNumeral(release) || !isReleaseNumeral(current)) { return true } } diff --git a/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go index fd1cf3f544..ff6bc9b016 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/agents/agents_test.go @@ -165,7 +165,7 @@ func TestBGPAgentCRUD(t *testing.T) { agentConf := bgpAgent.Configurations numOfSpeakers := int(agentConf["bgp_speakers"].(float64)) t.Logf("Agent %s has %d speaker(s)", agentID, numOfSpeakers) - return 1 == numOfSpeakers, nil + return numOfSpeakers == 1, nil }, timeout) th.AssertNoErr(t, err) @@ -201,7 +201,7 @@ func TestBGPAgentCRUD(t *testing.T) { agentConf := bgpAgent.Configurations numOfSpeakers := int(agentConf["bgp_speakers"].(float64)) t.Logf("Agent %s has %d speaker(s)", bgpAgent.ID, numOfSpeakers) - return 0 == numOfSpeakers, nil + return numOfSpeakers == 0, nil }, timeout) th.AssertNoErr(t, err) } diff --git a/openstack/networking/v2/extensions/agents/results.go b/openstack/networking/v2/extensions/agents/results.go index 166702009d..4e13e212ba 100644 --- a/openstack/networking/v2/extensions/agents/results.go +++ b/openstack/networking/v2/extensions/agents/results.go @@ -205,7 +205,7 @@ func (r ListBGPSpeakersResult) IsEmpty() (bool, error) { } speakers, err := ExtractBGPSpeakers(r) - return 0 == len(speakers), err + return len(speakers) == 0, err } // ExtractBGPSpeakers inteprets the ListBGPSpeakersResult into an array of BGP speakers diff --git a/openstack/orchestration/v1/stacks/template.go b/openstack/orchestration/v1/stacks/template.go index 75eb6a97cf..af49c612a0 100644 --- a/openstack/orchestration/v1/stacks/template.go +++ b/openstack/orchestration/v1/stacks/template.go @@ -202,7 +202,7 @@ func ignoreIfTemplate(key string, value any) bool { return true } // `.template` and `.yaml` are allowed suffixes for template URLs when referred to by `type` - if key == "type" && !(strings.HasSuffix(valueString, ".template") || strings.HasSuffix(valueString, ".yaml")) { + if key == "type" && !strings.HasSuffix(valueString, ".template") && !strings.HasSuffix(valueString, ".yaml") { return true } return false diff --git a/openstack/orchestration/v1/stacks/utils.go b/openstack/orchestration/v1/stacks/utils.go index 56bc48d041..228335388f 100644 --- a/openstack/orchestration/v1/stacks/utils.go +++ b/openstack/orchestration/v1/stacks/utils.go @@ -80,7 +80,7 @@ func (t *TE) Fetch() error { if err != nil { return err } - if !(resp.StatusCode >= 200 && resp.StatusCode < 300) { + if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("error fetching %s: %s", t.URL, resp.Status) } t.Bin = body diff --git a/params.go b/params.go index 4a2ed6c942..f7135b2dfa 100644 --- a/params.go +++ b/params.go @@ -109,7 +109,7 @@ func BuildRequestBody(opts any, parent string) (map[string]any, error) { } xorFieldIsZero = isZero(xorField) } - if !(zero != xorFieldIsZero) { + if zero == xorFieldIsZero { err := ErrMissingInput{} err.Argument = fmt.Sprintf("%s/%s", f.Name, xorTag) err.Info = fmt.Sprintf("Exactly one of %s and %s must be provided", f.Name, xorTag) diff --git a/testhelper/convenience.go b/testhelper/convenience.go index 1ea727045f..57fa558fd1 100644 --- a/testhelper/convenience.go +++ b/testhelper/convenience.go @@ -433,7 +433,7 @@ func CheckErr(t *testing.T, e error, expected ...any) { func AssertIntLesserOrEqual(t *testing.T, v1 int, v2 int) { t.Helper() - if !(v1 <= v2) { + if v1 > v2 { logFatal(t, fmt.Sprintf("The first value \"%v\" is greater than the second value \"%v\"", v1, v2)) } } @@ -442,7 +442,7 @@ func AssertIntLesserOrEqual(t *testing.T, v1 int, v2 int) { func AssertIntGreaterOrEqual(t *testing.T, v1 int, v2 int) { t.Helper() - if !(v1 >= v2) { + if v1 < v2 { logFatal(t, fmt.Sprintf("The first value \"%v\" is lesser than the second value \"%v\"", v1, v2)) } } From 5795a379184886735652838b7970b6440e27573a Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:26:20 +0100 Subject: [PATCH 05/10] lint: Prefer switch statements over conditional ladders Signed-off-by: Stephen Finucane --- .golangci.yaml | 3 --- openstack/image/v2/imagedata/testing/requests_test.go | 9 +++++---- .../v2/extensions/bgp/speakers/testing/requests_test.go | 7 ++++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 28bf5ecf15..054ab275e2 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -27,9 +27,6 @@ linters: - linters: - staticcheck text: "ST1005: error strings should not end with punctuation or newlines" - - linters: - - staticcheck - text: "QF1003: could use tagged switch on .*" - linters: - staticcheck text: "QF1004: could use strings.ReplaceAll instead" diff --git a/openstack/image/v2/imagedata/testing/requests_test.go b/openstack/image/v2/imagedata/testing/requests_test.go index ad4dba86f1..3a5c26706c 100644 --- a/openstack/image/v2/imagedata/testing/requests_test.go +++ b/openstack/image/v2/imagedata/testing/requests_test.go @@ -74,13 +74,14 @@ func min(a int, b int) int { func (rs *RS) Seek(offset int64, whence int) (int64, error) { var offsetInt = int(offset) - if whence == 0 { + switch whence { + case 0: rs.offset = offsetInt - } else if whence == 1 { + case 1: rs.offset = rs.offset + offsetInt - } else if whence == 2 { + case 2: rs.offset = len(rs.bs) - offsetInt - } else { + default: return 0, fmt.Errorf("For parameter `whence`, expected value in {0,1,2} but got: %#v", whence) } diff --git a/openstack/networking/v2/extensions/bgp/speakers/testing/requests_test.go b/openstack/networking/v2/extensions/bgp/speakers/testing/requests_test.go index edcf11637b..2970094f30 100644 --- a/openstack/networking/v2/extensions/bgp/speakers/testing/requests_test.go +++ b/openstack/networking/v2/extensions/bgp/speakers/testing/requests_test.go @@ -119,13 +119,14 @@ func TestUpdate(t *testing.T) { bgpSpeakerID := "ab01ade1-ae62-43c9-8a1f-3c24225b96d8" fakeServer.Mux.HandleFunc("/v2.0/bgp-speakers/"+bgpSpeakerID, func(w http.ResponseWriter, r *http.Request) { - if r.Method == "GET" { + switch r.Method { + case "GET": th.TestMethod(t, r, "GET") th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) fmt.Fprint(w, GetBGPSpeakerResult) - } else if r.Method == "PUT" { + case "PUT": th.TestMethod(t, r, "PUT") th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) th.TestHeader(t, r, "Content-Type", "application/json") @@ -135,7 +136,7 @@ func TestUpdate(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) fmt.Fprint(w, UpdateBGPSpeakerResponse) - } else { + default: panic("Unexpected Request") } }) From a8f292e0b15ee73a1fbd6278f0026cef83c3532d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:32:13 +0100 Subject: [PATCH 06/10] lint: Prefer strings.ReplaceAll to string.Replace with n=-1 Signed-off-by: Stephen Finucane --- .golangci.yaml | 3 --- openstack/client.go | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 054ab275e2..553f2f253c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -27,9 +27,6 @@ linters: - linters: - staticcheck text: "ST1005: error strings should not end with punctuation or newlines" - - linters: - - staticcheck - text: "QF1004: could use strings.ReplaceAll instead" - linters: - staticcheck text: "could remove embedded field \".*\" from selector" diff --git a/openstack/client.go b/openstack/client.go index 122a3ee699..0d71332c81 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -450,7 +450,7 @@ func NewLoadBalancerV2(client *gophercloud.ProviderClient, eo gophercloud.Endpoi sc, err := initClientOpts(client, eo, "load-balancer") // Fixes edge case having an OpenStack lb endpoint with trailing version number. - endpoint := strings.Replace(sc.Endpoint, "v2.0/", "", -1) + endpoint := strings.ReplaceAll(sc.Endpoint, "v2.0/", "") sc.ResourceBase = endpoint + "v2.0/" return sc, err From 6160fd13e2da830edc5fecfd3b2f1591fe6b697f Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:33:02 +0100 Subject: [PATCH 07/10] lint: Remove embedded fields from selectors This looks complicated, but it's just a whole lot of sed invocations. Signed-off-by: Stephen Finucane --- .golangci.yaml | 3 --- docs/FAQ.md | 2 +- .../openstack/identity/v3/oauth1_test.go | 2 +- .../extensions/trunk_details/trunks_test.go | 16 ++++++------- .../objectstorage/v1/objects_test.go | 4 ++-- openstack/baremetal/v1/allocations/results.go | 4 ++-- openstack/baremetal/v1/conductors/results.go | 4 ++-- openstack/baremetal/v1/drivers/results.go | 4 ++-- openstack/baremetal/v1/nodes/results.go | 4 ++-- .../v1/nodes/testing/results_test.go | 10 ++++---- openstack/baremetal/v1/portgroups/results.go | 4 ++-- openstack/baremetal/v1/ports/results.go | 4 ++-- .../v1/introspection/results.go | 4 ++-- openstack/blockstorage/v2/backups/results.go | 10 ++++---- .../blockstorage/v2/transfers/results.go | 4 ++-- openstack/blockstorage/v2/volumes/results.go | 4 ++-- .../blockstorage/v3/attachments/results.go | 4 ++-- openstack/blockstorage/v3/backups/results.go | 10 ++++---- .../v3/manageablevolumes/results.go | 2 +- openstack/blockstorage/v3/qos/results.go | 2 +- .../blockstorage/v3/transfers/results.go | 4 ++-- openstack/blockstorage/v3/volumes/results.go | 4 ++-- .../blockstorage/v3/volumetypes/results.go | 6 ++--- .../compute/v2/instanceactions/results.go | 4 ++-- openstack/compute/v2/servers/results.go | 4 ++-- openstack/messaging/v2/messages/results.go | 2 +- openstack/messaging/v2/queues/results.go | 2 +- .../v2/extensions/bgp/peers/results.go | 4 ++-- .../v2/extensions/bgp/speakers/results.go | 8 +++---- .../v2/extensions/bgpvpns/requests.go | 8 +++---- .../v2/extensions/bgpvpns/results.go | 24 +++++++++---------- .../extensions/layer3/floatingips/results.go | 4 ++-- .../layer3/portforwarding/results.go | 2 +- .../v2/extensions/layer3/routers/results.go | 2 +- .../v2/extensions/qos/policies/results.go | 2 +- .../v2/extensions/qos/rules/results.go | 6 ++--- .../v2/extensions/rbacpolicies/results.go | 4 ++-- .../trunk_details/testing/requests_test.go | 6 ++--- openstack/networking/v2/networks/results.go | 4 ++-- openstack/networking/v2/ports/results.go | 4 ++-- .../objectstorage/v1/containers/requests.go | 2 +- .../objectstorage/v1/objects/requests.go | 2 +- openstack/objectstorage/v1/objects/results.go | 2 +- .../orchestration/v1/stackevents/requests.go | 4 ++-- .../sharedfilesystems/v2/replicas/requests.go | 4 ++-- .../sharedfilesystems/v2/replicas/results.go | 4 ++-- .../v2/sharenetworks/requests.go | 2 +- .../v2/sharenetworks/results.go | 2 +- .../sharedfilesystems/v2/shares/requests.go | 2 +- .../sharedfilesystems/v2/shares/results.go | 2 +- .../v2/sharetransfers/requests.go | 4 ++-- .../v2/sharetransfers/results.go | 6 ++--- .../v2/snapshots/requests.go | 2 +- .../sharedfilesystems/v2/snapshots/results.go | 2 +- pagination/testing/marker_test.go | 2 +- 55 files changed, 122 insertions(+), 125 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 553f2f253c..6469415c8c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -27,9 +27,6 @@ linters: - linters: - staticcheck text: "ST1005: error strings should not end with punctuation or newlines" - - linters: - - staticcheck - text: "could remove embedded field \".*\" from selector" - path: (.+)\.go$ text: SA1006 paths: diff --git a/docs/FAQ.md b/docs/FAQ.md index bb37db8019..bc42ae6cbb 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -8,7 +8,7 @@ Please see our dedicated document [here](MICROVERSIONS.md). You can implement custom logging and/or limit re-auth attempts by creating a custom HTTP client like the following and setting it as the provider client's HTTP Client (via the -`gophercloud.ProviderClient.HTTPClient` field): +`gophercloud.HTTPClient` field): ```go //... diff --git a/internal/acceptance/openstack/identity/v3/oauth1_test.go b/internal/acceptance/openstack/identity/v3/oauth1_test.go index 125fdd0588..2e5b9b25fe 100644 --- a/internal/acceptance/openstack/identity/v3/oauth1_test.go +++ b/internal/acceptance/openstack/identity/v3/oauth1_test.go @@ -215,7 +215,7 @@ func oauth1MethodTest(t *testing.T, client *gophercloud.ServiceClient, consumer tokens.Token oauth1.TokenExt } - tokenRes := tokens.Get(context.TODO(), newClient, newClient.ProviderClient.TokenID) + tokenRes := tokens.Get(context.TODO(), newClient, newClient.TokenID) err = tokenRes.ExtractInto(&token) th.AssertNoErr(t, err) oauth1Roles, err := tokenRes.ExtractRoles() diff --git a/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go b/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go index 3a9870d35b..e38404888f 100644 --- a/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go +++ b/internal/acceptance/openstack/networking/v2/extensions/trunk_details/trunks_test.go @@ -79,8 +79,8 @@ func TestListPortWithSubports(t *testing.T) { th.AssertEquals(t, 1, len(allPorts)) port := allPorts[0] - th.AssertEquals(t, trunk.ID, port.TrunkDetails.TrunkID) - th.AssertEquals(t, 2, len(port.TrunkDetails.SubPorts)) + th.AssertEquals(t, trunk.ID, port.TrunkID) + th.AssertEquals(t, 2, len(port.SubPorts)) // Note that MAC address is not (currently) returned in list queries. We // exclude it from the comparison here in case it's ever added. MAC @@ -92,18 +92,18 @@ func TestListPortWithSubports(t *testing.T) { SegmentationID: 1, SegmentationType: "vlan", PortID: subport1.ID, - }, port.TrunkDetails.SubPorts[0].Subport) + }, port.SubPorts[0].Subport) th.AssertDeepEquals(t, trunks.Subport{ SegmentationID: 2, SegmentationType: "vlan", PortID: subport2.ID, - }, port.TrunkDetails.SubPorts[1].Subport) + }, port.SubPorts[1].Subport) // Test GET port with trunk details err = ports.Get(context.TODO(), client, parentPort.ID).ExtractInto(&port) th.AssertNoErr(t, err) - th.AssertEquals(t, trunk.ID, port.TrunkDetails.TrunkID) - th.AssertEquals(t, 2, len(port.TrunkDetails.SubPorts)) + th.AssertEquals(t, trunk.ID, port.TrunkID) + th.AssertEquals(t, 2, len(port.SubPorts)) th.AssertDeepEquals(t, trunk_details.Subport{ Subport: trunks.Subport{ SegmentationID: 1, @@ -111,7 +111,7 @@ func TestListPortWithSubports(t *testing.T) { PortID: subport1.ID, }, MACAddress: subport1.MACAddress, - }, port.TrunkDetails.SubPorts[0]) + }, port.SubPorts[0]) th.AssertDeepEquals(t, trunk_details.Subport{ Subport: trunks.Subport{ SegmentationID: 2, @@ -119,5 +119,5 @@ func TestListPortWithSubports(t *testing.T) { PortID: subport2.ID, }, MACAddress: subport2.MACAddress, - }, port.TrunkDetails.SubPorts[1]) + }, port.SubPorts[1]) } diff --git a/internal/acceptance/openstack/objectstorage/v1/objects_test.go b/internal/acceptance/openstack/objectstorage/v1/objects_test.go index 5fcf806936..90753baeb8 100644 --- a/internal/acceptance/openstack/objectstorage/v1/objects_test.go +++ b/internal/acceptance/openstack/objectstorage/v1/objects_test.go @@ -100,7 +100,7 @@ func TestObjects(t *testing.T) { }) th.AssertNoErr(t, err) - resp, err := client.ProviderClient.HTTPClient.Get(objURLs[i]) + resp, err := client.HTTPClient.Get(objURLs[i]) th.AssertNoErr(t, err) if resp.StatusCode != http.StatusOK { resp.Body.Close() @@ -121,7 +121,7 @@ func TestObjects(t *testing.T) { }) th.AssertNoErr(t, err) - resp, err = client.ProviderClient.HTTPClient.Get(objURLs[i]) + resp, err = client.HTTPClient.Get(objURLs[i]) th.AssertNoErr(t, err) if resp.StatusCode != http.StatusOK { resp.Body.Close() diff --git a/openstack/baremetal/v1/allocations/results.go b/openstack/baremetal/v1/allocations/results.go index 932862e283..cc05ed68ce 100644 --- a/openstack/baremetal/v1/allocations/results.go +++ b/openstack/baremetal/v1/allocations/results.go @@ -56,11 +56,11 @@ func (r allocationResult) Extract() (*Allocation, error) { } func (r allocationResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractAllocationsInto(r pagination.Page, v any) error { - return r.(AllocationPage).Result.ExtractIntoSlicePtr(v, "allocations") + return r.(AllocationPage).ExtractIntoSlicePtr(v, "allocations") } // AllocationPage abstracts the raw results of making a List() request against diff --git a/openstack/baremetal/v1/conductors/results.go b/openstack/baremetal/v1/conductors/results.go index 5431106108..005669af9f 100644 --- a/openstack/baremetal/v1/conductors/results.go +++ b/openstack/baremetal/v1/conductors/results.go @@ -19,11 +19,11 @@ func (r conductorResult) Extract() (*Conductor, error) { } func (r conductorResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractConductorInto(r pagination.Page, v any) error { - return r.(ConductorPage).Result.ExtractIntoSlicePtr(v, "conductors") + return r.(ConductorPage).ExtractIntoSlicePtr(v, "conductors") } // Conductor represents a conductor in the OpenStack Bare Metal API. diff --git a/openstack/baremetal/v1/drivers/results.go b/openstack/baremetal/v1/drivers/results.go index 4905fa902b..d3ebc6555b 100644 --- a/openstack/baremetal/v1/drivers/results.go +++ b/openstack/baremetal/v1/drivers/results.go @@ -17,11 +17,11 @@ func (r driverResult) Extract() (*Driver, error) { } func (r driverResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractDriversInto(r pagination.Page, v any) error { - return r.(DriverPage).Result.ExtractIntoSlicePtr(v, "drivers") + return r.(DriverPage).ExtractIntoSlicePtr(v, "drivers") } // Driver represents a driver in the OpenStack Bare Metal API. diff --git a/openstack/baremetal/v1/nodes/results.go b/openstack/baremetal/v1/nodes/results.go index b33517a388..abc669c579 100644 --- a/openstack/baremetal/v1/nodes/results.go +++ b/openstack/baremetal/v1/nodes/results.go @@ -47,11 +47,11 @@ func (r ValidateResult) Extract() (*NodeValidation, error) { } func (r nodeResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractNodesInto(r pagination.Page, v any) error { - return r.(NodePage).Result.ExtractIntoSlicePtr(v, "nodes") + return r.(NodePage).ExtractIntoSlicePtr(v, "nodes") } // Extract interprets a BIOSSettingsResult as an array of BIOSSetting structs, if possible. diff --git a/openstack/baremetal/v1/nodes/testing/results_test.go b/openstack/baremetal/v1/nodes/testing/results_test.go index acdb59e774..f7b99d827f 100644 --- a/openstack/baremetal/v1/nodes/testing/results_test.go +++ b/openstack/baremetal/v1/nodes/testing/results_test.go @@ -13,7 +13,7 @@ import ( func TestStandardPluginData(t *testing.T) { var pluginData nodes.PluginData - err := pluginData.RawMessage.UnmarshalJSON([]byte(invtest.StandardPluginDataSample)) + err := pluginData.UnmarshalJSON([]byte(invtest.StandardPluginDataSample)) th.AssertNoErr(t, err) parsedData, err := pluginData.AsStandardData() @@ -28,7 +28,7 @@ func TestStandardPluginData(t *testing.T) { func TestInspectorPluginData(t *testing.T) { var pluginData nodes.PluginData - err := pluginData.RawMessage.UnmarshalJSON([]byte(insptest.IntrospectionDataJSONSample)) + err := pluginData.UnmarshalJSON([]byte(insptest.IntrospectionDataJSONSample)) th.AssertNoErr(t, err) parsedData, err := pluginData.AsInspectorData() @@ -43,7 +43,7 @@ func TestInspectorPluginData(t *testing.T) { func TestGuessFormatUnknownDefaultsToIronic(t *testing.T) { var pluginData nodes.PluginData - err := pluginData.RawMessage.UnmarshalJSON([]byte("{}")) + err := pluginData.UnmarshalJSON([]byte("{}")) th.AssertNoErr(t, err) irData, inspData, err := pluginData.GuessFormat() @@ -54,7 +54,7 @@ func TestGuessFormatUnknownDefaultsToIronic(t *testing.T) { func TestGuessFormatErrors(t *testing.T) { var pluginData nodes.PluginData - err := pluginData.RawMessage.UnmarshalJSON([]byte("\"banana\"")) + err := pluginData.UnmarshalJSON([]byte("\"banana\"")) th.AssertNoErr(t, err) irData, inspData, err := pluginData.GuessFormat() @@ -65,7 +65,7 @@ func TestGuessFormatErrors(t *testing.T) { failsInspectorConversion := `{ "interfaces": "banana" }` - err = pluginData.RawMessage.UnmarshalJSON([]byte(failsInspectorConversion)) + err = pluginData.UnmarshalJSON([]byte(failsInspectorConversion)) th.AssertNoErr(t, err) irData, inspData, err = pluginData.GuessFormat() diff --git a/openstack/baremetal/v1/portgroups/results.go b/openstack/baremetal/v1/portgroups/results.go index 1c0c14191f..fc939296a7 100644 --- a/openstack/baremetal/v1/portgroups/results.go +++ b/openstack/baremetal/v1/portgroups/results.go @@ -70,11 +70,11 @@ func (r portgroupsResult) Extract() (*PortGroup, error) { } func (r portgroupsResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractPortGroupsInto(r pagination.Page, v any) error { - return r.(PortGroupsPage).Result.ExtractIntoSlicePtr(v, "portgroups") + return r.(PortGroupsPage).ExtractIntoSlicePtr(v, "portgroups") } // PortGroupsPage abstracts the raw results of making a List() request against diff --git a/openstack/baremetal/v1/ports/results.go b/openstack/baremetal/v1/ports/results.go index b1ec5cca81..1537a45bea 100644 --- a/openstack/baremetal/v1/ports/results.go +++ b/openstack/baremetal/v1/ports/results.go @@ -18,11 +18,11 @@ func (r portResult) Extract() (*Port, error) { } func (r portResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } func ExtractPortsInto(r pagination.Page, v any) error { - return r.(PortPage).Result.ExtractIntoSlicePtr(v, "ports") + return r.(PortPage).ExtractIntoSlicePtr(v, "ports") } // Port represents a port in the OpenStack Bare Metal API. diff --git a/openstack/baremetalintrospection/v1/introspection/results.go b/openstack/baremetalintrospection/v1/introspection/results.go index 00e0287bc4..c7740940a1 100644 --- a/openstack/baremetalintrospection/v1/introspection/results.go +++ b/openstack/baremetalintrospection/v1/introspection/results.go @@ -22,13 +22,13 @@ func (r introspectionResult) Extract() (*Introspection, error) { // ExtractInto will extract a response body into an Introspection struct. func (r introspectionResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } // ExtractIntrospectionsInto will extract a collection of introspectResult pages into a // slice of Introspection entities. func ExtractIntrospectionsInto(r pagination.Page, v any) error { - return r.(IntrospectionPage).Result.ExtractIntoSlicePtr(v, "introspection") + return r.(IntrospectionPage).ExtractIntoSlicePtr(v, "introspection") } // ExtractIntrospections interprets the results of a single page from a diff --git a/openstack/blockstorage/v2/backups/results.go b/openstack/blockstorage/v2/backups/results.go index 77620de917..fb204b9f61 100644 --- a/openstack/blockstorage/v2/backups/results.go +++ b/openstack/blockstorage/v2/backups/results.go @@ -156,11 +156,11 @@ func (r commonResult) Extract() (*Backup, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup") + return r.ExtractIntoStructPtr(v, "backup") } func ExtractBackupsInto(r pagination.Page, v any) error { - return r.(BackupPage).Result.ExtractIntoSlicePtr(v, "backups") + return r.(BackupPage).ExtractIntoSlicePtr(v, "backups") } // RestoreResult contains the response body and error from a restore request. @@ -189,7 +189,7 @@ func (r RestoreResult) Extract() (*Restore, error) { } func (r RestoreResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "restore") + return r.ExtractIntoStructPtr(v, "restore") } // ExportResult contains the response body and error from an export request. @@ -214,7 +214,7 @@ func (r ExportResult) Extract() (*BackupRecord, error) { } func (r ExportResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup-record") + return r.ExtractIntoStructPtr(v, "backup-record") } // ImportResponse struct contains the response of the Backup Import action. @@ -236,7 +236,7 @@ func (r ImportResult) Extract() (*ImportResponse, error) { } func (r ImportResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup") + return r.ExtractIntoStructPtr(v, "backup") } // ImportBackup contains all the information to import a Cinder Backup. diff --git a/openstack/blockstorage/v2/transfers/results.go b/openstack/blockstorage/v2/transfers/results.go index 42885c27ef..5dce9179ff 100644 --- a/openstack/blockstorage/v2/transfers/results.go +++ b/openstack/blockstorage/v2/transfers/results.go @@ -49,7 +49,7 @@ func (r commonResult) Extract() (*Transfer, error) { // ExtractInto converts our response data into a transfer struct func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "transfer") + return r.ExtractIntoStructPtr(v, "transfer") } // CreateResult contains the response body and error from a Create request. @@ -76,7 +76,7 @@ func ExtractTransfers(r pagination.Page) ([]Transfer, error) { // ExtractTransfersInto similar to ExtractInto but operates on a `list` of transfers func ExtractTransfersInto(r pagination.Page, v any) error { - return r.(TransferPage).Result.ExtractIntoSlicePtr(v, "transfers") + return r.(TransferPage).ExtractIntoSlicePtr(v, "transfers") } // TransferPage is a pagination.pager that is returned from a call to the List function. diff --git a/openstack/blockstorage/v2/volumes/results.go b/openstack/blockstorage/v2/volumes/results.go index 061309e991..abc3d46821 100644 --- a/openstack/blockstorage/v2/volumes/results.go +++ b/openstack/blockstorage/v2/volumes/results.go @@ -147,11 +147,11 @@ func (r commonResult) Extract() (*Volume, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "volume") + return r.ExtractIntoStructPtr(v, "volume") } func ExtractVolumesInto(r pagination.Page, v any) error { - return r.(VolumePage).Result.ExtractIntoSlicePtr(v, "volumes") + return r.(VolumePage).ExtractIntoSlicePtr(v, "volumes") } // CreateResult contains the response body and error from a Create request. diff --git a/openstack/blockstorage/v3/attachments/results.go b/openstack/blockstorage/v3/attachments/results.go index 8c572047ae..0ef8a66074 100644 --- a/openstack/blockstorage/v3/attachments/results.go +++ b/openstack/blockstorage/v3/attachments/results.go @@ -89,13 +89,13 @@ func (r commonResult) Extract() (*Attachment, error) { // ExtractInto converts our response data into a attachment struct. func (r commonResult) ExtractInto(a any) error { - return r.Result.ExtractIntoStructPtr(a, "attachment") + return r.ExtractIntoStructPtr(a, "attachment") } // ExtractAttachmentsInto similar to ExtractInto but operates on a List of // attachments. func ExtractAttachmentsInto(r pagination.Page, a any) error { - return r.(AttachmentPage).Result.ExtractIntoSlicePtr(a, "attachments") + return r.(AttachmentPage).ExtractIntoSlicePtr(a, "attachments") } // CreateResult contains the response body and error from a Create request. diff --git a/openstack/blockstorage/v3/backups/results.go b/openstack/blockstorage/v3/backups/results.go index 77620de917..fb204b9f61 100644 --- a/openstack/blockstorage/v3/backups/results.go +++ b/openstack/blockstorage/v3/backups/results.go @@ -156,11 +156,11 @@ func (r commonResult) Extract() (*Backup, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup") + return r.ExtractIntoStructPtr(v, "backup") } func ExtractBackupsInto(r pagination.Page, v any) error { - return r.(BackupPage).Result.ExtractIntoSlicePtr(v, "backups") + return r.(BackupPage).ExtractIntoSlicePtr(v, "backups") } // RestoreResult contains the response body and error from a restore request. @@ -189,7 +189,7 @@ func (r RestoreResult) Extract() (*Restore, error) { } func (r RestoreResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "restore") + return r.ExtractIntoStructPtr(v, "restore") } // ExportResult contains the response body and error from an export request. @@ -214,7 +214,7 @@ func (r ExportResult) Extract() (*BackupRecord, error) { } func (r ExportResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup-record") + return r.ExtractIntoStructPtr(v, "backup-record") } // ImportResponse struct contains the response of the Backup Import action. @@ -236,7 +236,7 @@ func (r ImportResult) Extract() (*ImportResponse, error) { } func (r ImportResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "backup") + return r.ExtractIntoStructPtr(v, "backup") } // ImportBackup contains all the information to import a Cinder Backup. diff --git a/openstack/blockstorage/v3/manageablevolumes/results.go b/openstack/blockstorage/v3/manageablevolumes/results.go index 317ed21fb3..bb8ec9f7e3 100644 --- a/openstack/blockstorage/v3/manageablevolumes/results.go +++ b/openstack/blockstorage/v3/manageablevolumes/results.go @@ -18,5 +18,5 @@ func (r ManageExistingResult) Extract() (*volumes.Volume, error) { // ExtractInto converts our response data into a volume struct func (r ManageExistingResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "volume") + return r.ExtractIntoStructPtr(v, "volume") } diff --git a/openstack/blockstorage/v3/qos/results.go b/openstack/blockstorage/v3/qos/results.go index 314bf878ca..53765f3af1 100644 --- a/openstack/blockstorage/v3/qos/results.go +++ b/openstack/blockstorage/v3/qos/results.go @@ -30,7 +30,7 @@ func (r commonResult) Extract() (*QoS, error) { // ExtractInto converts our response data into a QoS struct func (r commonResult) ExtractInto(qos any) error { - return r.Result.ExtractIntoStructPtr(qos, "qos_specs") + return r.ExtractIntoStructPtr(qos, "qos_specs") } // CreateResult contains the response body and error from a Create request. diff --git a/openstack/blockstorage/v3/transfers/results.go b/openstack/blockstorage/v3/transfers/results.go index 42885c27ef..5dce9179ff 100644 --- a/openstack/blockstorage/v3/transfers/results.go +++ b/openstack/blockstorage/v3/transfers/results.go @@ -49,7 +49,7 @@ func (r commonResult) Extract() (*Transfer, error) { // ExtractInto converts our response data into a transfer struct func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "transfer") + return r.ExtractIntoStructPtr(v, "transfer") } // CreateResult contains the response body and error from a Create request. @@ -76,7 +76,7 @@ func ExtractTransfers(r pagination.Page) ([]Transfer, error) { // ExtractTransfersInto similar to ExtractInto but operates on a `list` of transfers func ExtractTransfersInto(r pagination.Page, v any) error { - return r.(TransferPage).Result.ExtractIntoSlicePtr(v, "transfers") + return r.(TransferPage).ExtractIntoSlicePtr(v, "transfers") } // TransferPage is a pagination.pager that is returned from a call to the List function. diff --git a/openstack/blockstorage/v3/volumes/results.go b/openstack/blockstorage/v3/volumes/results.go index e99ef5e197..b32c836161 100644 --- a/openstack/blockstorage/v3/volumes/results.go +++ b/openstack/blockstorage/v3/volumes/results.go @@ -154,12 +154,12 @@ func (r commonResult) Extract() (*Volume, error) { // ExtractInto converts our response data into a volume struct func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "volume") + return r.ExtractIntoStructPtr(v, "volume") } // ExtractVolumesInto similar to ExtractInto but operates on a `list` of volumes func ExtractVolumesInto(r pagination.Page, v any) error { - return r.(VolumePage).Result.ExtractIntoSlicePtr(v, "volumes") + return r.(VolumePage).ExtractIntoSlicePtr(v, "volumes") } // CreateResult contains the response body and error from a Create request. diff --git a/openstack/blockstorage/v3/volumetypes/results.go b/openstack/blockstorage/v3/volumetypes/results.go index 9d5dce56ee..11f03b4c94 100644 --- a/openstack/blockstorage/v3/volumetypes/results.go +++ b/openstack/blockstorage/v3/volumetypes/results.go @@ -69,12 +69,12 @@ func (r commonResult) Extract() (*VolumeType, error) { // ExtractInto converts our response data into a volume type struct func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "volume_type") + return r.ExtractIntoStructPtr(v, "volume_type") } // ExtractVolumeTypesInto similar to ExtractInto but operates on a `list` of volume types func ExtractVolumeTypesInto(r pagination.Page, v any) error { - return r.(VolumeTypePage).Result.ExtractIntoSlicePtr(v, "volume_types") + return r.(VolumeTypePage).ExtractIntoSlicePtr(v, "volume_types") } // GetResult contains the response body and error from a Get request. @@ -228,7 +228,7 @@ func (r encryptionResult) Extract() (*EncryptionType, error) { // ExtractInto converts our response data into a volume type struct func (r encryptionResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "encryption") + return r.ExtractIntoStructPtr(v, "encryption") } type CreateEncryptionResult struct { diff --git a/openstack/compute/v2/instanceactions/results.go b/openstack/compute/v2/instanceactions/results.go index 2015be88c2..8ebc060542 100644 --- a/openstack/compute/v2/instanceactions/results.go +++ b/openstack/compute/v2/instanceactions/results.go @@ -186,9 +186,9 @@ func (r InstanceActionResult) Extract() (InstanceActionDetail, error) { } func (r InstanceActionResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "instanceAction") + return r.ExtractIntoStructPtr(v, "instanceAction") } func ExtractInstanceActionsInto(r pagination.Page, v any) error { - return r.(InstanceActionPage).Result.ExtractIntoSlicePtr(v, "instanceActions") + return r.(InstanceActionPage).ExtractIntoSlicePtr(v, "instanceActions") } diff --git a/openstack/compute/v2/servers/results.go b/openstack/compute/v2/servers/results.go index 385001c8dd..8e9d9b2ad7 100644 --- a/openstack/compute/v2/servers/results.go +++ b/openstack/compute/v2/servers/results.go @@ -25,11 +25,11 @@ func (r serverResult) Extract() (*Server, error) { } func (r serverResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "server") + return r.ExtractIntoStructPtr(v, "server") } func ExtractServersInto(r pagination.Page, v any) error { - return r.(ServerPage).Result.ExtractIntoSlicePtr(v, "servers") + return r.(ServerPage).ExtractIntoSlicePtr(v, "servers") } // CreateResult is the response from a Create operation. Call its Extract diff --git a/openstack/messaging/v2/messages/results.go b/openstack/messaging/v2/messages/results.go index a0b76a7373..cf280d8868 100644 --- a/openstack/messaging/v2/messages/results.go +++ b/openstack/messaging/v2/messages/results.go @@ -127,5 +127,5 @@ func (r MessagePage) NextPageURL() (string, error) { if err != nil { return "", err } - return nextPageURL(r.URL.String(), next) + return nextPageURL(r.String(), next) } diff --git a/openstack/messaging/v2/queues/results.go b/openstack/messaging/v2/queues/results.go index 8190ddfa52..398bbba77d 100644 --- a/openstack/messaging/v2/queues/results.go +++ b/openstack/messaging/v2/queues/results.go @@ -173,7 +173,7 @@ func (r QueuePage) NextPageURL() (string, error) { if err != nil { return "", err } - return nextPageURL(r.URL.String(), next) + return nextPageURL(r.String(), next) } // GetCount value if it request was supplied `WithCount` param diff --git a/openstack/networking/v2/extensions/bgp/peers/results.go b/openstack/networking/v2/extensions/bgp/peers/results.go index afd771b1e4..ac07c91c81 100644 --- a/openstack/networking/v2/extensions/bgp/peers/results.go +++ b/openstack/networking/v2/extensions/bgp/peers/results.go @@ -19,7 +19,7 @@ func (r commonResult) Extract() (*BGPPeer, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, jroot) + return r.ExtractIntoStructPtr(v, jroot) } // BGP peer @@ -72,7 +72,7 @@ func ExtractBGPPeers(r pagination.Page) ([]BGPPeer, error) { } func ExtractBGPPeersInto(r pagination.Page, v any) error { - return r.(BGPPeerPage).Result.ExtractIntoSlicePtr(v, "bgp_peers") + return r.(BGPPeerPage).ExtractIntoSlicePtr(v, "bgp_peers") } // GetResult represents the result of a get operation. Call its Extract diff --git a/openstack/networking/v2/extensions/bgp/speakers/results.go b/openstack/networking/v2/extensions/bgp/speakers/results.go index 93c967ca47..3c8b312537 100644 --- a/openstack/networking/v2/extensions/bgp/speakers/results.go +++ b/openstack/networking/v2/extensions/bgp/speakers/results.go @@ -19,7 +19,7 @@ func (r commonResult) Extract() (*BGPSpeaker, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, jroot) + return r.ExtractIntoStructPtr(v, jroot) } // BGPSpeaker BGP Speaker @@ -84,7 +84,7 @@ func ExtractBGPSpeakers(r pagination.Page) ([]BGPSpeaker, error) { // a list of BGPSpeaker and the later should be used to store the result that would be // extracted from the former. func ExtractBGPSpeakersInto(r pagination.Page, v any) error { - return r.(BGPSpeakerPage).Result.ExtractIntoSlicePtr(v, "bgp_speakers") + return r.(BGPSpeakerPage).ExtractIntoSlicePtr(v, "bgp_speakers") } // GetResult represents the result of a get operation. Call its Extract @@ -124,7 +124,7 @@ func (r AddBGPPeerResult) Extract() (*AddBGPPeerOpts, error) { } func (r AddBGPPeerResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "") + return r.ExtractIntoStructPtr(v, "") } // RemoveBGPPeerResult represent the response of the PUT /v2.0/bgp-speakers/{bgp-speaker-id}/remove-bgp-peer @@ -167,7 +167,7 @@ func ExtractAdvertisedRoutes(r pagination.Page) ([]AdvertisedRoute, error) { // ExtractAdvertisedRoutesInto extract the advertised routes from the first param into the 2nd func ExtractAdvertisedRoutesInto(r pagination.Page, v any) error { - return r.(AdvertisedRoutePage).Result.ExtractIntoSlicePtr(v, "advertised_routes") + return r.(AdvertisedRoutePage).ExtractIntoSlicePtr(v, "advertised_routes") } // AddGatewayNetworkResult represents the data that would be PUT to diff --git a/openstack/networking/v2/extensions/bgpvpns/requests.go b/openstack/networking/v2/extensions/bgpvpns/requests.go index 374b4daf5b..9e6c02717f 100644 --- a/openstack/networking/v2/extensions/bgpvpns/requests.go +++ b/openstack/networking/v2/extensions/bgpvpns/requests.go @@ -43,7 +43,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { url += query return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := BGPVPNPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -169,7 +169,7 @@ func ListNetworkAssociations(c *gophercloud.ServiceClient, id string, opts ListN url += query return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := NetworkAssociationPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -258,7 +258,7 @@ func ListRouterAssociations(c *gophercloud.ServiceClient, id string, opts ListRo url += query return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := RouterAssociationPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -380,7 +380,7 @@ func ListPortAssociations(c *gophercloud.ServiceClient, id string, opts ListPort url += query return pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := PortAssociationPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/networking/v2/extensions/bgpvpns/results.go b/openstack/networking/v2/extensions/bgpvpns/results.go index df0587568c..5aef69b98a 100644 --- a/openstack/networking/v2/extensions/bgpvpns/results.go +++ b/openstack/networking/v2/extensions/bgpvpns/results.go @@ -23,7 +23,7 @@ func (r commonResult) Extract() (*BGPVPN, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "bgpvpn") + return r.ExtractIntoStructPtr(v, "bgpvpn") } // BGPVPN represents an MPLS network with which Neutron routers and/or networks @@ -115,7 +115,7 @@ func (r BGPVPNPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } @@ -150,7 +150,7 @@ func ExtractBGPVPNs(r pagination.Page) ([]BGPVPN, error) { } func ExtractBGPVPNsInto(r pagination.Page, v any) error { - return r.(BGPVPNPage).Result.ExtractIntoSlicePtr(v, "bgpvpns") + return r.(BGPVPNPage).ExtractIntoSlicePtr(v, "bgpvpns") } // GetResult represents the result of a get operation. Call its Extract @@ -189,7 +189,7 @@ func (r commonNetworkAssociationResult) Extract() (*NetworkAssociation, error) { } func (r commonNetworkAssociationResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "network_association") + return r.ExtractIntoStructPtr(v, "network_association") } // NetworkAssociation represents a BGP VPN network association object. @@ -233,7 +233,7 @@ func (r NetworkAssociationPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } @@ -264,7 +264,7 @@ func ExtractNetworkAssociations(r pagination.Page) ([]NetworkAssociation, error) } func ExtractNetworkAssociationsInto(r pagination.Page, v interface{}) error { - return r.(NetworkAssociationPage).Result.ExtractIntoSlicePtr(v, "network_associations") + return r.(NetworkAssociationPage).ExtractIntoSlicePtr(v, "network_associations") } // CreateNetworkAssociationResult represents the result of a create operation. Call its Extract @@ -297,7 +297,7 @@ func (r commonRouterAssociationResult) Extract() (*RouterAssociation, error) { } func (r commonRouterAssociationResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "router_association") + return r.ExtractIntoStructPtr(v, "router_association") } // RouterAssociation represents a BGP VPN router association object. @@ -342,7 +342,7 @@ func (r RouterAssociationPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } @@ -373,7 +373,7 @@ func ExtractRouterAssociations(r pagination.Page) ([]RouterAssociation, error) { } func ExtractRouterAssociationsInto(r pagination.Page, v interface{}) error { - return r.(RouterAssociationPage).Result.ExtractIntoSlicePtr(v, "router_associations") + return r.(RouterAssociationPage).ExtractIntoSlicePtr(v, "router_associations") } // CreateRouterAssociationResult represents the result of a create operation. Call its Extract @@ -412,7 +412,7 @@ func (r commonPortAssociationResult) Extract() (*PortAssociation, error) { } func (r commonPortAssociationResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "port_association") + return r.ExtractIntoStructPtr(v, "port_association") } // PortAssociation represents a BGP VPN port association object. @@ -458,7 +458,7 @@ func (r PortAssociationPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } @@ -489,7 +489,7 @@ func ExtractPortAssociations(r pagination.Page) ([]PortAssociation, error) { } func ExtractPortAssociationsInto(r pagination.Page, v interface{}) error { - return r.(PortAssociationPage).Result.ExtractIntoSlicePtr(v, "port_associations") + return r.(PortAssociationPage).ExtractIntoSlicePtr(v, "port_associations") } // CreatePortAssociationResult represents the result of a create operation. Call its Extract diff --git a/openstack/networking/v2/extensions/layer3/floatingips/results.go b/openstack/networking/v2/extensions/layer3/floatingips/results.go index 7ea6160032..89fd5cf9cd 100644 --- a/openstack/networking/v2/extensions/layer3/floatingips/results.go +++ b/openstack/networking/v2/extensions/layer3/floatingips/results.go @@ -111,7 +111,7 @@ func (r commonResult) Extract() (*FloatingIP, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "floatingip") + return r.ExtractIntoStructPtr(v, "floatingip") } // CreateResult represents the result of a create operation. Call its Extract @@ -180,5 +180,5 @@ func ExtractFloatingIPs(r pagination.Page) ([]FloatingIP, error) { } func ExtractFloatingIPsInto(r pagination.Page, v any) error { - return r.(FloatingIPPage).Result.ExtractIntoSlicePtr(v, "floatingips") + return r.(FloatingIPPage).ExtractIntoSlicePtr(v, "floatingips") } diff --git a/openstack/networking/v2/extensions/layer3/portforwarding/results.go b/openstack/networking/v2/extensions/layer3/portforwarding/results.go index 89e71efd0e..c2ed860231 100644 --- a/openstack/networking/v2/extensions/layer3/portforwarding/results.go +++ b/openstack/networking/v2/extensions/layer3/portforwarding/results.go @@ -67,7 +67,7 @@ func (r commonResult) Extract() (*PortForwarding, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "port_forwarding") + return r.ExtractIntoStructPtr(v, "port_forwarding") } // PortForwardingPage is the page returned by a pager when traversing over a diff --git a/openstack/networking/v2/extensions/layer3/routers/results.go b/openstack/networking/v2/extensions/layer3/routers/results.go index 14845524c0..2c7eb4788d 100644 --- a/openstack/networking/v2/extensions/layer3/routers/results.go +++ b/openstack/networking/v2/extensions/layer3/routers/results.go @@ -129,7 +129,7 @@ func ExtractRouters(r pagination.Page) ([]Router, error) { // ExtractRoutersInto extracts the elements into a slice of Router structs. func ExtractRoutersInto(r pagination.Page, v any) error { - return r.(RouterPage).Result.ExtractIntoSlicePtr(v, "routers") + return r.(RouterPage).ExtractIntoSlicePtr(v, "routers") } type commonResult struct { diff --git a/openstack/networking/v2/extensions/qos/policies/results.go b/openstack/networking/v2/extensions/qos/policies/results.go index c35853bac8..6a8a92a46f 100644 --- a/openstack/networking/v2/extensions/qos/policies/results.go +++ b/openstack/networking/v2/extensions/qos/policies/results.go @@ -127,5 +127,5 @@ func ExtractPolicies(r pagination.Page) ([]Policy, error) { // ExtractPoliciesInto extracts the elements into a slice of RBAC Policy structs. func ExtractPolicysInto(r pagination.Page, v any) error { - return r.(PolicyPage).Result.ExtractIntoSlicePtr(v, "policies") + return r.(PolicyPage).ExtractIntoSlicePtr(v, "policies") } diff --git a/openstack/networking/v2/extensions/qos/rules/results.go b/openstack/networking/v2/extensions/qos/rules/results.go index cb2ee24887..241e8f800b 100644 --- a/openstack/networking/v2/extensions/qos/rules/results.go +++ b/openstack/networking/v2/extensions/qos/rules/results.go @@ -88,7 +88,7 @@ func ExtractBandwidthLimitRules(r pagination.Page) ([]BandwidthLimitRule, error) // ExtractBandwidthLimitRulesInto extracts the elements into a slice of RBAC Policy structs. func ExtractBandwidthLimitRulesInto(r pagination.Page, v any) error { - return r.(BandwidthLimitRulePage).Result.ExtractIntoSlicePtr(v, "bandwidth_limit_rules") + return r.(BandwidthLimitRulePage).ExtractIntoSlicePtr(v, "bandwidth_limit_rules") } // Extract is a function that accepts a result and extracts a DSCPMarkingRule. @@ -164,7 +164,7 @@ func ExtractDSCPMarkingRules(r pagination.Page) ([]DSCPMarkingRule, error) { // ExtractDSCPMarkingRulesInto extracts the elements into a slice of RBAC Policy structs. func ExtractDSCPMarkingRulesInto(r pagination.Page, v any) error { - return r.(DSCPMarkingRulePage).Result.ExtractIntoSlicePtr(v, "dscp_marking_rules") + return r.(DSCPMarkingRulePage).ExtractIntoSlicePtr(v, "dscp_marking_rules") } // Extract is a function that accepts a result and extracts a BandwidthLimitRule. @@ -243,5 +243,5 @@ func ExtractMinimumBandwidthRules(r pagination.Page) ([]MinimumBandwidthRule, er // ExtractMinimumBandwidthRulesInto extracts the elements into a slice of RBAC Policy structs. func ExtractMinimumBandwidthRulesInto(r pagination.Page, v any) error { - return r.(MinimumBandwidthRulePage).Result.ExtractIntoSlicePtr(v, "minimum_bandwidth_rules") + return r.(MinimumBandwidthRulePage).ExtractIntoSlicePtr(v, "minimum_bandwidth_rules") } diff --git a/openstack/networking/v2/extensions/rbacpolicies/results.go b/openstack/networking/v2/extensions/rbacpolicies/results.go index abbd044b91..9550b8d15b 100644 --- a/openstack/networking/v2/extensions/rbacpolicies/results.go +++ b/openstack/networking/v2/extensions/rbacpolicies/results.go @@ -17,7 +17,7 @@ func (r commonResult) Extract() (*RBACPolicy, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "rbac_policy") + return r.ExtractIntoStructPtr(v, "rbac_policy") } // CreateResult represents the result of a create operation. Call its Extract @@ -101,5 +101,5 @@ func ExtractRBACPolicies(r pagination.Page) ([]RBACPolicy, error) { // ExtractRBACPolicesInto extracts the elements into a slice of RBAC Policy structs. func ExtractRBACPolicesInto(r pagination.Page, v any) error { - return r.(RBACPolicyPage).Result.ExtractIntoSlicePtr(v, "rbac_policies") + return r.(RBACPolicyPage).ExtractIntoSlicePtr(v, "rbac_policies") } diff --git a/openstack/networking/v2/extensions/trunk_details/testing/requests_test.go b/openstack/networking/v2/extensions/trunk_details/testing/requests_test.go index fdbd4329f2..f9f3c74ab7 100644 --- a/openstack/networking/v2/extensions/trunk_details/testing/requests_test.go +++ b/openstack/networking/v2/extensions/trunk_details/testing/requests_test.go @@ -35,9 +35,9 @@ func TestServerWithUsageExt(t *testing.T) { err := ports.Get(context.TODO(), client.ServiceClient(fakeServer), portIDFixture).ExtractInto(&portExt) th.AssertNoErr(t, err) - th.AssertEquals(t, portExt.TrunkDetails.TrunkID, "f170c831-8c55-4ceb-ad13-75eab4a121e5") - th.AssertEquals(t, len(portExt.TrunkDetails.SubPorts), 1) - subPort := portExt.TrunkDetails.SubPorts[0] + th.AssertEquals(t, portExt.TrunkID, "f170c831-8c55-4ceb-ad13-75eab4a121e5") + th.AssertEquals(t, len(portExt.SubPorts), 1) + subPort := portExt.SubPorts[0] th.AssertEquals(t, subPort.SegmentationID, 100) th.AssertEquals(t, subPort.SegmentationType, "vlan") th.AssertEquals(t, subPort.PortID, "20c673d8-7f9d-4570-b662-148d9ddcc5bd") diff --git a/openstack/networking/v2/networks/results.go b/openstack/networking/v2/networks/results.go index 53927bf0c0..d4b97c1a20 100644 --- a/openstack/networking/v2/networks/results.go +++ b/openstack/networking/v2/networks/results.go @@ -20,7 +20,7 @@ func (r commonResult) Extract() (*Network, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "network") + return r.ExtractIntoStructPtr(v, "network") } // CreateResult represents the result of a create operation. Call its Extract @@ -173,5 +173,5 @@ func ExtractNetworks(r pagination.Page) ([]Network, error) { } func ExtractNetworksInto(r pagination.Page, v any) error { - return r.(NetworkPage).Result.ExtractIntoSlicePtr(v, "networks") + return r.(NetworkPage).ExtractIntoSlicePtr(v, "networks") } diff --git a/openstack/networking/v2/ports/results.go b/openstack/networking/v2/ports/results.go index 74a0fa3b49..a6836c2a86 100644 --- a/openstack/networking/v2/ports/results.go +++ b/openstack/networking/v2/ports/results.go @@ -20,7 +20,7 @@ func (r commonResult) Extract() (*Port, error) { } func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "port") + return r.ExtractIntoStructPtr(v, "port") } // CreateResult represents the result of a create operation. Call its Extract @@ -202,5 +202,5 @@ func ExtractPorts(r pagination.Page) ([]Port, error) { } func ExtractPortsInto(r pagination.Page, v any) error { - return r.(PortPage).Result.ExtractIntoSlicePtr(v, "ports") + return r.(PortPage).ExtractIntoSlicePtr(v, "ports") } diff --git a/openstack/objectstorage/v1/containers/requests.go b/openstack/objectstorage/v1/containers/requests.go index f4714d6ff6..2d00b659ca 100644 --- a/openstack/objectstorage/v1/containers/requests.go +++ b/openstack/objectstorage/v1/containers/requests.go @@ -54,7 +54,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { pager := pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := ContainerPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) pager.Headers = headers diff --git a/openstack/objectstorage/v1/objects/requests.go b/openstack/objectstorage/v1/objects/requests.go index abc56f4773..464f94eeb7 100644 --- a/openstack/objectstorage/v1/objects/requests.go +++ b/openstack/objectstorage/v1/objects/requests.go @@ -91,7 +91,7 @@ func List(c *gophercloud.ServiceClient, containerName string, opts ListOptsBuild pager := pagination.NewPager(c, url, func(r pagination.PageResult) pagination.Page { p := ObjectPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) pager.Headers = headers diff --git a/openstack/objectstorage/v1/objects/results.go b/openstack/objectstorage/v1/objects/results.go index e98c542960..d7849e9ecb 100644 --- a/openstack/objectstorage/v1/objects/results.go +++ b/openstack/objectstorage/v1/objects/results.go @@ -496,7 +496,7 @@ func extractLastMarker(r pagination.Page) (string, error) { casted := r.(ObjectPage) // If a delimiter was requested, check if a subdir exists. - queryParams, err := url.ParseQuery(casted.URL.RawQuery) + queryParams, err := url.ParseQuery(casted.RawQuery) if err != nil { return "", err } diff --git a/openstack/orchestration/v1/stackevents/requests.go b/openstack/orchestration/v1/stackevents/requests.go index 71836e0541..7166387ec0 100644 --- a/openstack/orchestration/v1/stackevents/requests.go +++ b/openstack/orchestration/v1/stackevents/requests.go @@ -116,7 +116,7 @@ func List(client *gophercloud.ServiceClient, stackName, stackID string, opts Lis } return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := EventPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -173,7 +173,7 @@ func ListResourceEvents(client *gophercloud.ServiceClient, stackName, stackID, r } return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := EventPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/replicas/requests.go b/openstack/sharedfilesystems/v2/replicas/requests.go index 415e67b37d..6e29fd783c 100644 --- a/openstack/sharedfilesystems/v2/replicas/requests.go +++ b/openstack/sharedfilesystems/v2/replicas/requests.go @@ -90,7 +90,7 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := ReplicaPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -108,7 +108,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := ReplicaPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/replicas/results.go b/openstack/sharedfilesystems/v2/replicas/results.go index 7b75117747..8de27928f4 100644 --- a/openstack/sharedfilesystems/v2/replicas/results.go +++ b/openstack/sharedfilesystems/v2/replicas/results.go @@ -109,7 +109,7 @@ func (r ReplicaPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } @@ -160,7 +160,7 @@ func ExtractReplicas(r pagination.Page) ([]Replica, error) { // ExtractReplicasInto similar to ExtractReplicas but operates on a `list` of // replicas. func ExtractReplicasInto(r pagination.Page, v any) error { - return r.(ReplicaPage).Result.ExtractIntoSlicePtr(v, "share_replicas") + return r.(ReplicaPage).ExtractIntoSlicePtr(v, "share_replicas") } // DeleteResult contains the response body and error from a Delete request. diff --git a/openstack/sharedfilesystems/v2/sharenetworks/requests.go b/openstack/sharedfilesystems/v2/sharenetworks/requests.go index 6df73b5eed..c340e3ed43 100644 --- a/openstack/sharedfilesystems/v2/sharenetworks/requests.go +++ b/openstack/sharedfilesystems/v2/sharenetworks/requests.go @@ -116,7 +116,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := ShareNetworkPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/sharenetworks/results.go b/openstack/sharedfilesystems/v2/sharenetworks/results.go index 5d3537c007..6ffbae151e 100644 --- a/openstack/sharedfilesystems/v2/sharenetworks/results.go +++ b/openstack/sharedfilesystems/v2/sharenetworks/results.go @@ -94,7 +94,7 @@ func (r ShareNetworkPage) LastMarker() (string, error) { return maxInt, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return maxInt, err } diff --git a/openstack/sharedfilesystems/v2/shares/requests.go b/openstack/sharedfilesystems/v2/shares/requests.go index 5d680a642b..4cf7621331 100644 --- a/openstack/sharedfilesystems/v2/shares/requests.go +++ b/openstack/sharedfilesystems/v2/shares/requests.go @@ -181,7 +181,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := SharePage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/shares/results.go b/openstack/sharedfilesystems/v2/shares/results.go index 7c1b621327..650b9c3262 100644 --- a/openstack/sharedfilesystems/v2/shares/results.go +++ b/openstack/sharedfilesystems/v2/shares/results.go @@ -148,7 +148,7 @@ func (r SharePage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } diff --git a/openstack/sharedfilesystems/v2/sharetransfers/requests.go b/openstack/sharedfilesystems/v2/sharetransfers/requests.go index 88b1950eb2..dd06d01f36 100644 --- a/openstack/sharedfilesystems/v2/sharetransfers/requests.go +++ b/openstack/sharedfilesystems/v2/sharetransfers/requests.go @@ -144,7 +144,7 @@ func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pa return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := TransferPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } @@ -163,7 +163,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := TransferPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/sharetransfers/results.go b/openstack/sharedfilesystems/v2/sharetransfers/results.go index 264951383d..faa65b1903 100644 --- a/openstack/sharedfilesystems/v2/sharetransfers/results.go +++ b/openstack/sharedfilesystems/v2/sharetransfers/results.go @@ -62,7 +62,7 @@ func (r commonResult) Extract() (*Transfer, error) { // ExtractInto converts our response data into a transfer struct. func (r commonResult) ExtractInto(v any) error { - return r.Result.ExtractIntoStructPtr(v, "transfer") + return r.ExtractIntoStructPtr(v, "transfer") } // CreateResult contains the response body and error from a Create request. @@ -94,7 +94,7 @@ func ExtractTransfers(r pagination.Page) ([]Transfer, error) { // ExtractTransfersInto similar to ExtractInto but operates on a `list` of transfers func ExtractTransfersInto(r pagination.Page, v any) error { - return r.(TransferPage).Result.ExtractIntoSlicePtr(v, "transfers") + return r.(TransferPage).ExtractIntoSlicePtr(v, "transfers") } // TransferPage is a pagination.pager that is returned from a call to the List function. @@ -129,7 +129,7 @@ func (r TransferPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } diff --git a/openstack/sharedfilesystems/v2/snapshots/requests.go b/openstack/sharedfilesystems/v2/snapshots/requests.go index db043f1131..7b61dc4260 100644 --- a/openstack/sharedfilesystems/v2/snapshots/requests.go +++ b/openstack/sharedfilesystems/v2/snapshots/requests.go @@ -110,7 +110,7 @@ func ListDetail(client *gophercloud.ServiceClient, opts ListOptsBuilder) paginat return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { p := SnapshotPage{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p }) } diff --git a/openstack/sharedfilesystems/v2/snapshots/results.go b/openstack/sharedfilesystems/v2/snapshots/results.go index 9cd1b65236..e780c8f73c 100644 --- a/openstack/sharedfilesystems/v2/snapshots/results.go +++ b/openstack/sharedfilesystems/v2/snapshots/results.go @@ -107,7 +107,7 @@ func (r SnapshotPage) LastMarker() (string, error) { return invalidMarker, nil } - u, err := url.Parse(r.URL.String()) + u, err := url.Parse(r.String()) if err != nil { return invalidMarker, err } diff --git a/pagination/testing/marker_test.go b/pagination/testing/marker_test.go index 4c9441f370..a17d8687d3 100644 --- a/pagination/testing/marker_test.go +++ b/pagination/testing/marker_test.go @@ -61,7 +61,7 @@ func createMarkerPaged(t *testing.T, fakeServer th.FakeServer) pagination.Pager createPage := func(r pagination.PageResult) pagination.Page { p := MarkerPageResult{pagination.MarkerPageBase{PageResult: r}} - p.MarkerPageBase.Owner = p + p.Owner = p return p } From 1442f1d7db846fa4fab64b40b8eae7bb408bdd6e Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:42:35 +0100 Subject: [PATCH 08/10] lint: Prefer fmt.Fprintf over fmt.Fprint(..., fmt.Sprintf(...)) Signed-off-by: Stephen Finucane --- .golangci.yaml | 3 --- .../networking/v2/extensions/dns/testing/fixtures_test.go | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 6469415c8c..a0fe9b2006 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -15,9 +15,6 @@ linters: - legacy - std-error-handling rules: - - linters: - - staticcheck - text: "S1038: should use fmt.Fprintf instead of fmt.Fprint" - linters: - staticcheck text: "SA1019: (x509.EncryptPEMBlock|strings.Title)" diff --git a/openstack/networking/v2/extensions/dns/testing/fixtures_test.go b/openstack/networking/v2/extensions/dns/testing/fixtures_test.go index 5f3dbd9935..f09a1033c6 100644 --- a/openstack/networking/v2/extensions/dns/testing/fixtures_test.go +++ b/openstack/networking/v2/extensions/dns/testing/fixtures_test.go @@ -241,7 +241,7 @@ func FloatingIPHandleGet(t *testing.T, fakeServer th.FakeServer) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprint(w, fmt.Sprintf(`{"floatingip": %s}`, floatingiptest.FipDNS)) + fmt.Fprintf(w, `{"floatingip": %s}`, floatingiptest.FipDNS) }) } @@ -264,7 +264,7 @@ func FloatingIPHandleCreate(t *testing.T, fakeServer th.FakeServer) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) - fmt.Fprint(w, fmt.Sprintf(`{"floatingip": %s}`, floatingiptest.FipDNS)) + fmt.Fprintf(w, `{"floatingip": %s}`, floatingiptest.FipDNS) }) } From 22b0ac17cbabd0c13d16ee53edf5eaa0ab61dc0b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 11:48:11 +0100 Subject: [PATCH 09/10] lint: Use lowercase error strings More sed, along with some manual fixups. sed -i 's/fmt.Errorf("\([A-Z]\)/fmt.Errorf("\L\1/' \ $(ag 'fmt.Errorf\("[A-Z]' -l) sed -i 's/fmt.Errorf("\(.*\)\.")/fmt.Errorf("\1")/' \ $(ag 'fmt.Errorf\(' -l) sed -i 's/errors.New("\([A-Z]\)/errors.New("\L\1/' \ $(ag 'errors.New\("[A-Z]' -l) sed -i 's/errors.New("\(.*\)\.")/errors.New("\1")/' \ $(ag 'errors.New\(' -l) (yes, that could have a one-liner but $complexity) Signed-off-by: Stephen Finucane --- .golangci.yaml | 6 ------ docs/FAQ.md | 2 +- internal/acceptance/clients/clients.go | 6 ++---- .../openstack/blockstorage/v2/blockstorage.go | 4 ++-- .../openstack/blockstorage/v3/blockstorage.go | 4 ++-- .../blockstorage/v3/volumeattachments.go | 2 +- .../openstack/compute/v2/aggregates_test.go | 2 +- .../acceptance/openstack/compute/v2/compute.go | 4 ++-- .../openstack/compute/v2/hypervisors_test.go | 2 +- .../openstack/compute/v2/quotaset_test.go | 4 ++-- .../openstack/container/v1/capsules.go | 4 ++-- .../containerinfra/v1/containerinfra.go | 2 +- internal/acceptance/openstack/db/v1/db.go | 2 +- .../openstack/keymanager/v1/keymanager.go | 4 ++-- .../openstack/loadbalancer/v2/loadbalancer.go | 18 +++++++++--------- .../orchestration/v1/orchestration.go | 2 +- .../openstack/sharedfilesystems/v2/replicas.go | 8 ++++---- .../openstack/sharedfilesystems/v2/shares.go | 8 ++++---- .../sharedfilesystems/v2/snapshots.go | 4 ++-- .../openstack/workflow/v2/execution.go | 2 +- openstack/baremetal/httpbasic/requests.go | 2 +- .../httpbasic/testing/requests_test.go | 2 +- openstack/baremetal/inventory/plugindata.go | 2 +- .../httpbasic/requests.go | 2 +- .../httpbasic/testing/requests_test.go | 2 +- openstack/blockstorage/noauth/requests.go | 2 +- .../v2/quotasets/testing/requests_test.go | 2 +- .../v3/quotasets/testing/requests_test.go | 2 +- openstack/client.go | 2 +- openstack/compute/v2/hypervisors/results.go | 6 +++--- .../v2/quotasets/testing/requests_test.go | 2 +- openstack/compute/v2/servers/results.go | 6 +++--- openstack/container/v1/capsules/results.go | 2 +- openstack/identity/v3/users/results.go | 4 ++-- .../v2/imagedata/testing/requests_test.go | 2 +- openstack/image/v2/images/results.go | 2 +- .../networking/v2/extensions/quotas/results.go | 2 +- .../objectstorage/v1/containers/results.go | 2 +- openstack/objectstorage/v1/objects/results.go | 4 ++-- .../sharedfilesystems/v2/errors/errors.go | 2 +- openstack/utils/choose_version.go | 6 +++--- pagination/pager.go | 2 +- params.go | 12 ++++++------ results.go | 16 ++++++++-------- testing/provider_client_test.go | 2 +- testing/util_test.go | 6 +++--- 46 files changed, 89 insertions(+), 97 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index a0fe9b2006..b138f3161c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -18,12 +18,6 @@ linters: - linters: - staticcheck text: "SA1019: (x509.EncryptPEMBlock|strings.Title)" - - linters: - - staticcheck - text: "ST1005: error strings should not be capitalized" - - linters: - - staticcheck - text: "ST1005: error strings should not end with punctuation or newlines" - path: (.+)\.go$ text: SA1006 paths: diff --git a/docs/FAQ.md b/docs/FAQ.md index bc42ae6cbb..bfd0bc7bc8 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -41,7 +41,7 @@ func (lrt *LogRoundTripper) RoundTrip(request *http.Request) (*http.Response, er if response.StatusCode == http.StatusUnauthorized { if lrt.numReauthAttempts == 3 { - return response, fmt.Errorf("Tried to re-authenticate 3 times with no success.") + return response, fmt.Errorf("tried to re-authenticate 3 times with no success") } lrt.numReauthAttempts++ } diff --git a/internal/acceptance/clients/clients.go b/internal/acceptance/clients/clients.go index f981ffcea2..6c36391488 100644 --- a/internal/acceptance/clients/clients.go +++ b/internal/acceptance/clients/clients.go @@ -108,13 +108,11 @@ func AcceptanceTestChoicesFromEnv() (*AcceptanceTestChoices, error) { } if len(missing) > 0 { - text := "You're missing some important setup:\n * These environment variables must be provided: %s\n" - return nil, fmt.Errorf(text, strings.Join(missing, ", ")) + return nil, fmt.Errorf("you're missing some important setup:\n * These environment variables must be provided: %s", strings.Join(missing, ", ")) } if notDistinct != "" { - text := "You're missing some important setup:\n * %s\n" - return nil, fmt.Errorf(text, notDistinct) + return nil, fmt.Errorf("you're missing some important setup:\n * %s", notDistinct) } return &AcceptanceTestChoices{ diff --git a/internal/acceptance/openstack/blockstorage/v2/blockstorage.go b/internal/acceptance/openstack/blockstorage/v2/blockstorage.go index 9c22a2a4f8..f920a615c1 100644 --- a/internal/acceptance/openstack/blockstorage/v2/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/v2/blockstorage.go @@ -455,7 +455,7 @@ func SetBootable(t *testing.T, client *gophercloud.ServiceClient, volume *volume } if strings.ToLower(vol.Bootable) != "true" { - return fmt.Errorf("Volume bootable status is %q, expected 'true'", vol.Bootable) + return fmt.Errorf("volume bootable status is %q, expected 'true'", vol.Bootable) } bootableOpts = volumes.BootableOpts{ @@ -473,7 +473,7 @@ func SetBootable(t *testing.T, client *gophercloud.ServiceClient, volume *volume } if strings.ToLower(vol.Bootable) == "true" { - return fmt.Errorf("Volume bootable status is %q, expected 'false'", vol.Bootable) + return fmt.Errorf("volume bootable status is %q, expected 'false'", vol.Bootable) } return nil diff --git a/internal/acceptance/openstack/blockstorage/v3/blockstorage.go b/internal/acceptance/openstack/blockstorage/v3/blockstorage.go index 63de9aee9e..16e0a23dd1 100644 --- a/internal/acceptance/openstack/blockstorage/v3/blockstorage.go +++ b/internal/acceptance/openstack/blockstorage/v3/blockstorage.go @@ -673,7 +673,7 @@ func SetBootable(t *testing.T, client *gophercloud.ServiceClient, volume *volume } if strings.ToLower(vol.Bootable) != "true" { - return fmt.Errorf("Volume bootable status is %q, expected 'true'", vol.Bootable) + return fmt.Errorf("volume bootable status is %q, expected 'true'", vol.Bootable) } bootableOpts = volumes.BootableOpts{ @@ -691,7 +691,7 @@ func SetBootable(t *testing.T, client *gophercloud.ServiceClient, volume *volume } if strings.ToLower(vol.Bootable) == "true" { - return fmt.Errorf("Volume bootable status is %q, expected 'false'", vol.Bootable) + return fmt.Errorf("volume bootable status is %q, expected 'false'", vol.Bootable) } return nil diff --git a/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go b/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go index 4bd531a856..ce47111e85 100644 --- a/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go +++ b/internal/acceptance/openstack/blockstorage/v3/volumeattachments.go @@ -72,7 +72,7 @@ func CreateVolumeAttachment(t *testing.T, client *gophercloud.ServiceClient, vol } if allAttachments[0].ID != attachment.ID { - return fmt.Errorf("Attachment IDs from get and list are not equal: %q != %q", allAttachments[0].ID, attachment.ID) + return fmt.Errorf("attachment IDs from get and list are not equal: %q != %q", allAttachments[0].ID, attachment.ID) } t.Logf("Attached volume %s to server %s within %q attachment", volume.ID, server.ID, attachment.ID) diff --git a/internal/acceptance/openstack/compute/v2/aggregates_test.go b/internal/acceptance/openstack/compute/v2/aggregates_test.go index 4b20b3ff29..bd376c295e 100644 --- a/internal/acceptance/openstack/compute/v2/aggregates_test.go +++ b/internal/acceptance/openstack/compute/v2/aggregates_test.go @@ -147,5 +147,5 @@ func getHypervisor(t *testing.T, client *gophercloud.ServiceClient) (string, err return host, nil } - return "", fmt.Errorf("Unable to get hypervisor") + return "", fmt.Errorf("unable to get hypervisor") } diff --git a/internal/acceptance/openstack/compute/v2/compute.go b/internal/acceptance/openstack/compute/v2/compute.go index 3d5da42a6c..b09b8d7b6e 100644 --- a/internal/acceptance/openstack/compute/v2/compute.go +++ b/internal/acceptance/openstack/compute/v2/compute.go @@ -888,7 +888,7 @@ func GetNetworkIDFromNetworks(t *testing.T, client *gophercloud.ServiceClient, n } } - return "", fmt.Errorf("Failed to obtain network ID for network %s", networkName) + return "", fmt.Errorf("failed to obtain network ID for network %s", networkName) } // ImportPublicKey will create a KeyPair with a random name and a specified @@ -952,7 +952,7 @@ func WaitForComputeStatus(client *gophercloud.ServiceClient, server *servers.Ser } if latest.Status == "ERROR" { - return false, fmt.Errorf("Instance in ERROR state") + return false, fmt.Errorf("instance in ERROR state") } return false, nil diff --git a/internal/acceptance/openstack/compute/v2/hypervisors_test.go b/internal/acceptance/openstack/compute/v2/hypervisors_test.go index dae1bbcdbc..861fa7e02c 100644 --- a/internal/acceptance/openstack/compute/v2/hypervisors_test.go +++ b/internal/acceptance/openstack/compute/v2/hypervisors_test.go @@ -121,5 +121,5 @@ func getHypervisorID(t *testing.T, client *gophercloud.ServiceClient) (string, e return allHypervisors[0].ID, nil } - return "", fmt.Errorf("Unable to get hypervisor ID") + return "", fmt.Errorf("unable to get hypervisor ID") } diff --git a/internal/acceptance/openstack/compute/v2/quotaset_test.go b/internal/acceptance/openstack/compute/v2/quotaset_test.go index 53d94b538e..d2da0c4193 100644 --- a/internal/acceptance/openstack/compute/v2/quotaset_test.go +++ b/internal/acceptance/openstack/compute/v2/quotaset_test.go @@ -45,7 +45,7 @@ func getProjectID(t *testing.T, client *gophercloud.ServiceClient) (string, erro return project.ID, nil } - return "", fmt.Errorf("Unable to get project ID") + return "", fmt.Errorf("unable to get project ID") } func getProjectIDByName(t *testing.T, client *gophercloud.ServiceClient, name string) (string, error) { @@ -61,7 +61,7 @@ func getProjectIDByName(t *testing.T, client *gophercloud.ServiceClient, name st } } - return "", fmt.Errorf("Unable to get project ID") + return "", fmt.Errorf("unable to get project ID") } // What will be sent as desired Quotas to the Server diff --git a/internal/acceptance/openstack/container/v1/capsules.go b/internal/acceptance/openstack/container/v1/capsules.go index b4f48fc903..6ad33c0c6d 100644 --- a/internal/acceptance/openstack/container/v1/capsules.go +++ b/internal/acceptance/openstack/container/v1/capsules.go @@ -36,11 +36,11 @@ func WaitForCapsuleStatus(client *gophercloud.ServiceClient, uuid, status string } if newStatus == "Failed" { - return false, fmt.Errorf("Capsule in FAILED state") + return false, fmt.Errorf("capsule in FAILED state") } if newStatus == "Error" { - return false, fmt.Errorf("Capsule in ERROR state") + return false, fmt.Errorf("capsule in ERROR state") } return false, nil diff --git a/internal/acceptance/openstack/containerinfra/v1/containerinfra.go b/internal/acceptance/openstack/containerinfra/v1/containerinfra.go index 84ee98e87d..24f8c1959b 100644 --- a/internal/acceptance/openstack/containerinfra/v1/containerinfra.go +++ b/internal/acceptance/openstack/containerinfra/v1/containerinfra.go @@ -203,7 +203,7 @@ func WaitForCluster(client *gophercloud.ServiceClient, clusterID string, status } if strings.Contains(cluster.Status, "FAILED") { - return false, fmt.Errorf("Cluster %s FAILED. Status=%s StatusReason=%s", clusterID, cluster.Status, cluster.StatusReason) + return false, fmt.Errorf("cluster %s FAILED. Status=%s StatusReason=%s", clusterID, cluster.Status, cluster.StatusReason) } return false, nil diff --git a/internal/acceptance/openstack/db/v1/db.go b/internal/acceptance/openstack/db/v1/db.go index abc92553a0..fe529a0133 100644 --- a/internal/acceptance/openstack/db/v1/db.go +++ b/internal/acceptance/openstack/db/v1/db.go @@ -138,7 +138,7 @@ func WaitForInstanceStatus( } if latest.Status == "ERROR" { - return false, fmt.Errorf("Instance in ERROR state") + return false, fmt.Errorf("instance in ERROR state") } return false, nil diff --git a/internal/acceptance/openstack/keymanager/v1/keymanager.go b/internal/acceptance/openstack/keymanager/v1/keymanager.go index a44b57a4bf..87a965eb5c 100644 --- a/internal/acceptance/openstack/keymanager/v1/keymanager.go +++ b/internal/acceptance/openstack/keymanager/v1/keymanager.go @@ -646,7 +646,7 @@ func DeleteSecret(t *testing.T, client *gophercloud.ServiceClient, id string) { func ParseID(ref string) (string, error) { parts := strings.Split(ref, "/") if len(parts) < 2 { - return "", fmt.Errorf("Could not parse %s", ref) + return "", fmt.Errorf("could not parse %s", ref) } return parts[len(parts)-1], nil @@ -757,7 +757,7 @@ func WaitForOrder(client *gophercloud.ServiceClient, orderID string) error { } if order.Status == "ERROR" { - return false, fmt.Errorf("Order %s in ERROR state", orderID) + return false, fmt.Errorf("order %s in ERROR state", orderID) } return false, nil diff --git a/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go b/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go index 6a36a49d21..c7e94ba059 100644 --- a/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go +++ b/internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go @@ -47,7 +47,7 @@ func CreateListener(t *testing.T, client *gophercloud.ServiceClient, lb *loadbal t.Logf("Successfully created listener %s", listenerName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return listener, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return listener, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, listener.Name, listenerName) @@ -99,7 +99,7 @@ func CreateListenerHTTP(t *testing.T, client *gophercloud.ServiceClient, lb *loa t.Logf("Successfully created listener %s", listenerName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return listener, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return listener, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, listener.Name, listenerName) @@ -318,7 +318,7 @@ func CreateMember(t *testing.T, client *gophercloud.ServiceClient, lb *loadbalan t.Logf("Successfully created member %s", memberName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return member, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return member, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, member.Name, memberName) @@ -352,7 +352,7 @@ func CreateMonitor(t *testing.T, client *gophercloud.ServiceClient, lb *loadbala t.Logf("Successfully created monitor: %s", monitorName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return monitor, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return monitor, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, monitor.Name, monitorName) @@ -391,7 +391,7 @@ func CreatePool(t *testing.T, client *gophercloud.ServiceClient, lb *loadbalance t.Logf("Successfully created pool %s", poolName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return pool, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return pool, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, pool.Name, poolName) @@ -428,7 +428,7 @@ func CreatePoolHTTP(t *testing.T, client *gophercloud.ServiceClient, lb *loadbal t.Logf("Successfully created pool %s", poolName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return pool, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return pool, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, pool.Name, poolName) @@ -466,7 +466,7 @@ func CreateL7Policy(t *testing.T, client *gophercloud.ServiceClient, listener *l t.Logf("Successfully created l7 policy %s", policyName) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return policy, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return policy, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, policy.Name, policyName) @@ -498,7 +498,7 @@ func CreateL7Rule(t *testing.T, client *gophercloud.ServiceClient, policyID stri t.Logf("Successfully created l7 rule for policy %s", policyID) if err := WaitForLoadBalancerState(client, lb.ID, "ACTIVE"); err != nil { - return rule, fmt.Errorf("Timed out waiting for loadbalancer to become active: %s", err) + return rule, fmt.Errorf("timed out waiting for loadbalancer to become active: %s", err) } th.AssertEquals(t, rule.RuleType, string(l7policies.TypePath)) @@ -686,7 +686,7 @@ func WaitForLoadBalancerState(client *gophercloud.ServiceClient, lbID, status st } if current.ProvisioningStatus == "ERROR" { - return false, fmt.Errorf("Load balancer is in ERROR state") + return false, fmt.Errorf("load balancer is in ERROR state") } return false, nil diff --git a/internal/acceptance/openstack/orchestration/v1/orchestration.go b/internal/acceptance/openstack/orchestration/v1/orchestration.go index 3d45311fef..e6245ad83d 100644 --- a/internal/acceptance/openstack/orchestration/v1/orchestration.go +++ b/internal/acceptance/openstack/orchestration/v1/orchestration.go @@ -108,7 +108,7 @@ func WaitForStackStatus(client *gophercloud.ServiceClient, stackName, stackID, s } if latest.Status == "ERROR" { - return false, fmt.Errorf("Stack in ERROR state") + return false, fmt.Errorf("stack in ERROR state") } return false, nil diff --git a/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go b/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go index 6a2d31d08a..8a3b88815f 100644 --- a/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/replicas.go @@ -95,7 +95,7 @@ func waitForReplicaStatus(t *testing.T, c *gophercloud.ServiceClient, id, status } if strings.Contains(current.Status, "error") { - return true, fmt.Errorf("An error occurred, wrong status: %s", current.Status) + return true, fmt.Errorf("an error occurred, wrong status: %s", current.Status) } return false, nil @@ -104,7 +104,7 @@ func waitForReplicaStatus(t *testing.T, c *gophercloud.ServiceClient, id, status if err != nil { mErr := PrintMessages(t, c, id) if mErr != nil { - return fmt.Errorf("Replica status is '%s' and unable to get manila messages: %s", err, mErr) + return fmt.Errorf("replica status is '%s' and unable to get manila messages: %s", err, mErr) } } @@ -127,7 +127,7 @@ func waitForReplicaState(t *testing.T, c *gophercloud.ServiceClient, id, state s } if strings.Contains(current.State, "error") { - return true, fmt.Errorf("An error occurred, wrong state: %s", current.State) + return true, fmt.Errorf("an error occurred, wrong state: %s", current.State) } return false, nil @@ -136,7 +136,7 @@ func waitForReplicaState(t *testing.T, c *gophercloud.ServiceClient, id, state s if err != nil { mErr := PrintMessages(t, c, id) if mErr != nil { - return fmt.Errorf("Replica state is '%s' and unable to get manila messages: %s", err, mErr) + return fmt.Errorf("replica state is '%s' and unable to get manila messages: %s", err, mErr) } } diff --git a/internal/acceptance/openstack/sharedfilesystems/v2/shares.go b/internal/acceptance/openstack/sharedfilesystems/v2/shares.go index afb699627c..eacceebf1e 100644 --- a/internal/acceptance/openstack/sharedfilesystems/v2/shares.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/shares.go @@ -120,12 +120,12 @@ func PrintMessages(t *testing.T, c *gophercloud.ServiceClient, id string) error allPages, err := messages.List(c, messages.ListOpts{ResourceID: id}).AllPages(context.TODO()) if err != nil { - return fmt.Errorf("Unable to retrieve messages: %v", err) + return fmt.Errorf("unable to retrieve messages: %v", err) } allMessages, err := messages.ExtractMessages(allPages) if err != nil { - return fmt.Errorf("Unable to extract messages: %v", err) + return fmt.Errorf("unable to extract messages: %v", err) } for _, message := range allMessages { @@ -159,7 +159,7 @@ func waitForStatus(t *testing.T, c *gophercloud.ServiceClient, id, status string } if strings.Contains(current.Status, "error") { - return true, fmt.Errorf("An error occurred, wrong status: %s", current.Status) + return true, fmt.Errorf("an error occurred, wrong status: %s", current.Status) } return false, nil @@ -168,7 +168,7 @@ func waitForStatus(t *testing.T, c *gophercloud.ServiceClient, id, status string if err != nil { mErr := PrintMessages(t, c, id) if mErr != nil { - return current, fmt.Errorf("Share status is '%s' and unable to get manila messages: %s", err, mErr) + return current, fmt.Errorf("share status is '%s' and unable to get manila messages: %s", err, mErr) } } diff --git a/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go index 4fb3128f29..9c5ccb7949 100644 --- a/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go +++ b/internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go @@ -90,7 +90,7 @@ func waitForSnapshotStatus(t *testing.T, c *gophercloud.ServiceClient, id, statu } if strings.Contains(current.Status, "error") { - return true, fmt.Errorf("An error occurred, wrong status: %s", current.Status) + return true, fmt.Errorf("an error occurred, wrong status: %s", current.Status) } return false, nil @@ -99,7 +99,7 @@ func waitForSnapshotStatus(t *testing.T, c *gophercloud.ServiceClient, id, statu if err != nil { mErr := PrintMessages(t, c, id) if mErr != nil { - return fmt.Errorf("Snapshot status is '%s' and unable to get manila messages: %s", err, mErr) + return fmt.Errorf("snapshot status is '%s' and unable to get manila messages: %s", err, mErr) } } diff --git a/internal/acceptance/openstack/workflow/v2/execution.go b/internal/acceptance/openstack/workflow/v2/execution.go index d2c2a71970..9a3eccaa9d 100644 --- a/internal/acceptance/openstack/workflow/v2/execution.go +++ b/internal/acceptance/openstack/workflow/v2/execution.go @@ -48,7 +48,7 @@ func CreateExecution(t *testing.T, client *gophercloud.ServiceClient, workflow * } if latest.State == "ERROR" { - return false, fmt.Errorf("Execution in ERROR state") + return false, fmt.Errorf("execution in ERROR state") } return false, nil diff --git a/openstack/baremetal/httpbasic/requests.go b/openstack/baremetal/httpbasic/requests.go index 3b13dd4637..6eb65eff14 100644 --- a/openstack/baremetal/httpbasic/requests.go +++ b/openstack/baremetal/httpbasic/requests.go @@ -20,7 +20,7 @@ func initClientOpts(client *gophercloud.ProviderClient, eo EndpointOpts) (*gophe return nil, fmt.Errorf("IronicEndpoint is required") } if eo.IronicUser == "" || eo.IronicUserPassword == "" { - return nil, fmt.Errorf("User and Password are required") + return nil, fmt.Errorf("IronicUser and IronicUserPassword are required") } token := []byte(eo.IronicUser + ":" + eo.IronicUserPassword) diff --git a/openstack/baremetal/httpbasic/testing/requests_test.go b/openstack/baremetal/httpbasic/testing/requests_test.go index d8c9faf5ba..9618a1b1df 100644 --- a/openstack/baremetal/httpbasic/testing/requests_test.go +++ b/openstack/baremetal/httpbasic/testing/requests_test.go @@ -24,7 +24,7 @@ func TestHttpBasic(t *testing.T) { IronicEndpoint: "http://ironic:6385/v1", }) _ = errTest1 - th.AssertEquals(t, "User and Password are required", err.Error()) + th.AssertEquals(t, "IronicUser and IronicUserPassword are required", err.Error()) errTest2, err := httpbasic.NewBareMetalHTTPBasic(httpbasic.EndpointOpts{ IronicUser: "myUser", diff --git a/openstack/baremetal/inventory/plugindata.go b/openstack/baremetal/inventory/plugindata.go index 3c4666eb34..4cbd8214e7 100644 --- a/openstack/baremetal/inventory/plugindata.go +++ b/openstack/baremetal/inventory/plugindata.go @@ -54,7 +54,7 @@ func (r *LLDPTLVType) UnmarshalJSON(data []byte) error { } if len(list) != 2 { - return fmt.Errorf("Invalid LLDP TLV key-value pair") + return fmt.Errorf("invalid LLDP TLV key-value pair") } fieldtype, ok := list[0].(float64) diff --git a/openstack/baremetalintrospection/httpbasic/requests.go b/openstack/baremetalintrospection/httpbasic/requests.go index 473e92c372..023ef67046 100644 --- a/openstack/baremetalintrospection/httpbasic/requests.go +++ b/openstack/baremetalintrospection/httpbasic/requests.go @@ -20,7 +20,7 @@ func initClientOpts(client *gophercloud.ProviderClient, eo EndpointOpts) (*gophe return nil, fmt.Errorf("IronicInspectorEndpoint is required") } if eo.IronicInspectorUser == "" || eo.IronicInspectorUserPassword == "" { - return nil, fmt.Errorf("User and Password are required") + return nil, fmt.Errorf("IronicInspectorUser and IronicInspectorUserPassword are required") } token := []byte(eo.IronicInspectorUser + ":" + eo.IronicInspectorUserPassword) diff --git a/openstack/baremetalintrospection/httpbasic/testing/requests_test.go b/openstack/baremetalintrospection/httpbasic/testing/requests_test.go index df091e0cc9..bceb8c5d8c 100644 --- a/openstack/baremetalintrospection/httpbasic/testing/requests_test.go +++ b/openstack/baremetalintrospection/httpbasic/testing/requests_test.go @@ -23,7 +23,7 @@ func TestNoAuth(t *testing.T) { IronicInspectorEndpoint: "http://ironic:5050/v1", }) _ = errTest1 - th.AssertEquals(t, "User and Password are required", err.Error()) + th.AssertEquals(t, "IronicInspectorUser and IronicInspectorUserPassword are required", err.Error()) errTest2, err := httpbasic.NewBareMetalIntrospectionHTTPBasic(httpbasic.EndpointOpts{ IronicInspectorUser: "myUser", diff --git a/openstack/blockstorage/noauth/requests.go b/openstack/blockstorage/noauth/requests.go index cf887553f0..e9d1a156b1 100644 --- a/openstack/blockstorage/noauth/requests.go +++ b/openstack/blockstorage/noauth/requests.go @@ -39,7 +39,7 @@ func initClientOpts(client *gophercloud.ProviderClient, eo EndpointOpts, clientT token := strings.Split(client.TokenID, ":") if len(token) != 2 { - return nil, fmt.Errorf("Malformed noauth token") + return nil, fmt.Errorf("malformed noauth token") } endpoint := fmt.Sprintf("%s%s", gophercloud.NormalizeURL(eo.CinderEndpoint), token[1]) diff --git a/openstack/blockstorage/v2/quotasets/testing/requests_test.go b/openstack/blockstorage/v2/quotasets/testing/requests_test.go index 7a5bc8fe0a..5e40907675 100644 --- a/openstack/blockstorage/v2/quotasets/testing/requests_test.go +++ b/openstack/blockstorage/v2/quotasets/testing/requests_test.go @@ -57,7 +57,7 @@ func TestPartialUpdate(t *testing.T) { type ErrorUpdateOpts quotasets.UpdateOpts func (opts ErrorUpdateOpts) ToBlockStorageQuotaUpdateMap() (map[string]any, error) { - return nil, errors.New("This is an error") + return nil, errors.New("this is an error") } func TestErrorInToBlockStorageQuotaUpdateMap(t *testing.T) { diff --git a/openstack/blockstorage/v3/quotasets/testing/requests_test.go b/openstack/blockstorage/v3/quotasets/testing/requests_test.go index 0b8b74e514..9cf76b2a3f 100644 --- a/openstack/blockstorage/v3/quotasets/testing/requests_test.go +++ b/openstack/blockstorage/v3/quotasets/testing/requests_test.go @@ -57,7 +57,7 @@ func TestPartialUpdate(t *testing.T) { type ErrorUpdateOpts quotasets.UpdateOpts func (opts ErrorUpdateOpts) ToBlockStorageQuotaUpdateMap() (map[string]any, error) { - return nil, errors.New("This is an error") + return nil, errors.New("this is an error") } func TestErrorInToBlockStorageQuotaUpdateMap(t *testing.T) { diff --git a/openstack/client.go b/openstack/client.go index 0d71332c81..03a3d2903e 100644 --- a/openstack/client.go +++ b/openstack/client.go @@ -104,7 +104,7 @@ func Authenticate(ctx context.Context, client *gophercloud.ProviderClient, optio return v3auth(ctx, client, endpoint, &options, gophercloud.EndpointOpts{}) default: // The switch statement must be out of date from the versions list. - return fmt.Errorf("Unrecognized identity version: %s", chosen.ID) + return fmt.Errorf("unrecognized identity version: %s", chosen.ID) } } diff --git a/openstack/compute/v2/hypervisors/results.go b/openstack/compute/v2/hypervisors/results.go index 0a35dfdf0f..55ae98bf56 100644 --- a/openstack/compute/v2/hypervisors/results.go +++ b/openstack/compute/v2/hypervisors/results.go @@ -194,7 +194,7 @@ func (r *Hypervisor) UnmarshalJSON(b []byte) error { case float64: r.HypervisorVersion = int(t) default: - return fmt.Errorf("Hypervisor version has unexpected type: %T", t) + return fmt.Errorf("HypervisorVersion has unexpected type: %T", t) } // free_disk_gb doesn't exist after api version 2.87 @@ -205,7 +205,7 @@ func (r *Hypervisor) UnmarshalJSON(b []byte) error { case float64: r.FreeDiskGB = int(t) default: - return fmt.Errorf("Free disk GB has unexpected type: %T", t) + return fmt.Errorf("FreeDiskGB has unexpected type: %T", t) } } @@ -217,7 +217,7 @@ func (r *Hypervisor) UnmarshalJSON(b []byte) error { case float64: r.LocalGB = int(t) default: - return fmt.Errorf("Local GB has unexpected type: %T", t) + return fmt.Errorf("LocalGB has unexpected type: %T", t) } } diff --git a/openstack/compute/v2/quotasets/testing/requests_test.go b/openstack/compute/v2/quotasets/testing/requests_test.go index c46afd343d..5b17b5777d 100644 --- a/openstack/compute/v2/quotasets/testing/requests_test.go +++ b/openstack/compute/v2/quotasets/testing/requests_test.go @@ -59,7 +59,7 @@ func TestDelete(t *testing.T) { type ErrorUpdateOpts quotasets.UpdateOpts func (opts ErrorUpdateOpts) ToComputeQuotaUpdateMap() (map[string]any, error) { - return nil, errors.New("This is an error") + return nil, errors.New("this is an error") } func TestErrorInToComputeQuotaUpdateMap(t *testing.T) { diff --git a/openstack/compute/v2/servers/results.go b/openstack/compute/v2/servers/results.go index 8e9d9b2ad7..fa4ce38ffd 100644 --- a/openstack/compute/v2/servers/results.go +++ b/openstack/compute/v2/servers/results.go @@ -117,11 +117,11 @@ func decryptPassword(encryptedPassword string, privateKey *rsa.PrivateKey) (stri n, err := base64.StdEncoding.Decode(b64EncryptedPassword, []byte(encryptedPassword)) if err != nil { - return "", fmt.Errorf("Failed to base64 decode encrypted password: %s", err) + return "", fmt.Errorf("failed to base64 decode encrypted password: %s", err) } password, err := rsa.DecryptPKCS1v15(nil, privateKey, b64EncryptedPassword[0:n]) if err != nil { - return "", fmt.Errorf("Failed to decrypt password: %s", err) + return "", fmt.Errorf("failed to decrypt password: %s", err) } return string(password), nil @@ -139,7 +139,7 @@ func (r CreateImageResult) ExtractImageID() (string, error) { } imageID := path.Base(u.Path) if imageID == "." || imageID == "/" { - return "", fmt.Errorf("Failed to parse the ID of newly created image: %s", u) + return "", fmt.Errorf("failed to parse the ID of newly created image: %s", u) } return imageID, nil } diff --git a/openstack/container/v1/capsules/results.go b/openstack/container/v1/capsules/results.go index c417bb2038..7c8a2fc178 100644 --- a/openstack/container/v1/capsules/results.go +++ b/openstack/container/v1/capsules/results.go @@ -258,7 +258,7 @@ func (r CapsulePage) IsEmpty() (bool, error) { return len(v) == 0, nil } - return false, fmt.Errorf("Unable to determine Capsule type") + return false, fmt.Errorf("unable to determine Capsule type") } // ExtractCapsulesBase accepts a Page struct, specifically a CapsulePage struct, diff --git a/openstack/identity/v3/users/results.go b/openstack/identity/v3/users/results.go index d9e7aaab66..18d3f46e1d 100644 --- a/openstack/identity/v3/users/results.go +++ b/openstack/identity/v3/users/results.go @@ -67,10 +67,10 @@ func (r *User) UnmarshalJSON(b []byte) error { case string: r.Enabled, err = strconv.ParseBool(t) if err != nil { - return fmt.Errorf("Failed to parse Enabled %q: %v", t, err) + return fmt.Errorf("failed to parse Enabled %q: %v", t, err) } default: - return fmt.Errorf("Unknown type for Enabled: %T (value: %v)", t, t) + return fmt.Errorf("unknown type for Enabled: %T (value: %v)", t, t) } // Collect other fields and bundle them into Extra diff --git a/openstack/image/v2/imagedata/testing/requests_test.go b/openstack/image/v2/imagedata/testing/requests_test.go index 3a5c26706c..63294a1323 100644 --- a/openstack/image/v2/imagedata/testing/requests_test.go +++ b/openstack/image/v2/imagedata/testing/requests_test.go @@ -82,7 +82,7 @@ func (rs *RS) Seek(offset int64, whence int) (int64, error) { case 2: rs.offset = len(rs.bs) - offsetInt default: - return 0, fmt.Errorf("For parameter `whence`, expected value in {0,1,2} but got: %#v", whence) + return 0, fmt.Errorf("for parameter `whence`, expected value in {0,1,2} but got: %#v", whence) } return int64(rs.offset), nil diff --git a/openstack/image/v2/images/results.go b/openstack/image/v2/images/results.go index 6652f0e791..f9c6e13ba4 100644 --- a/openstack/image/v2/images/results.go +++ b/openstack/image/v2/images/results.go @@ -120,7 +120,7 @@ func (r *Image) UnmarshalJSON(b []byte) error { case float64: r.SizeBytes = int64(t) default: - return fmt.Errorf("Unknown type for SizeBytes: %v (value: %v)", reflect.TypeOf(t), t) + return fmt.Errorf("unknown type for SizeBytes: %v (value: %v)", reflect.TypeOf(t), t) } // Bundle all other fields into Properties diff --git a/openstack/networking/v2/extensions/quotas/results.go b/openstack/networking/v2/extensions/quotas/results.go index 8b1ae8a95d..249d115175 100644 --- a/openstack/networking/v2/extensions/quotas/results.go +++ b/openstack/networking/v2/extensions/quotas/results.go @@ -166,7 +166,7 @@ func (q *QuotaDetail) UnmarshalJSON(b []byte) error { return err } default: - return fmt.Errorf("reserved has unexpected type: %T", t) + return fmt.Errorf("Reserved has unexpected type: %T", t) //nolint:staticcheck } return nil diff --git a/openstack/objectstorage/v1/containers/results.go b/openstack/objectstorage/v1/containers/results.go index fddfa26bf1..ddbdfca623 100644 --- a/openstack/objectstorage/v1/containers/results.go +++ b/openstack/objectstorage/v1/containers/results.go @@ -89,7 +89,7 @@ func ExtractNames(page pagination.Page) ([]string, error) { return names, nil default: - return nil, fmt.Errorf("Cannot extract names from response with content-type: [%s]", ct) + return nil, fmt.Errorf("cannot extract names from response with content-type: [%s]", ct) } } diff --git a/openstack/objectstorage/v1/objects/results.go b/openstack/objectstorage/v1/objects/results.go index d7849e9ecb..387516994b 100644 --- a/openstack/objectstorage/v1/objects/results.go +++ b/openstack/objectstorage/v1/objects/results.go @@ -133,7 +133,7 @@ func ExtractNames(r pagination.Page) ([]string, error) { case strings.HasPrefix(ct, "text/html"): return []string{}, nil default: - return nil, fmt.Errorf("Cannot extract names from response with content-type: [%s]", ct) + return nil, fmt.Errorf("cannot extract names from response with content-type: [%s]", ct) } } @@ -542,6 +542,6 @@ func extractLastMarker(r pagination.Page) (string, error) { case strings.HasPrefix(ct, "text/html"): return "", nil default: - return "", fmt.Errorf("Cannot extract names from response with content-type: [%s]", ct) + return "", fmt.Errorf("cannot extract names from response with content-type: [%s]", ct) } } diff --git a/openstack/sharedfilesystems/v2/errors/errors.go b/openstack/sharedfilesystems/v2/errors/errors.go index f01d6bd588..34324b08ba 100644 --- a/openstack/sharedfilesystems/v2/errors/errors.go +++ b/openstack/sharedfilesystems/v2/errors/errors.go @@ -21,6 +21,6 @@ func ExtractErrorInto(rawError error, errorDetails *ErrorDetails) (err error) { if errors.As(rawError, &codeError) { return json.Unmarshal(codeError.Body, errorDetails) } else { - return errors.New("Unable to extract detailed error message") + return errors.New("unable to extract detailed error message") } } diff --git a/openstack/utils/choose_version.go b/openstack/utils/choose_version.go index 6c720e57ef..1c2727cb99 100644 --- a/openstack/utils/choose_version.go +++ b/openstack/utils/choose_version.go @@ -89,7 +89,7 @@ func ChooseVersion(ctx context.Context, client *gophercloud.ProviderClient, reco // Prefer a version that exactly matches the provided endpoint. if href == identityEndpoint { if href == "" { - return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", value.ID, client.IdentityBase) + return nil, "", fmt.Errorf("endpoint missing in version %s response from %s", value.ID, client.IdentityBase) } return version, href, nil } @@ -106,10 +106,10 @@ func ChooseVersion(ctx context.Context, client *gophercloud.ProviderClient, reco } if highest == nil { - return nil, "", fmt.Errorf("No supported version available from endpoint %s", client.IdentityBase) + return nil, "", fmt.Errorf("no supported version available from endpoint %s", client.IdentityBase) } if endpoint == "" { - return nil, "", fmt.Errorf("Endpoint missing in version %s response from %s", highest.ID, client.IdentityBase) + return nil, "", fmt.Errorf("endpoint missing in version %s response from %s", highest.ID, client.IdentityBase) } return highest, endpoint, nil diff --git a/pagination/pager.go b/pagination/pager.go index 3581012566..2eed649f78 100644 --- a/pagination/pager.go +++ b/pagination/pager.go @@ -13,7 +13,7 @@ import ( var ( // ErrPageNotAvailable is returned from a Pager when a next or previous page is requested, but does not exist. - ErrPageNotAvailable = errors.New("The requested page does not exist.") + ErrPageNotAvailable = errors.New("the requested page does not exist") ) // Page must be satisfied by the result type of any resource collection. diff --git a/params.go b/params.go index f7135b2dfa..e282033683 100644 --- a/params.go +++ b/params.go @@ -219,12 +219,12 @@ func BuildRequestBody(opts any, parent string) (map[string]any, error) { optsMaps[i] = b } if parent == "" { - return nil, fmt.Errorf("Parent is required when passing an array or a slice.") + return nil, fmt.Errorf("parent is required when passing an array or a slice") } return map[string]any{parent: optsMaps}, nil } // Return an error if we can't work with the underlying type of 'opts' - return nil, fmt.Errorf("Options type is not a struct, a slice, or an array.") + return nil, fmt.Errorf("options type is not a struct, a slice, or an array") } // EnabledState is a convenience type, mostly used in Create and Update @@ -429,7 +429,7 @@ func BuildQueryString(opts any) (*url.URL, error) { } else { // if the field has a 'required' tag, it can't have a zero-value if requiredTag := f.Tag.Get("required"); requiredTag == "true" { - return &url.URL{}, fmt.Errorf("Required query parameter [%s] not set.", f.Name) + return &url.URL{}, fmt.Errorf("required query parameter [%s] not set", f.Name) } } } @@ -438,7 +438,7 @@ func BuildQueryString(opts any) (*url.URL, error) { return &url.URL{RawQuery: params.Encode()}, nil } // Return an error if the underlying type of 'opts' isn't a struct. - return nil, fmt.Errorf("Options type is not a struct.") + return nil, fmt.Errorf("options type is not a struct") } /* @@ -509,7 +509,7 @@ func BuildHeaders(opts any) (map[string]string, error) { } else { // if the field has a 'required' tag, it can't have a zero-value if requiredTag := f.Tag.Get("required"); requiredTag == "true" { - return optsMap, fmt.Errorf("Required header [%s] not set.", f.Name) + return optsMap, fmt.Errorf("required header [%s] not set", f.Name) } } } @@ -518,7 +518,7 @@ func BuildHeaders(opts any) (map[string]string, error) { return optsMap, nil } // Return an error if the underlying type of 'opts' isn't a struct. - return optsMap, fmt.Errorf("Options type is not a struct.") + return optsMap, fmt.Errorf("options type is not a struct") } // IDSliceToQueryString takes a slice of elements and converts them into a query diff --git a/results.go b/results.go index b12c15a026..d5b947b7f0 100644 --- a/results.go +++ b/results.go @@ -185,23 +185,23 @@ func (r Result) ExtractIntoStructPtr(to any, label string) error { } if to == nil { - return fmt.Errorf("Expected pointer, got %T", to) + return fmt.Errorf("expected pointer, got %T", to) } t := reflect.TypeOf(to) if k := t.Kind(); k != reflect.Ptr { - return fmt.Errorf("Expected pointer, got %v", k) + return fmt.Errorf("expected pointer, got %v", k) } if reflect.ValueOf(to).IsNil() { - return fmt.Errorf("Expected pointer, got %T", to) + return fmt.Errorf("expected pointer, got %T", to) } switch t.Elem().Kind() { case reflect.Struct: return r.extractIntoPtr(to, label) default: - return fmt.Errorf("Expected pointer to struct, got: %v", t) + return fmt.Errorf("expected pointer to struct, got: %v", t) } } @@ -220,23 +220,23 @@ func (r Result) ExtractIntoSlicePtr(to any, label string) error { } if to == nil { - return fmt.Errorf("Expected pointer, got %T", to) + return fmt.Errorf("expected pointer, got %T", to) } t := reflect.TypeOf(to) if k := t.Kind(); k != reflect.Ptr { - return fmt.Errorf("Expected pointer, got %v", k) + return fmt.Errorf("expected pointer, got %v", k) } if reflect.ValueOf(to).IsNil() { - return fmt.Errorf("Expected pointer, got %T", to) + return fmt.Errorf("expected pointer, got %T", to) } switch t.Elem().Kind() { case reflect.Slice: return r.extractIntoPtr(to, label) default: - return fmt.Errorf("Expected pointer to slice, got: %v", t) + return fmt.Errorf("expected pointer to slice, got: %v", t) } } diff --git a/testing/provider_client_test.go b/testing/provider_client_test.go index 900d53021a..7e9cb7be44 100644 --- a/testing/provider_client_test.go +++ b/testing/provider_client_test.go @@ -161,7 +161,7 @@ func TestReauthEndLoop(t *testing.T) { if info.reauthAttempts > 5 { info.maxReauthReached = true - return fmt.Errorf("Max reauthentication attempts reached") + return fmt.Errorf("max reauthentication attempts reached") } p.SetThrowaway(true) p.AuthenticatedHeaders() diff --git a/testing/util_test.go b/testing/util_test.go index 6b6b425f45..93fa2efb8f 100644 --- a/testing/util_test.go +++ b/testing/util_test.go @@ -47,9 +47,9 @@ func TestWaitForError(t *testing.T) { defer cancel() err := gophercloud.WaitFor(ctx, func(context.Context) (bool, error) { - return false, errors.New("Error has occurred") + return false, errors.New("error has occurred") }) - th.AssertEquals(t, "Error has occurred", err.Error()) + th.AssertEquals(t, "error has occurred", err.Error()) } func TestWaitForPredicateExceed(t *testing.T) { @@ -67,7 +67,7 @@ func TestWaitForPredicateExceed(t *testing.T) { return true, ctx.Err() case <-time.After(4 * time.Second): - return false, errors.New("Just wasting time") + return false, errors.New("just wasting time") } }) th.AssertErrIs(t, err, context.DeadlineExceeded) From 02c2636a8a1ebadde70ee6c8f3f31d07cf67b3e9 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 16 May 2025 12:02:04 +0100 Subject: [PATCH 10/10] lint: Remove non-constant format string in calls I'm not sure why this was disabled, but undisable it. Signed-off-by: Stephen Finucane --- .golangci.yaml | 2 -- .../security/addressgroups/testing/requests_test.go | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index b138f3161c..2de1155c03 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -18,8 +18,6 @@ linters: - linters: - staticcheck text: "SA1019: (x509.EncryptPEMBlock|strings.Title)" - - path: (.+)\.go$ - text: SA1006 paths: - third_party$ - builtin$ diff --git a/openstack/networking/v2/extensions/security/addressgroups/testing/requests_test.go b/openstack/networking/v2/extensions/security/addressgroups/testing/requests_test.go index 24abf1cb72..37f8184dc2 100644 --- a/openstack/networking/v2/extensions/security/addressgroups/testing/requests_test.go +++ b/openstack/networking/v2/extensions/security/addressgroups/testing/requests_test.go @@ -23,7 +23,7 @@ func TestList(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AddressGroupListResponse) + fmt.Fprint(w, AddressGroupListResponse) }) count := 0 @@ -73,7 +73,7 @@ func TestCreate(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusCreated) - fmt.Fprintf(w, AddressGroupCreateResponse) + fmt.Fprint(w, AddressGroupCreateResponse) }) opts := addressgroups.CreateOpts{ @@ -107,7 +107,7 @@ func TestGet(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AddressGroupGetResponse) + fmt.Fprint(w, AddressGroupGetResponse) }) sr, err := addressgroups.Get(context.TODO(), fake.ServiceClient(fakeServer), "8722e0e0-9cc9-4490-9660-8c9a5732fbb0").Extract() @@ -134,7 +134,7 @@ func TestUpdate(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AddressGroupUpdateResponse) + fmt.Fprint(w, AddressGroupUpdateResponse) }) name := "ADDR_GP_2" @@ -168,7 +168,7 @@ func TestAddAddresses(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AddressGroupAddAddressesResponse) + fmt.Fprint(w, AddressGroupAddAddressesResponse) }) opts := addressgroups.UpdateAddressesOpts{ @@ -197,7 +197,7 @@ func TestRemoveAddresses(t *testing.T) { w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, AddressGroupRemoveAddressesResponse) + fmt.Fprint(w, AddressGroupRemoveAddressesResponse) }) opts := addressgroups.UpdateAddressesOpts{