Skip to content

Commit 420de47

Browse files
committed
Initial version
1 parent 50aa9ad commit 420de47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+4634
-9
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
2+
# Ignore build and test binaries.
3+
bin/

.github/workflows/docker.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Docker
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
branches:
8+
- main
9+
pull_request:
10+
11+
env:
12+
GORELEASER_VER: "v2.3.2"
13+
14+
jobs:
15+
release:
16+
env:
17+
flags: ""
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: read
21+
packages: write
22+
# This is used to complete the identity challenge
23+
# with sigstore/fulcio when running outside of PRs.
24+
id-token: write
25+
26+
steps:
27+
- name: Parse semver string
28+
id: semver_parser
29+
uses: booxmedialtd/ws-action-parse-semver@v1
30+
with:
31+
input_string: ${{ (startsWith(github.ref, 'refs/tags/v') && github.ref) || 'refs/tags/v0.0.0' }}
32+
version_extractor_regex: '\/v(.*)$'
33+
34+
- if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
35+
run: echo "flags=--snapshot" >> $GITHUB_ENV
36+
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # It is required for GoReleaser to work properly
41+
42+
# Set up BuildKit Docker container builder to be able to build
43+
# multi-platform images and export cache
44+
# https://github.com/docker/setup-buildx-action
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
47+
48+
# Login against a Docker registry except on PR
49+
# https://github.com/docker/login-action
50+
- name: Login to Docker hub
51+
if: github.repository == github.event.pull_request.head.repo.full_name || !github.head_ref
52+
uses: docker/login-action@v1
53+
with:
54+
username: ${{ secrets.DOCKER_USER }}
55+
password: ${{ secrets.DOCKER_TOKEN }}
56+
57+
- name: Install OS build dependencies
58+
run: sudo apt update && sudo apt install -y -q gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
59+
60+
- name: Install goversioninfo
61+
run: go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@233067e
62+
63+
- name: Run GoReleaser
64+
uses: goreleaser/goreleaser-action@v4
65+
with:
66+
version: ${{ env.GORELEASER_VER }}
67+
args: release --clean ${{ env.flags }}
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/helm.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Helm Chart and Carvel package
2+
3+
on:
4+
push:
5+
paths:
6+
# update this file to trigger helm chart release
7+
- 'helm/netbird-operator/Chart.yaml'
8+
branches:
9+
- main
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/[email protected]
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Configure Git
21+
run: |
22+
git config user.name "$GITHUB_ACTOR"
23+
git config user.email "[email protected]"
24+
25+
- name: Install Helm
26+
uses: azure/[email protected]
27+
with:
28+
version: v3.4.2
29+
30+
- name: Run chart-releaser
31+
uses: helm/[email protected]
32+
with:
33+
charts_dir: helm
34+
env:
35+
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
36+
CR_RELEASE_NAME_TEMPLATE: "helm-v{{ .Version }}"

.github/workflows/lint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Run linter
21+
uses: golangci/golangci-lint-action@v6
22+
with:
23+
version: v1.63.4

.github/workflows/test-chart.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Test Chart
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test-e2e:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Install the latest version of kind
21+
run: |
22+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
23+
chmod +x ./kind
24+
sudo mv ./kind /usr/local/bin/kind
25+
26+
- name: Verify kind installation
27+
run: kind version
28+
29+
- name: Create kind cluster
30+
run: kind create cluster
31+
32+
- name: Prepare operator
33+
run: |
34+
go mod tidy
35+
make docker-build IMG=netbirdio/kubernetes-operator:debug
36+
kind load docker-image netbirdio/kubernetes-operator:debug
37+
38+
- name: Install Helm
39+
run: |
40+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
41+
42+
- name: Verify Helm installation
43+
run: helm version
44+
45+
- name: Lint Helm Chart
46+
run: |
47+
helm lint ./helm/netbird-operator
48+
49+
- name: Install cert-manager via Helm
50+
run: |
51+
helm repo add jetstack https://charts.jetstack.io
52+
helm repo update
53+
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true
54+
55+
- name: Wait for cert-manager to be ready
56+
run: |
57+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager
58+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-cainjector
59+
kubectl wait --namespace cert-manager --for=condition=available --timeout=300s deployment/cert-manager-webhook
60+
61+
- name: Install Helm chart for project
62+
run: |
63+
helm install test-chart --create-namespace --namespace netbird --set 'operator.image.tag=debug' ./helm/netbird-operator
64+
65+
- name: Check Helm release status
66+
run: |
67+
helm status test-chart --namespace netbird
68+

.github/workflows/test-e2e.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test-e2e:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Install the latest version of kind
21+
run: |
22+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
23+
chmod +x ./kind
24+
sudo mv ./kind /usr/local/bin/kind
25+
26+
- name: Verify kind installation
27+
run: kind version
28+
29+
- name: Create kind cluster
30+
run: kind create cluster
31+
32+
- name: Running Test e2e
33+
run: |
34+
go mod tidy
35+
make test-e2e

.github/workflows/test.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: Run on Ubuntu
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Clone the code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
20+
- name: Running Tests
21+
run: |
22+
go mod tidy
23+
make test

.gitignore

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
# If you prefer the allow list template instead of the deny list, see community template:
2-
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3-
#
41
# Binaries for programs and plugins
52
*.exe
63
*.exe~
74
*.dll
85
*.so
96
*.dylib
7+
bin/*
8+
Dockerfile.cross
109

1110
# Test binary, built with `go test -c`
1211
*.test
1312

1413
# Output of the go coverage tool, specifically when used with LiteIDE
1514
*.out
1615

17-
# Dependency directories (remove the comment below to include it)
18-
# vendor/
19-
2016
# Go workspace file
2117
go.work
22-
go.work.sum
2318

24-
# env file
25-
.env
19+
# Kubernetes Generated files - skip generated files, except for vendored files
20+
!vendor/**/zz_generated.*
21+
22+
# editor and IDE paraphernalia
23+
.idea
24+
.vscode
25+
*.swp
26+
*.swo
27+
*~

.golangci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
run:
2+
timeout: 5m
3+
allow-parallel-runners: true
4+
5+
issues:
6+
# don't skip warning about doc comments
7+
# don't exclude the default set of lint
8+
exclude-use-default: false
9+
# restore some of the defaults
10+
# (fill in the rest as needed)
11+
exclude-rules:
12+
- path: "api/*"
13+
linters:
14+
- lll
15+
- path: "internal/*"
16+
linters:
17+
- dupl
18+
- lll
19+
linters:
20+
disable-all: true
21+
enable:
22+
- dupl
23+
- errcheck
24+
- copyloopvar
25+
- ginkgolinter
26+
- goconst
27+
- gocyclo
28+
- gofmt
29+
- goimports
30+
- gosimple
31+
- govet
32+
- ineffassign
33+
- lll
34+
- misspell
35+
- nakedret
36+
- prealloc
37+
- revive
38+
- staticcheck
39+
- typecheck
40+
- unconvert
41+
- unparam
42+
- unused
43+
44+
linters-settings:
45+
revive:
46+
rules:
47+
- name: comment-spacings

0 commit comments

Comments
 (0)