Skip to content

Commit d7f92b1

Browse files
author
Marcelo
committed
First commit
0 parents  commit d7f92b1

File tree

86 files changed

+22296
-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.

86 files changed

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