Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bump golangci-lint to v2 and fix new lint issues #3385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
Loading
from
Open
39 changes: 27 additions & 12 deletions 39 .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
---
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: "SA1019: (x509.EncryptPEMBlock|strings.Title)"
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion 2 Makefile
Original file line number Diff line number Diff line change
@@ -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"

Expand Down
4 changes: 2 additions & 2 deletions 4 docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
//...
Expand Down Expand Up @@ -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++
}
Expand Down
6 changes: 2 additions & 4 deletions 6 internal/acceptance/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/acceptance/clients/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/blockstorage/v2/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/blockstorage/v3/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/compute/v2/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/compute/v2/quotaset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/container/v1/capsules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 2 internal/acceptance/openstack/db/v1/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions 6 internal/acceptance/openstack/identity/v3/domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion 2 internal/acceptance/openstack/identity/v3/oauth1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion 2 internal/acceptance/openstack/identity/v3/projects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion 2 internal/acceptance/openstack/identity/v3/users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
4 changes: 2 additions & 2 deletions 4 internal/acceptance/openstack/keymanager/v1/keymanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions 18 internal/acceptance/openstack/loadbalancer/v2/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.