Skip to content

Commit

Permalink
fix: fixed linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Armin Schlegel <[email protected]>
  • Loading branch information
siredmar committed Mar 1, 2023
1 parent 323c535 commit 1a89581
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

env:
# Common versions
GO_VERSION: "1.19"
GOLANGCI_VERSION: "v1.50"
GO_VERSION: "1.20"
GOLANGCI_VERSION: "v1.51.0"
DOCKER_BUILDX_VERSION: "v0.9.1"

# Common users. We can't run a step 'if secrets.AWS_USR != ""' but we can run
Expand Down
26 changes: 14 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ run:
deadline: 2m

skip-files:
- "zz_generated\\..+\\.go$"
- "zz_generated\\..+\\.go$"

output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
Expand Down Expand Up @@ -42,7 +42,7 @@ linters-settings:

gocyclo:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 10
min-complexity: 20

maligned:
# print struct with more effective memory layout or not, false by default
Expand Down Expand Up @@ -110,18 +110,20 @@ linters:
- gocritic
- goconst
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- unconvert
- misspell
- nakedret

disable:
- contextcheck

presets:
- bugs
- unused
fast: false


issues:
# Excluding configuration per-path and per-linter
exclude-rules:
Expand All @@ -134,7 +136,7 @@ issues:
- gosec
- exportloopref
- unparam

# Ease some gocritic warnings on test files.
- path: _test\.go
text: "(unnamedResult|exitAfterDefer)"
Expand All @@ -146,31 +148,31 @@ issues:
# rather than using a pointer.
- text: "(hugeParam|rangeValCopy):"
linters:
- gocritic
- gocritic

# This "TestMain should call os.Exit to set exit code" warning is not clever
# enough to notice that we call a helper method that calls os.Exit.
- text: "SA3000:"
linters:
- staticcheck
- staticcheck

- text: "k8s.io/api/core/v1"
linters:
- goimports
- goimports

# This is a "potential hardcoded credentials" warning. It's triggered by
# any variable with 'secret' in the same, and thus hits a lot of false
# positives in Kubernetes land where a Secret is an object type.
- text: "G101:"
linters:
- gosec
- gas
- gosec
- gas

# This is an 'errors unhandled' warning that duplicates errcheck.
- text: "G104:"
linters:
- gosec
- gas
- gosec
- gas

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand Down
19 changes: 0 additions & 19 deletions apis/accountSigningKey/v1alpha1/config/errors/errors.go

This file was deleted.

19 changes: 0 additions & 19 deletions apis/operatorSigningKey/v1alpha1/config/errors/errors.go

This file was deleted.

2 changes: 1 addition & 1 deletion cluster/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.20 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
19 changes: 15 additions & 4 deletions cluster/local/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}"
version_tag="$(cat ${projectdir}/_output/version)"
# tag as latest version to load into kind cluster
PACKAGE_CONTROLLER_IMAGE="${DOCKER_REGISTRY}/${PROJECT_NAME}-controller:${VERSION}"
K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}"
K8S_CLUSTER="${K8S_CLUSTER:-${PROJECT_NAME}-inttests}"

CROSSPLANE_NAMESPACE="crossplane-system"

Expand Down Expand Up @@ -138,7 +138,7 @@ echo "${PVC_YAML}" | "${KUBECTL}" create -f -

# install crossplane from stable channel
echo_step "installing crossplane from stable channel"
"${HELM3}" repo add crossplane-stable https://charts.crossplane.io/stable/
"${HELM3}" repo add crossplane-stable https://charts.crossplane.io/stable/ | true
chart_version="$("${HELM3}" search repo crossplane-stable/crossplane | awk 'FNR == 2 {print $2}')"
echo_info "using crossplane version ${chart_version}"
echo
Expand All @@ -159,7 +159,18 @@ metadata:
name: "${PACKAGE_NAME}"
spec:
package: "${PACKAGE_NAME}"
controllerConfigRef:
name: "${PACKAGE_NAME}"
packagePullPolicy: Never
---
apiVersion: pkg.crossplane.io/v1alpha1
kind: ControllerConfig
metadata:
name: "${PACKAGE_NAME}"
spec:
args:
- --poll
- 3s
EOF
)"

Expand All @@ -171,7 +182,7 @@ docker exec "${K8S_CLUSTER}-control-plane" ls -la /cache

echo_step "waiting for provider to be installed"

kubectl wait "provider.pkg.crossplane.io/${PACKAGE_NAME}" --for=condition=healthy --timeout=180s
kubectl wait "provider.pkg.crossplane.io/${PACKAGE_NAME}" --for=condition=healthy --timeout=360s

echo_step "uninstalling ${PROJECT_NAME}"

Expand All @@ -190,4 +201,4 @@ while [[ $(kubectl get providerrevision.pkg.crossplane.io -o name | wc -l) != "0
sleep $step;
done

echo_success "Integration tests succeeded!"
echo_success "Integration tests succeeded!"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/edgefarm/provider-natssecrets

go 1.19
go 1.20

require (
github.com/crossplane/crossplane-runtime v0.19.1
Expand Down
5 changes: 4 additions & 1 deletion internal/clients/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ func NewRootClient(creds []byte) (*Client, error) {
}
clientConfig := &api.Config{Address: config.Address}
if config.TLS {
clientConfig.ConfigureTLS(&api.TLSConfig{Insecure: config.Insecure})
err := clientConfig.ConfigureTLS(&api.TLSConfig{Insecure: config.Insecure})
if err != nil {
return nil, err
}
}

api, err := api.NewClient(clientConfig)
Expand Down
1 change: 0 additions & 1 deletion internal/controller/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ const (
errTrackPCUsage = "cannot track ProviderConfig usage"
errGetPC = "cannot get ProviderConfig"
errGetCreds = "cannot get credentials"
errNotSupported = "not supported to change operator id"

errNewClient = "cannot create new Service"
)
Expand Down
1 change: 1 addition & 0 deletions internal/controller/user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func (c *external) Observe(ctx context.Context, mg resource.Managed) (managed.Ex
user := cr.Name
data, status, err := issue.ReadUser(c.client, operator, account, user)
if err != nil {
cr.SetConditions(xpv1.Unavailable().WithMessage(err.Error()))
return managed.ExternalObservation{
ResourceExists: false,
}, nil
Expand Down

0 comments on commit 1a89581

Please sign in to comment.