Skip to content

Commit 1f3eb68

Browse files
authored
Merge pull request #29 from flexkube/updates
Updates
2 parents a5bb6b5 + f6481bf commit 1f3eb68

37 files changed

+981
-630
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10-
container: golangci/golangci-lint:v1.40.1
10+
container: golangci/golangci-lint:v1.46.0
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:
1414
# Required for Codecov report uploading.
1515
fetch-depth: 0
16-
- run: make install-cc-test-reporter BIN_PATH=/usr/local/bin
17-
- run: make build build-test test-update-linters lint
16+
- run: make install-cc-test-reporter install-changelog BIN_PATH=/usr/local/bin
17+
- run: make build build-test test-update-linters lint test-tidy test-changelog
1818
- run: make test-cover-upload
1919
e2e:
2020
runs-on: ubuntu-latest
2121
steps:
2222
- uses: actions/setup-go@v2
2323
with:
24-
go-version: '1.17'
24+
go-version: '1.18'
2525
- uses: actions/cache@v2
2626
with:
2727
path: |
@@ -32,6 +32,8 @@ jobs:
3232
${{ runner.os }}-go-
3333
- uses: actions/checkout@v2
3434
- uses: hashicorp/setup-terraform@v1
35+
- name: Setup containerd
36+
uses: crazy-max/ghaction-setup-containerd@v1.3.0
3537
- name: Fetch dependencies and configure tests
3638
run: |
3739
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
@@ -47,9 +49,12 @@ jobs:
4749
nodes_cidr = "172.17.0.0/24"
4850
node_ssh_port = 2222
4951
workers_count = 0
50-
container_runtime = "docker"
5152
cidr_ips_offset = 1
52-
kubelet_extra_args = ["--fail-swap-on=false"]
53+
kubelet_extra_args = [
54+
"--fail-swap-on=false",
55+
"--container-runtime-endpoint=unix:///run/containerd/containerd.sock",
56+
]
57+
cgroup_driver = "cgroupfs"
5358
EOF
5459
- run: make build test-e2e-run TERRAFORM_BIN=terraform
5560
codespell:
@@ -59,6 +64,45 @@ jobs:
5964
- uses: codespell-project/actions-codespell@master
6065
with:
6166
skip: .git,go.sum
62-
ignore_words_list: uptodate
67+
ignore_words_list: uptodate,decorder
6368
check_filenames: true
6469
check_hidden: true
70+
vagrant:
71+
runs-on: ubuntu-latest
72+
steps:
73+
- uses: actions/checkout@v2
74+
- name: Install vagrant
75+
run: |
76+
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
77+
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
78+
sudo apt-get update && sudo apt-get install vagrant
79+
- run: make test-vagrant
80+
semgrep:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v2
84+
# Use dedicated action for nice integration with GitHub.
85+
- uses: returntocorp/semgrep-action@v1
86+
terraform:
87+
runs-on: ubuntu-latest
88+
steps:
89+
- uses: actions/checkout@v2
90+
- name: Get dependencies
91+
run: |
92+
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
93+
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
94+
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
95+
sudo apt-get update && sudo apt-get install terraform
96+
- run: |
97+
terraform -chdir=libvirt init
98+
make test-terraform
99+
build-integration-image:
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v2
103+
- run: make build-integration
104+
build-e2e-image:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v2
108+
- run: make build-e2e

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ kubeconfig
88
config.yaml
99
state.yaml
1010
terraform.tfstate*
11+
.terraform.lock.hcl
12+
.terraform.tfstate.lock.info
1113
variables.auto.tfvars
1214
/c.out
1315
crash.log

.golangci.yml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,36 @@ issues:
1313
max-issues-per-linter: 0
1414
exclude-rules:
1515
- linters:
16-
- forbidigo
16+
- forbidigo
1717
text: "use of `fmt.Printf` forbidden by pattern"
1818

19+
linters-settings:
20+
errcheck:
21+
check-type-assertions: true
22+
check-blank: true
23+
gci:
24+
sections:
25+
- standard
26+
- default
27+
- prefix(github.com/flexkube/terraform-provider-flexkube)
28+
godot:
29+
capital: true
30+
gofumpt:
31+
extra-rules: true
32+
govet:
33+
enable-all: true
34+
disable:
35+
- fieldalignment
36+
- shadow
37+
makezero:
38+
always: true
39+
nolintlint:
40+
allow-leading-space: false
41+
require-explanation: true
42+
require-specific: true
43+
wsl:
44+
force-err-cuddling: true
45+
1946
linters:
2047
disable:
2148
# Disabled until we implement some error types and migrate to use them.
@@ -24,26 +51,37 @@ linters:
2451
- gci
2552
# To be able to make use of Go zero-value feature.
2653
- exhaustivestruct
54+
- exhaustruct
2755
# Allow replacements to force specific versions of dependencies.
2856
- gomoddirectives
2957
# Temporarily disable assertion checks, as it adds a lot of boilerplate to the code.
3058
- forcetypeassert
59+
# To allow defensive approach when initializing structs.
60+
- ireturn
61+
# This linters should eventually be addressed and re-enabled.
62+
- varnamelen
63+
- errcheck
3164
# Those linters has been deprecated.
3265
- interfacer
3366
- maligned
34-
- scopelint
3567
- golint
3668
enable:
3769
- asciicheck
70+
- bidichk
3871
- bodyclose
72+
- containedctx
73+
- contextcheck
3974
- cyclop
4075
- deadcode
76+
- decorder
4177
- depguard
4278
- dogsled
4379
- dupl
4480
- durationcheck
45-
- errcheck
81+
- errchkjson
82+
- errname
4683
- errorlint
84+
- execinquery
4785
- exhaustive
4886
- exportloopref
4987
- forbidigo
@@ -63,28 +101,33 @@ linters:
63101
- gomnd
64102
- gomodguard
65103
- goprintffuncname
104+
- grouper
66105
- ifshort
67106
- importas
68107
- ineffassign
69108
- lll
109+
- maintidx
70110
- makezero
71111
- misspell
72112
- nakedret
73113
- nestif
74114
- nilerr
115+
- nilnil
75116
- nlreturn
76117
- noctx
77118
- nolintlint
119+
- nonamedreturns
120+
- nosprintfhostport
78121
- paralleltest
79122
- prealloc
80123
- predeclared
81124
- promlinter
82125
- revive
83-
- rowserrcheck
84126
- sqlclosecheck
85127
- structcheck
86128
- stylecheck
87129
- tagliatelle
130+
- tenv
88131
- testpackage
89132
- thelper
90133
- tparallel

.semgrep.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
rules:
2+
- id: bad-error-wrap-wording
3+
patterns:
4+
- pattern-regex: fmt\.Errorf\(".?([Ff]ailed|[]Uu]nable|[Cc]ould|([Ee]rror))
5+
message: Word "fail", "failed", "unable", "could not" should not be used when wrapping errors. Use verb in continuous form instead!
6+
languages: [go]
7+
severity: ERROR
8+
- id: printed-messages-must-be-captialized
9+
patterns:
10+
- pattern-regex: (fmt.Print(ln|f)|\bt\.(Error|Fatal|Log)(|f))\("[a-z]
11+
message: Printed messages must be capitalized.
12+
languages: [go]
13+
severity: ERROR
14+
- id: strings-must-be-quoted-using-q
15+
patterns:
16+
- pattern-regex: "'%s'"
17+
message: When formatting, strings must be quoted using %q instead of e.g. '%s'.
18+
languages: [go]
19+
severity: ERROR
20+
- id: error-wrapping-must-be-preceded-by-space
21+
patterns:
22+
- pattern-regex: '[^ ]%w'
23+
message: When wrapping errors, %w must be preceded by space.
24+
languages: [go]
25+
severity: ERROR
26+
- id: files-must-not-have-trailing-whitespace
27+
patterns:
28+
- pattern-regex: '[[:blank:]]$'
29+
message: Files must not have any trailing whitespace.
30+
languages: [generic]
31+
severity: ERROR
32+
- id: files-must-not-have-trailing-newlines
33+
patterns:
34+
- pattern-regex: '\n\n\Z'
35+
message: Files must not have any trailing newlines.
36+
languages: [generic]
37+
severity: ERROR
38+
- id: all-lines-must-end-with-newline
39+
patterns:
40+
- pattern-regex: '\S\z'
41+
message: All lines must end with newline.
42+
languages: [generic]
43+
severity: ERROR

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.0] - 2022-05-09
9+
### Changed
10+
- Updated `libflexkube` version to `v0.8.0`.
11+
- Updated remaining dependencies to latest versions.
12+
13+
### Removed
14+
- `r/flexkube_kubelet_pool` parameters `network_plugin` and `pod_cidr` has been removed as they are no longer effective.
15+
816
## [0.6.0] - 2021-09-02
917
### Changed
10-
- Updated `libflexkube` version to `v.7.0`.
18+
- Updated `libflexkube` version to `v0.7.0`.
1119
- Updated remaining dependencies to latest versions.
1220

1321
## [0.5.1] - 2021-05-31
@@ -52,6 +60,7 @@ in `libflexkube` and `flexkube_pki` and `flexkube_etcd_cluster` resources compla
5260
### Changed
5361
- flexkube_containers: rename 'container' to 'host_configured_container'.
5462

63+
[0.7.0]: https://github.com/flexkube/terraform-provider-flexkube/compare/v0.6.0...v0.7.0
5564
[0.6.0]: https://github.com/flexkube/terraform-provider-flexkube/compare/v0.5.1...v0.6.0
5665
[0.5.1]: https://github.com/flexkube/terraform-provider-flexkube/compare/v0.5.0...v0.5.1
5766
[0.5.0]: https://github.com/flexkube/terraform-provider-flexkube/compare/v0.4.1...v0.5.0

Makefile

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GOBUILD=CGO_ENABLED=$(CGO_ENABLED) $(GOCMD) build -v -buildmode=exe -ldflags $(L
1313
GO_PACKAGES=./...
1414
GO_TESTS=^.*$
1515

16-
GOLANGCI_LINT_VERSION=v1.40.1
16+
GOLANGCI_LINT_VERSION=v1.46.0
1717

1818
BIN_PATH=$$HOME/bin
1919

@@ -41,7 +41,7 @@ COVERPROFILE=c.out
4141
CC_TEST_REPORTER_ID=5bc3e58aca2ff47897d533ba92ae8db15ac9fdb83fad3637301ee5d75ccd4143
4242

4343
.PHONY: all
44-
all: build build-test test lint
44+
all: build build-test test lint semgrep
4545

4646
.PHONY: download
4747
download:
@@ -56,6 +56,10 @@ install-cc-test-reporter:
5656
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $(BIN_PATH)/cc-test-reporter
5757
chmod +x $(BIN_PATH)/cc-test-reporter
5858

59+
.PHONY: install-changelog
60+
install-changelog:
61+
go install github.com/rcmachado/changelog@0.7.0
62+
5963
.PHONY: install-ci
6064
install-ci: install-golangci-lint install-cc-test-reporter
6165

@@ -152,6 +156,10 @@ test-local-apply:
152156
build-e2e:
153157
docker build -t $(E2E_IMAGE) e2e
154158

159+
.PHONY: build-integration
160+
build-integration:
161+
docker build -t $(INTEGRATION_IMAGE) integration
162+
155163
.PHONY: vagrant-up
156164
vagrant-up:
157165
$(VAGRANTCMD) up
@@ -222,3 +230,35 @@ test-e2e-run:
222230
test-e2e-destroy: TERRAFORM_BIN=$(TERRAFORM_ENV) /bin/terraform
223231
test-e2e-destroy:
224232
$(TERRAFORM_BIN) -chdir=e2e destroy -auto-approve
233+
234+
.PHONY: semgrep
235+
semgrep: SEMGREP_BIN=semgrep
236+
semgrep:
237+
@if ! which $(SEMGREP_BIN) >/dev/null 2>&1; then echo "$(SEMGREP_BIN) binary not found, skipping extra linting"; else $(SEMGREP_BIN) --error; fi
238+
239+
.PHONY: test-vagrant
240+
test-vagrant:
241+
vagrant validate --ignore-provider
242+
243+
.PHONY: test-changelog
244+
test-changelog: test-working-tree-clean
245+
make format-changelog
246+
@test -z "$$(git status --porcelain)" || (echo "Please run 'make format-changelog' and commit generated changes."; git diff; exit 1)
247+
248+
.PHONY: test-working-tree-clean
249+
test-working-tree-clean:
250+
@test -z "$$(git status --porcelain)" || (echo "Commit all changes before running this target"; exit 1)
251+
252+
.PHONY: test-tidy
253+
test-tidy: test-working-tree-clean
254+
go mod tidy
255+
@test -z "$$(git status --porcelain)" || (echo "Please run 'go mod tidy' and commit generated changes."; git diff; exit 1)
256+
257+
.PHONY: format-changelog
258+
format-changelog:
259+
changelog fmt -o CHANGELOG.md.fmt
260+
mv CHANGELOG.md.fmt CHANGELOG.md
261+
262+
.PHONY: test-terraform
263+
test-terraform:
264+
terraform -chdir=libvirt validate

0 commit comments

Comments
 (0)