Skip to content
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

fix(deps): update module github.com/gophercloud/gophercloud to v2 #366

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 92 additions & 60 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,61 @@ linters-settings:
statements: 50
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- hugeParam
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
- hugeParam

gocyclo:
min-complexity: 30
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]
mnd:
# don't include the "operation" and "assign"
checks: [argument, case, condition, return]

revive:
enable-all-rules: false
rules:
# enable (taken from https://github.com/mgechev/revive/blob/master/defaults.toml)
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
- name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
# tweaks
- name: dot-imports
exclude: [TEST]
- name: unused-parameter
exclude: [TEST]

govet:
check-shadowing: false
disable:
- shadow
lll:
line-length: 140
misspell:
Expand All @@ -45,31 +78,31 @@ linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- bodyclose
- dogsled
- gocritic
- gofmt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
- revive
- dupl
- gocyclo
- gosec
- nolintlint
- bodyclose
- dogsled
- gocritic
- gofmt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- lll
- misspell
- nakedret
- rowserrcheck
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace
- revive
- dupl
- gocyclo
- gosec
- nolintlint

# don't enable:
# - noctx
Expand Down Expand Up @@ -98,28 +131,27 @@ linters:
issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- gochecknoglobals
- gosec
- noctx
- goerr113
- goconst
- dupl
- unparam
- path: _test\.go
linters:
- gomnd
- gochecknoglobals
- gosec
- noctx
- goerr113
- goconst
- dupl
- unparam

# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"
# https://github.com/go-critic/go-critic/issues/926
- linters:
- gocritic
text: "unnecessaryDefer:"

- text: "should not use dot imports"
path: _test\.go
- text: "should not use dot imports"
path: _test\.go

# silence stupid linter errors
exclude:
- directive `// nolint.*` should be written without leading space
- directive `// nolint.*` should be written without leading space

run:
timeout: 15m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/go-logr/logr"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
"github.com/gophercloud/gophercloud/v2"
"github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servergroups"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports"
errors2 "k8s.io/apimachinery/pkg/api/errors"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -422,7 +422,7 @@ func (r *Reconciler) reconcileFIP(
var fip *floatingips.FloatingIP
if fip, err = openstackhelper.GetFIPByID(ctx, fipClient, *lb.Status.FloatingID); err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("fip not found in openstack", "fip", *lb.Status.FloatingID)
// fip not found by ID, remove it from status and trigger reconcile
if err := helper.RemoveFromLBStatus(ctx, r.Status(), lb, "floatingID"); err != nil {
Expand Down Expand Up @@ -477,7 +477,7 @@ func (r *Reconciler) assignOrCreateFIP(
r.Log.Info("Use ExistingFloatingIP", "lb", lb.Name)
if fip, err = openstackhelper.GetFIPByIP(ctx, fipClient, *lb.Spec.ExistingFloatingIP); err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("configured fip not found in openstack", "fip", *lb.Spec.ExistingFloatingIP)
return kubernetes.SendErrorAsEvent(r.RecorderLB, err, lb)
default:
Expand Down Expand Up @@ -613,7 +613,7 @@ func (r *Reconciler) reconcilePort( //nolint: gocyclo // TODO reduce complexity
if lb.Status.PortID != nil {
if port, err = openstackhelper.GetPortByID(ctx, portClient, *lb.Status.PortID); err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("port not found in openstack", "portID", *lb.Status.PortID)
if err := helper.RemoveFromLBStatus(ctx, r.Status(), lb, "portID"); err != nil {
return false, err
Expand Down Expand Up @@ -755,7 +755,7 @@ func (r *Reconciler) reconcileSecGroup(
if lb.Status.SecurityGroupID != nil {
if secGroup, err = openstackhelper.GetSecGroupByID(ctx, groupClient, *lb.Status.SecurityGroupID); err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("SecurityGroupID not found in openstack", "SecurityGroupID", *lb.Status.SecurityGroupID)
if err := helper.RemoveFromLBStatus(ctx, r.Status(), lb, "securityGroupID"); err != nil {
return false, err
Expand Down Expand Up @@ -863,7 +863,7 @@ func (r *Reconciler) reconcileServerGroup(
if lb.Status.ServerGroupID != nil {
if serverGroup, err = openstackhelper.GetServerGroupByID(ctx, serverGroupClient, *lb.Status.ServerGroupID); err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("server group not found in openstack", "serverGroupID", *lb.Status.ServerGroupID)
if err := helper.RemoveFromLBStatus(ctx, r.Status(), lb, "serverGroupID"); err != nil {
return false, err
Expand Down Expand Up @@ -1189,7 +1189,7 @@ func (r *Reconciler) deleteFips(

// if error is openstack error
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("error getting fip, already deleted", "lb", lb.Namespace+"/"+lb.Name, "fipId", *lb.Status.FloatingID)
// requeue true to delete fips by floatingName in the next run
return true, helper.RemoveFromLBStatus(ctx, r.Status(), lb, "floatingID")
Expand Down Expand Up @@ -1284,7 +1284,7 @@ func (r *Reconciler) deletePorts(
port, err := openstackhelper.GetPortByID(ctx, portClient, *lb.Status.PortID)
if err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("port has already been deleted", "lb", lb.Namespace+"/"+lb.Name, "portID", *lb.Status.PortID)
// requeue true to clean orphan ports in the next run
_ = helper.RemoveFromLBStatus(ctx, r.Status(), lb, "portIP")
Expand Down Expand Up @@ -1385,7 +1385,7 @@ func (r *Reconciler) deleteSecGroups(
secGroup, err := openstackhelper.GetSecGroupByID(ctx, groupClient, *lb.Status.SecurityGroupID)
if err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("secGroup has already been deleted", "lb", lb.Namespace+"/"+lb.Name, "secGroup", *lb.Status.SecurityGroupID)
// requeue to clean orphan secgroups
err := helper.RemoveFromLBStatus(ctx, r.Status(), lb, "securityGroupID")
Expand Down Expand Up @@ -1472,7 +1472,7 @@ func (r *Reconciler) deleteServerGroups(
serverGroup, err := openstackhelper.GetServerGroupByID(ctx, serverGroupClient, *lb.Status.ServerGroupID)
if err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("server group has already been deleted",
"lb", lb.Namespace+"/"+lb.Name, "serverGroupID", *lb.Status.ServerGroupID)
// requeue to clean orphan server groups
Expand Down Expand Up @@ -1500,7 +1500,7 @@ func (r *Reconciler) deleteServerGroups(
serverGroup, err := openstackhelper.GetServerGroupByName(ctx, serverGroupClient, *lb.Status.ServerGroupName)
if err != nil {
switch err.(type) {
case gophercloud.ErrDefault404, gophercloud.ErrResourceNotFound:
case gophercloud.ErrUnexpectedResponseCode, gophercloud.ErrResourceNotFound:
r.Log.Info("server group has already been deleted", "lb", lb.Namespace+"/"+lb.Name, "serverGroup", *lb.Status.ServerGroupName)
// requeue to clean orphan secgroups
return true, helper.RemoveFromLBStatus(ctx, r.Status(), lb, "serverGroupName")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gstruct"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
"github.com/gophercloud/gophercloud/v2"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/layer3/floatingips"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/extensions/security/rules"
"github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports"

yawolv1beta1 "github.com/stackitcloud/yawol/api/v1beta1"
"github.com/stackitcloud/yawol/internal/helper"
Expand Down Expand Up @@ -704,29 +704,26 @@ var _ = Describe("loadbalancer controller", Serial, Ordered, func() {
BeforeEach(func() {
mockClient.GroupClientObj = &testing.CallbackGroupClient{
ListFunc: func(_ context.Context, _ groups.ListOpts) ([]groups.SecGroup, error) {
return []groups.SecGroup{}, gophercloud.ErrDefault401{
ErrUnexpectedResponseCode: gophercloud.ErrUnexpectedResponseCode{
Body: []byte("Auth failed"),
},
return []groups.SecGroup{}, gophercloud.ErrUnexpectedResponseCode{
// Actual: 401,
Kumm-Kai marked this conversation as resolved.
Show resolved Hide resolved
Body: []byte("Auth failed"),
}
},
GetFunc: func(_ context.Context, _ string) (*groups.SecGroup, error) {
return nil, gophercloud.ErrDefault401{
ErrUnexpectedResponseCode: gophercloud.ErrUnexpectedResponseCode{
Body: []byte("Auth failed"),
},
return nil, gophercloud.ErrUnexpectedResponseCode{
Body: []byte("Auth failed"),
}
},
CreateFunc: func(_ context.Context, _ groups.CreateOptsBuilder) (*groups.SecGroup, error) {
return nil, gophercloud.ErrDefault401{}
return nil, gophercloud.ErrUnexpectedResponseCode{}
},
DeleteFunc: func(_ context.Context, _ string) error {
return gophercloud.ErrDefault401{}
return gophercloud.ErrUnexpectedResponseCode{}
},
}
mockClient.FipClientObj = &testing.CallbackFipClient{
GetFunc: func(_ context.Context, _ string) (*floatingips.FloatingIP, error) {
return nil, gophercloud.ErrDefault403{}
return nil, gophercloud.ErrUnexpectedResponseCode{}
},
}
})
Expand Down
Loading