Add linting (#11)

Signed-off-by: Andrew Harding <aharding@vmware.com>
This commit is contained in:
Andrew Harding 2021-11-22 16:49:00 -07:00 committed by GitHub
parent 74acceb6a9
commit e79ed15cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 106 additions and 10 deletions

View File

@ -3,12 +3,23 @@ on:
pull_request: {}
workflow_dispatch: {}
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Lint
run: make lint
build-and-test-images:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build image
run: make docker-build
- name: Run integration tests
run: test/run.sh
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build image
run: make docker-build
- name: Run integration tests
run: test/run.sh

View File

@ -4,6 +4,17 @@ on:
tags:
- 'v[0-9].[0-9]+.[0-9]+'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Lint
run: make lint
build-and-publish-images:
runs-on: ubuntu-latest
steps:

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.build
/bin
spiffe-csi-driver

25
.golangci.yml Normal file
View File

@ -0,0 +1,25 @@
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 10m
linters:
enable:
- bodyclose
- depguard
- durationcheck
- errorlint
- goimports
- revive
- gosec
- misspell
- nolintlint
- nakedret
- unconvert
- unparam
- whitespace
- gocritic
linters-settings:
revive:
# minimal confidence for issues, default is 0.8
confidence: 0.0

View File

@ -1,3 +1,39 @@
DIR := ${CURDIR}
############################################################################
# OS/ARCH detection
############################################################################
os1=$(shell uname -s)
os2=
ifeq ($(os1),Darwin)
os1=darwin
os2=osx
else ifeq ($(os1),Linux)
os1=linux
os2=linux
else
$(error unsupported OS: $(os1))
endif
arch1=$(shell uname -m)
ifeq ($(arch1),x86_64)
arch2=amd64
else ifeq ($(arch1),aarch64)
arch2=arm64
else
$(error unsupported ARCH: $(arch1))
endif
############################################################################
# Vars
############################################################################
build_dir := $(DIR)/.build/$(os1)-$(arch1)
golangci_lint_version = v1.43.0
golangci_lint_dir = $(build_dir)/golangci_lint/$(golangci_lint_version)
golangci_lint_bin = $(golangci_lint_dir)/golangci-lint
golangci_lint_cache = $(golangci_lint_dir)/cache
# There may be more than one tag. Only use one that starts with 'v' followed by
# a number, e.g., v0.9.3.
@ -38,3 +74,13 @@ build: | bin
bin:
mkdir bin
lint: $(golangci_lint_bin)
@GOLANGCI_LINT_CACHE="$(golangci_lint_cache)" $(golangci_lint_bin) run ./...
$(golangci_lint_bin):
@echo "Installing golangci-lint $(golangci_lint_version)..."
@rm -rf $(dir $(golangci_lint_dir))
@mkdir -p $(golangci_lint_dir)
@mkdir -p $(golangci_lint_cache)
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(golangci_lint_dir) $(golangci_lint_version)

View File

@ -16,7 +16,7 @@ import (
var (
nodeIDFlag = flag.String("node-id", "", "Kubernetes Node ID. If unset, the node ID is obtained from the environment (i.e., -node-id-env)")
nodeIDEnvFlag = flag.String("node-id-env", "MY_NODE_NAME", "Envvar from which to obtain the node ID. Overriden by -node-id.")
nodeIDEnvFlag = flag.String("node-id-env", "MY_NODE_NAME", "Envvar from which to obtain the node ID. Overridden by -node-id.")
csiSocketPathFlag = flag.String("csi-socket-path", "/spiffe-csi/csi.sock", "Path to the CSI socket")
workloadAPISocketDir = flag.String("workload-api-socket-dir", "", "Path to the Workload API socket directory")
)

View File

@ -3,7 +3,9 @@
package mount
import "errors"
import (
"errors"
)
func bindMountRO(src, dst string) error {
return errors.New("unsupported on this platform")