Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
KEYCLOAK-14355-Linter-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slaskawi committed Jun 10, 2020
1 parent 59c07bd commit dcfd455
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 411 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.13
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: golangci-lint
uses: actions-contrib/golangci-lint@v1
with:
golangci_lint_version: v1.26
- name: Lint
run: make setup/linter code/lint
13 changes: 7 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
linters-settings:
golint:
# set the confidence level of a problem before it is reported. Setting it to 0 will show every issue from golint.
min-confidence: 0
gocyclo:
# a minimal complexity of function to report it
min-complexity: 60
min-complexity: 70
goconst:
# only report strings with the minimum given length
min-len: 2
# report from how many occurrence
min-occurrences: 2
funlen:
# We have very long type definitions for K8s resources
lines: 200
statements: 70

run:
modules-download-mode: vendor

service:
golangci-lint-version: 1.26.0

linters:
enable-all: true
disable:
Expand All @@ -29,3 +28,5 @@ linters:
- wsl
- godox
- gomnd
- testpackage
- godot
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ setup/operator-sdk:
@echo Installing Operator SDK
@curl -Lo operator-sdk ${OPERATOR_SDK_DOWNLOAD_URL} && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/

.PHONY: setup/linter
setup/linter:
@echo Installing Linter
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.26.0

.PHONY: code/run
code/run:
@operator-sdk run --local --namespace=${NAMESPACE}
Expand Down Expand Up @@ -139,10 +144,7 @@ code/fix:
.PHONY: code/lint
code/lint:
@echo "--> Running golangci-lint"
@which golangci-lint 2>/dev/null ; if [ $$? -eq 1 ]; then \
go get github.com/golangci/golangci-lint/cmd/[email protected]; \
fi
golangci-lint run
@$(shell go env GOPATH)/bin/golangci-lint run --timeout 10m

##############################
# CI #
Expand Down
7 changes: 3 additions & 4 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"runtime"

"github.com/keycloak/keycloak-operator/version"
"github.com/pkg/errors"

"github.com/keycloak/keycloak-operator/pkg/common"
routev1 "github.com/openshift/api/route/v1"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/log/zap"
"github.com/operator-framework/operator-sdk/pkg/metrics"
"github.com/operator-framework/operator-sdk/pkg/restmapper"
sdkVersion "github.com/operator-framework/operator-sdk/version"
"github.com/spf13/pflag"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -102,7 +102,6 @@ func main() {
// Create a new Cmd to provide shared dependencies and start components
mgr, err := manager.New(cfg, manager.Options{
Namespace: namespace,
MapperProvider: restmapper.NewDynamicRESTMapper,
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
})
if err != nil {
Expand Down Expand Up @@ -178,7 +177,7 @@ func main() {
log.Info("Could not create ServiceMonitor object", "error", err.Error())
// If this operator is deployed to a cluster without the prometheus-operator running, it will return
// ErrServiceMonitorNotPresent, which can be used to safely skip ServiceMonitor creation.
if err == metrics.ErrServiceMonitorNotPresent {
if errors.Is(err, metrics.ErrServiceMonitorNotPresent) {
log.Info("Install prometheus-operator in your cluster to create ServiceMonitor objects", "error", err.Error())
}
}
Expand All @@ -194,7 +193,7 @@ func main() {

func addMonitoringKeyLabelToOperatorService(ctx context.Context, cfg *rest.Config, service *v1.Service) error {
if service == nil {
return fmt.Errorf("service doesn't exist")
return errors.Errorf("service doesn't exist")
}

kclient, err := client.New(cfg, client.Options{})
Expand Down
26 changes: 1 addition & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,41 @@ module github.com/keycloak/keycloak-operator

require (
cloud.google.com/go v0.57.0 // indirect
github.com/Djarvur/go-err113 v0.1.0 // indirect
github.com/bombsimon/wsl/v3 v3.1.0 // indirect
github.com/coreos/prometheus-operator v0.34.0
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-critic/go-critic v0.4.3 // indirect
github.com/go-openapi/spec v0.19.6
github.com/go-toolsmith/typep v1.0.2 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/golangci/gocyclo v0.0.0-20180528144436-0a533e8fa43d // indirect
github.com/golangci/golangci-lint v1.27.0 // indirect
github.com/golangci/misspell v0.3.5 // indirect
github.com/golangci/revgrep v0.0.0-20180812185044-276a5c0a1039 // indirect
github.com/google/go-cmp v0.4.1 // indirect
github.com/gostaticanalysis/analysisutil v0.0.3 // indirect
github.com/integr8ly/grafana-operator/v3 v3.0.2-0.20200103111057-03d7fa884db4
github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect
github.com/json-iterator/go v1.1.9
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mitchellh/mapstructure v1.3.1 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/openshift/api v3.9.1-0.20190924102528-32369d4db2ad+incompatible
github.com/operator-framework/operator-sdk v0.15.1
github.com/pelletier/go-toml v1.8.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.5.2 // indirect
github.com/ryancurrah/gomodguard v1.1.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/sourcegraph/go-diff v0.5.3 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.0 // indirect
github.com/stretchr/testify v1.6.0
github.com/tdakkota/asciicheck v0.0.0-20200416200610-e657995f937b // indirect
github.com/tetafro/godot v0.4.2 // indirect
github.com/timakin/bodyclose v0.0.0-20200424151742-cb6215831a94 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20200528225125-3c3fba18258b // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
golang.org/x/tools v0.0.0-20200601175630-2caf76543d99 // indirect
golang.org/x/tools v0.0.0-20200606014950-c42cb6316fb6 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/ini.v1 v1.57.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200601152816-913338de1bd2 // indirect
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
k8s.io/api v0.0.0
k8s.io/apimachinery v0.0.0
k8s.io/client-go v12.0.0+incompatible
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d
mvdan.cc/unparam v0.0.0-20200501210554-b37ab49443f7 // indirect
sigs.k8s.io/controller-runtime v0.4.0
sourcegraph.com/sqs/pbtypes v1.0.0 // indirect

)

Expand Down
Loading

0 comments on commit dcfd455

Please sign in to comment.