Skip to content

Commit 1dc3c6f

Browse files
author
Marcelo
committed
First commit
0 parents  commit 1dc3c6f

File tree

85 files changed

+22356
-0
lines changed

Some content is hidden

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

85 files changed

+22356
-0
lines changed

.github/dependabot.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: gomod
5+
directory: /
6+
schedule:
7+
interval: daily
8+
- package-ecosystem: docker
9+
directory: /
10+
schedule:
11+
interval: daily
12+
- package-ecosystem: github-actions
13+
directory: /
14+
schedule:
15+
interval: daily

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
name: Lint
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: go.mod
21+
22+
- uses: golangci/golangci-lint-action@v7
23+
with:
24+
version: v2.0.2
25+
args: -v
26+
27+
build:
28+
needs: lint
29+
strategy:
30+
matrix:
31+
os: [ ubuntu-latest ]
32+
goos: [ linux ]
33+
goarch: [amd64, arm64, ppc64le]
34+
runs-on: ${{ matrix.os }}
35+
env:
36+
GO111MODULE: on
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version-file: go.mod
44+
45+
- name: Build test for ${{ matrix.goarch }}
46+
env:
47+
GOARCH: ${{ matrix.goarch }}
48+
GOOS: ${{ matrix.goos }}
49+
run: GOARCH="${TARGET}" go build ./cmd/main.go
50+
51+
test-unit:
52+
name: Run tests on Linux amd64
53+
needs: build
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- name: Set up Go
58+
uses: actions/setup-go@v5
59+
with:
60+
go-version-file: go.mod
61+
62+
- name: Run tests
63+
run: make test
64+
65+
test-e2e:
66+
name: Run e2e tests
67+
needs: build
68+
runs-on: ubuntu-latest
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Set up Go
72+
uses: actions/setup-go@v5
73+
with:
74+
go-version-file: go.mod
75+
76+
- name: Install bats
77+
run: sudo apt install bats
78+
- name: Setup registry
79+
run: docker run -d --restart=always -p "5000:5000" --name "kind-registry" registry:2
80+
81+
- name: Get tools
82+
working-directory: ./e2e
83+
run: ./get_tools.sh
84+
85+
- name: Setup cluster
86+
working-directory: ./e2e
87+
run: ./setup_cluster.sh
88+
89+
- name: "Test: simple"
90+
working-directory: ./e2e
91+
run: |
92+
export TERM=dumb
93+
# enable ip6_tables
94+
sudo modprobe ip6_tables
95+
96+
./run_all_tests.sh
97+
98+
- name: Upload logs
99+
uses: actions/upload-artifact@v4
100+
if: ${{ failure() }}
101+
with:
102+
name: kind-logs-e2e
103+
path: ./e2e/artifacts/

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
bin/*
8+
Dockerfile.cross
9+
10+
# Test binary, built with `go test -c`
11+
*.test
12+
13+
# Output of the go coverage tool, specifically when used with LiteIDE
14+
*.out
15+
coverage.html
16+
17+
# Go workspace file
18+
go.work
19+
20+
# Kubernetes Generated files - skip generated files, except for vendored files
21+
!vendor/**/zz_generated.*
22+
23+
# editor and IDE paraphernalia
24+
.idea
25+
.vscode
26+
*.swp
27+
*.swo
28+
*~

.golangci.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
version: "2"
3+
run:
4+
modules-download-mode: vendor
5+
linters:
6+
enable:
7+
- contextcheck
8+
- durationcheck
9+
- forbidigo
10+
- ginkgolinter
11+
- gocritic
12+
- misspell
13+
- nonamedreturns
14+
- predeclared
15+
- revive
16+
- unconvert
17+
- unparam
18+
- wastedassign
19+
disable:
20+
- errcheck
21+
settings:
22+
staticcheck:
23+
checks:
24+
- all
25+
- '-QF1008' # nested struct reference
26+
- '-ST1005' # capitalized error strings
27+
exclusions:
28+
generated: lax
29+
presets:
30+
- comments
31+
- common-false-positives
32+
- legacy
33+
- std-error-handling
34+
rules:
35+
- linters:
36+
- revive
37+
- staticcheck
38+
text: use ALL_CAPS in Go names; use CamelCase
39+
- linters:
40+
- revive
41+
text: ' and that stutters;'
42+
- path: (.+)_test\.go
43+
text: 'dot-imports: should not use dot imports'
44+
- path: (.+)_test\.go
45+
text: "ginkgo-linter: wrong comparison assertion. Consider using (.+)BeZero(.+)"
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$
50+
formatters:
51+
enable:
52+
- gci
53+
- gofumpt
54+
settings:
55+
gci:
56+
sections:
57+
- standard
58+
- default
59+
- prefix(github.com/mlguerrero12)
60+
exclusions:
61+
generated: lax
62+
paths:
63+
- third_party$
64+
- builtin$
65+
- examples$

Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM golang:1.24 as builder
2+
ARG TARGETOS
3+
ARG TARGETARCH
4+
5+
WORKDIR /workspace
6+
7+
COPY go.mod go.mod
8+
COPY go.sum go.sum
9+
RUN go mod download
10+
11+
COPY cmd/main.go cmd/main.go
12+
COPY pkg/ pkg/
13+
14+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o multi-networkpolicy-nftables cmd/main.go
15+
16+
FROM fedora:42
17+
WORKDIR /
18+
19+
RUN dnf install -y nftables
20+
COPY --from=builder /workspace/multi-networkpolicy-nftables .
21+
ENTRYPOINT ["/multi-networkpolicy-nftables"]

0 commit comments

Comments
 (0)