Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
stehessel committed Dec 27, 2022
1 parent 738e715 commit 120d0a3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
deadline: 2m
timeout: 10m

skip-files:
- "zz_generated\\..+\\.go$"
Expand Down Expand Up @@ -38,7 +38,7 @@ linters-settings:
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
local-prefixes: github.com/crossplane/provider-template
local-prefixes: github.com/stehessel/provider-redhat

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
Expand Down Expand Up @@ -108,10 +108,12 @@ linters:
- govet
- gocyclo
- gocritic
- interfacer
- goconst
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
- unconvert
- misspell
- nakedret
Expand All @@ -132,9 +134,9 @@ issues:
- errcheck
- dupl
- gosec
- exportloopref
- scopelint
- unparam

# Ease some gocritic warnings on test files.
- path: _test\.go
text: "(unnamedResult|exitAfterDefer)"
Expand Down
2 changes: 2 additions & 0 deletions apis/rhacs/v1alpha1/centralinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)

// CloudProvider is a typed enum for the cloud provider.
// +kubebuilder:validation:Enum=aws
type CloudProvider string

// Region is a typed enum for the region.
// +kubebuilder:validation:Enum=us-east-1
type Region string

Expand Down
1 change: 1 addition & 0 deletions pkg/clients/rhacs/rhacs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/stackrox/acs-fleet-manager/pkg/client/fleetmanager"
)

// Central request states in fleet manager.
const (
CentralRequestStatusAccepted string = "accepted"
CentralRequestStatusPreparing string = "preparing"
Expand Down
13 changes: 11 additions & 2 deletions pkg/controller/centralinstance/centralinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
}

centralResp, resp, err := c.client.GetCentralById(ctx, meta.GetExternalName(cr))
if resp != nil {
defer resp.Body.Close()
}
if err != nil {
if resp != nil && resp.StatusCode == http.StatusNotFound {
return managed.ExternalObservation{ResourceExists: false}, nil
Expand Down Expand Up @@ -222,7 +225,10 @@ func (c *external) Create(ctx context.Context, mg resource.Managed) (managed.Ext
Name: cr.Spec.ForProvider.Name,
Region: string(cr.Spec.ForProvider.Region),
}
centralResp, _, err := c.client.CreateCentral(ctx, true, request)
centralResp, resp, err := c.client.CreateCentral(ctx, true, request)
if resp != nil {
defer resp.Body.Close()
}
if err == nil {
meta.SetExternalName(cr, centralResp.Id)
}
Expand All @@ -249,6 +255,9 @@ func (c *external) Delete(ctx context.Context, mg resource.Managed) error {
return errors.New(errNotCentralInstance)
}

_, err := c.client.DeleteCentralById(ctx, cr.Status.AtProvider.ID, true)
resp, err := c.client.DeleteCentralById(ctx, cr.Status.AtProvider.ID, true)
if resp != nil {
defer resp.Body.Close()
}
return errors.Wrap(err, errDeleteFailed)
}

0 comments on commit 120d0a3

Please sign in to comment.