Skip to content

Commit b9fb762

Browse files
author
mgianluc
committed
Jsonnet controller
This PR adds jsoneet controller logic. Get jsonnet files, process those and store result in Status section making it available for Sveltos to use. This PR has uts and functional verification using a Kind cluster.
1 parent 19605a0 commit b9fb762

Some content is hidden

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

61 files changed

+6634
-7
lines changed

.github/workflows/main.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: main
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
types: [opened, edited, reopened]
9+
10+
11+
jobs:
12+
build-static-test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Go
20+
uses: actions/setup-go@v3
21+
with:
22+
go-version: 1.19
23+
- name: Build
24+
run: make build
25+
- name: FMT
26+
run: make fmt
27+
- name: VET
28+
run: make vet
29+
- name: LINT
30+
run: make lint
31+
env:
32+
LINT: true
33+
build-ut:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: checkout
37+
uses: actions/checkout@v3
38+
with:
39+
fetch-depth: 0
40+
- name: Set up Go
41+
uses: actions/setup-go@v3
42+
with:
43+
go-version: 1.19
44+
- name: ut
45+
run: make test
46+
env:
47+
UT: true
48+
FV:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: checkout
52+
uses: actions/checkout@v3
53+
with:
54+
fetch-depth: 0
55+
- name: Set up Go
56+
uses: actions/setup-go@v3
57+
with:
58+
go-version: 1.19
59+
- name: fv
60+
run: make create-cluster fv
61+
env:
62+
FV: true

.gitignore

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
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
107

8+
bin/
9+
10+
.dockerignore
11+
12+
# tmp files
13+
*.tmp
14+
tmp/
15+
16+
# vim files
17+
*.swp
18+
1119
# Test binary, built with `go test -c`
1220
*.test
1321

1422
# Output of the go coverage tool, specifically when used with LiteIDE
1523
*.out
24+
out.json
1625

17-
# Dependency directories (remove the comment below to include it)
18-
# vendor/
26+
# Needed tools
27+
hack/tools/bin/
1928

20-
# Go workspace file
21-
go.work
29+
manager_image_patch.yaml-e
30+
manager_pull_policy.yaml-e

.golangci.yaml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
linters-settings:
2+
depguard:
3+
list-type: blacklist
4+
packages:
5+
# Following logging implementations are allowed:
6+
# k8s.io/klog
7+
# go.uber.org/zap
8+
# go-logr/logr
9+
#
10+
# note that the following list will grow.
11+
- github.com/google/glog
12+
- log
13+
- github.com/sirupsen/logrus
14+
- github.com/wojas/genericr
15+
- logfmt
16+
packages-with-error-message:
17+
- github.com/google/glog: "Use klog, zap, or logr for logging."
18+
- log: "Use klog, zap, or logr for logging."
19+
- github.com/sirupsen/logrus: "Use klog, zap, or logr for logging."
20+
- github.com/wojas/genericr: "Use klog, zap, or logr for logging."
21+
- logfmt: "Use klog, zap, or logr for logging."
22+
dupl:
23+
threshold: 200
24+
errorlint:
25+
# Use '%w' to format errors.
26+
errorf: true
27+
exhaustive:
28+
# Ignore auto-generated code.
29+
check-generated: false
30+
default-signifies-exhaustive: false
31+
forbidigo:
32+
forbid:
33+
# Forbid 'fmt.Print[|f|ln]() in shipping code.
34+
- 'fmt\.Print.*'
35+
funlen:
36+
lines: 100
37+
statements: 50
38+
goconst:
39+
min-len: 2
40+
min-occurrences: 2
41+
gocritic:
42+
enabled-tags:
43+
- diagnostic
44+
- experimental
45+
- opinionated
46+
- performance
47+
- style
48+
disabled-checks:
49+
- dupImport # https://github.com/go-critic/go-critic/issues/845
50+
- ifElseChain
51+
- octalLiteral
52+
- whyNoLint # conflicts with nolintlint config providing superset functionality
53+
- wrapperFunc
54+
gocyclo:
55+
min-complexity: 20
56+
goimports:
57+
local-prefixes: github.com/projectsveltos
58+
gomnd:
59+
settings:
60+
mnd:
61+
# don't include the "operation" and "assign"
62+
checks: argument,case,condition,return
63+
gomodguard:
64+
# Although this is almost empty, we will evolve the list below with the
65+
# modules we shouldn't use for technical and/or security reasons.
66+
blocked:
67+
modules:
68+
- k8s.io/kubernetes:
69+
reason: "There is no good, avoidable reason to use this package and often leads to issues such as https://bit.ly/3dlKScY. However, if you disagree please include @ravchama in code review highlighting the reason."
70+
versions:
71+
# Don't merge replace directives using local path.
72+
local_replace_directives: true
73+
govet:
74+
check-shadowing: true
75+
settings:
76+
printf:
77+
funcs:
78+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
79+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
80+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
81+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
82+
grouper:
83+
const-require-grouping: true
84+
import-require-single-import: true
85+
import-require-grouping: true
86+
var-require-grouping: true
87+
lll:
88+
line-length: 160
89+
maintidx:
90+
# check https://bit.ly/3tlJX3n for maintainability index.
91+
##
92+
# starting with 25 to begin with, with the plan to bump it to 40 eventuallly.
93+
##
94+
under: 25
95+
misspell:
96+
locale: US
97+
nolintlint:
98+
allow-unused: false # report any unused nolint directives
99+
require-explanation: true # require an explanation for nolint directives
100+
require-specific: true # require nolint directives to be specific about which linter is being skipped
101+
revive:
102+
ignore-generated-header: true
103+
# this is a new linter, so let's start with Warning instead of errors to
104+
# begin with.
105+
severity: warning
106+
whitespace:
107+
multi-if: true
108+
multi-func: true
109+
110+
linters:
111+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
112+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
113+
disable-all: true
114+
fast: false
115+
enable:
116+
- bidichk
117+
- containedctx
118+
- bodyclose
119+
- depguard
120+
- dogsled
121+
- dupl
122+
- durationcheck
123+
- errcheck
124+
- errname
125+
- errorlint
126+
- exhaustive
127+
- exportloopref
128+
- forbidigo
129+
- funlen
130+
- goconst
131+
- gocritic
132+
- gocyclo
133+
- gofmt
134+
- goimports
135+
- gomnd
136+
- gomodguard
137+
- goprintffuncname
138+
- gosec
139+
- gosimple
140+
- govet
141+
- grouper
142+
- ineffassign
143+
- lll
144+
- misspell
145+
- maintidx
146+
- nakedret
147+
- noctx
148+
- nolintlint
149+
- nosprintfhostport
150+
- predeclared
151+
- revive
152+
- staticcheck
153+
- typecheck
154+
- unconvert
155+
- unparam
156+
- unused
157+
- whitespace
158+
159+
# don't enable:
160+
# - asciicheck
161+
# - exhaustivestruct # applicable to special cases.
162+
# - gochecknoglobals
163+
# - gocognit
164+
# - godot
165+
# - godox
166+
# - goerr113
167+
# - golint # deprecated
168+
# - interfacer # deprecated
169+
# - maligned #deprecated
170+
# - nestif
171+
# - prealloc
172+
# - scopelint # deprecated
173+
# - testpackage
174+
# - wsl
175+
176+
issues:
177+
# Excluding configuration per path, per linter, per text and per-source
178+
exclude-rules:
179+
- path: _test\.go
180+
linters:
181+
- gomnd
182+
- grouper
183+
- maintidx
184+
185+
# https://github.com/go-critic/go-critic/issues/926
186+
- linters:
187+
- gocritic
188+
text: "unnecessaryDefer:"
189+
# Maximum issues count per one linter.
190+
# Set to 0 to disable.
191+
max-issues-per-linter: 0
192+
# Maximum count of issues with the same text.
193+
# Set to 0 to disable.
194+
max-same-issues: 0
195+
196+
run:
197+
# Allow multiple parallel golangci-lint instances running.
198+
allow-parallel-runners: true
199+
# Timeout for analysis
200+
timeout: 5m
201+
# files to skip: they will be analyzed, but issues from them won't be reported.
202+
skip-dirs:
203+
- cmd/example/gen

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Build the manager binary
2+
FROM golang:1.18 as builder
3+
4+
WORKDIR /workspace
5+
# Copy the Go Modules manifests
6+
COPY go.mod go.mod
7+
COPY go.sum go.sum
8+
# cache deps before building and copying source so that we don't need to re-download as much
9+
# and so that source changes don't invalidate our downloaded layer
10+
RUN go mod download
11+
12+
# Copy the go source
13+
COPY main.go main.go
14+
COPY api/ api/
15+
COPY controllers/ controllers/
16+
17+
# Build
18+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
19+
20+
# Use distroless as minimal base image to package the manager binary
21+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
22+
FROM gcr.io/distroless/static:nonroot
23+
WORKDIR /
24+
COPY --from=builder /workspace/manager .
25+
USER 65532:65532
26+
27+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)