Skip to content

Commit

Permalink
Add revive to golanci
Browse files Browse the repository at this point in the history
This PR replace deprecated go-linter using
revive (https://golangci-lint.run/usage/linters/#revive).

We will add "ginkgolinter" in follow up patch once we merged add pre-commit job in openshift/releases.

If we add "ginkgolinter" in this patch then it's causes below issue [1]

```
level=info msg="[config_reader] Config search paths: [./ /home/prow/go/src/github.com/openstack-k8s-operators/dataplane-operator /home/prow/go/src/github.com/openstack-k8s-operators /home/prow/go/src/github.com /home/prow/go/src /home/prow/go /home/prow /home /]"
level=info msg="[config_reader] Used config file .golangci.yaml"
level=error msg="Running error: unknown linters: 'ginkgolinter', run 'golangci-lint help linters' to see the list of supported linters"
  • Loading branch information
bshewale committed Apr 12, 2023
1 parent 3cd896a commit d90eb08
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 42 deletions.
17 changes: 17 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errorlint
- revive
- gofmt
- govet
linters-settings:
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter
- name: unused-parameter
severity: warning
disabled: true
run:
timeout: 5m
31 changes: 6 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
repos:
- repo: local
hooks:
- id: golangci-lint
name: golangci-lint
language: golang
types: [go]
entry: make
args: ["golangci-lint"]
pass_filenames: false
- id: golint
name: golint
language: system
entry: make
args: ["golint"]
pass_filenames: false
- id: gofmt
name: gofmt
language: system
entry: make
args: ["fmt"]
pass_filenames: false
- id: govet
name: govet
language: system
entry: make
args: ["vet"]
pass_filenames: false
- id: gotidy
name: gotidy
language: system
Expand Down Expand Up @@ -80,3 +55,9 @@ repos:
hooks:
- id: bashate
entry: bashate --error . --ignore=E006,E040,E011,E020,E012

- repo: https://github.com/golangci/golangci-lint
rev: v1.52.2
hooks:
- id: golangci-lint
args: ["-v"]
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,9 @@ vet: ## Run go vet against code.
go vet ./...

.PHONY: tidy
tidy:
go mod tidy; \
pushd "$(LOCALBIN)/../api"; \
go mod tidy; \
popd
tidy: ## Run go mod tidy on every mod file in the repo
go mod tidy
cd ./api && go mod tidy

.PHONY: golangci-lint
golangci-lint:
Expand Down
2 changes: 1 addition & 1 deletion controllers/galera_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (r *GaleraReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res
condition.SeverityWarning,
condition.ServiceConfigReadyErrorMessage,
err.Error()))
return ctrl.Result{}, fmt.Errorf("error calculating configmap hash: %v", err)
return ctrl.Result{}, fmt.Errorf("error calculating configmap hash: %w", err)
}
// From hereon, configMapVars holds a hash of the config generated for this instance
// This is used in an envvar in the statefulset to restart it on config change
Expand Down
2 changes: 1 addition & 1 deletion controllers/mariadb_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (r *MariaDBReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
condition.SeverityWarning,
condition.ServiceConfigReadyErrorMessage,
err.Error()))
return ctrl.Result{}, fmt.Errorf("error calculating configmap hash: %v", err)
return ctrl.Result{}, fmt.Errorf("error calculating configmap hash: %w", err)
}
mergedMapVars := env.MergeEnvs([]corev1.EnvVar{}, configMapVars)
configHash := ""
Expand Down
16 changes: 8 additions & 8 deletions hack/configure_local_webhook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ sudo firewall-cmd --runtime-to-permanent

# Generate the certs and the ca bundle
if [ "$SKIP_CERT" = false ] ; then
mkdir -p ${TMPDIR}
rm -rf ${TMPDIR}/* || true
mkdir -p ${TMPDIR}
rm -rf ${TMPDIR}/* || true

openssl req -newkey rsa:2048 -days 3650 -nodes -x509 \
-subj "/CN=${HOSTNAME}" \
-addext "subjectAltName = IP:${CRC_IP}" \
-keyout ${TMPDIR}/tls.key \
-out ${TMPDIR}/tls.crt
openssl req -newkey rsa:2048 -days 3650 -nodes -x509 \
-subj "/CN=${HOSTNAME}" \
-addext "subjectAltName = IP:${CRC_IP}" \
-keyout ${TMPDIR}/tls.key \
-out ${TMPDIR}/tls.crt

cat ${TMPDIR}/tls.crt ${TMPDIR}/tls.key | base64 -w 0 > ${TMPDIR}/bundle.pem
cat ${TMPDIR}/tls.crt ${TMPDIR}/tls.key | base64 -w 0 > ${TMPDIR}/bundle.pem

fi

Expand Down
4 changes: 2 additions & 2 deletions templates/galera/bin/mysql_bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ PODIP=$(grep "${PODNAME}" /etc/hosts | cut -d$'\t' -f1)
pushd /var/lib/config-data
for cfg in *.cnf.in; do
if [ -s "${cfg}" ]; then
echo "Generating config file from template ${cfg}"
sed -e "s/{ PODNAME }/${PODNAME}/" -e "s/{ PODIP }/${PODIP}/" "/var/lib/config-data/${cfg}" > "/var/lib/pod-config-data/${cfg%.in}"
echo "Generating config file from template ${cfg}"
sed -e "s/{ PODNAME }/${PODNAME}/" -e "s/{ PODIP }/${PODIP}/" "/var/lib/config-data/${cfg}" > "/var/lib/pod-config-data/${cfg%.in}"
fi
done
popd
Expand Down

0 comments on commit d90eb08

Please sign in to comment.