Skip to content

Commit c6b8379

Browse files
Merge pull request #2 from SAP/initial
feat: initial
2 parents 7ba24c5 + 29432b9 commit c6b8379

File tree

165 files changed

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

165 files changed

+14891
-0
lines changed

.dockerignore

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

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
insert_final_newline = true
5+
charset = utf-8
6+
trim_trailing_whitespace = true
7+
indent_style = space
8+
indent_size = 4
9+
10+
[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
11+
indent_style = tab
12+
13+
[*.md]
14+
trim_trailing_whitespace = false
15+
16+
17+
[{*.yml,*.yaml}]
18+
indent_size = 2
19+
20+
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Check Go Dependency Licenses
2+
3+
on:
4+
workflow_call: {}
5+
pull_request:
6+
branches:
7+
- main
8+
paths:
9+
- go.mod
10+
- go.sum
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
validate:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: checkout repo
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
22+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
23+
with:
24+
go-version: '1.24'
25+
26+
- name: Install go-licenses
27+
run: |
28+
go install github.com/google/go-licenses@latest
29+
30+
- name: check licenses
31+
# Remove ignore before go live
32+
run: |
33+
go-licenses check --allowed_licenses="Apache-2.0,BSD-3-Clause,MIT,MPL-2.0,ISC,BSD-2-Clause" --ignore github.com/dynatrace-ace/dynatrace-go-api-client ./...
34+

.github/workflows/reuse-scan.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This workflow is triggered by the user and runs the REUSE compliance check (reuse lint) on the repository.
2+
3+
name: REUSE Compliance Check
4+
5+
on:
6+
workflow_call: {}
7+
pull_request:
8+
branches:
9+
- main
10+
11+
12+
jobs:
13+
lint-reuse:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
17+
- name: REUSE Compliance Check
18+
uses: fsfe/reuse-action@3ae3c6bdf1257ab19397fab11fd3312144692083 # v4.0.0

.github/workflows/reviewable.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will run make reviewable and make check-diff as checks
2+
3+
name: make reviewable && make check-Diff
4+
5+
on:
6+
workflow_call: {}
7+
pull_request:
8+
branches:
9+
- main
10+
env:
11+
GO_IMPORT_VERSION: 'v0.16.1'
12+
13+
jobs:
14+
run:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
with:
19+
submodules: true
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
23+
with:
24+
go-version: '1.24'
25+
26+
- name: Install goimports
27+
run: |
28+
cd /tmp
29+
go install golang.org/x/tools/cmd/goimports@${{ env.GO_IMPORT_VERSION }}
30+
31+
- name: make reviewable
32+
run: make reviewable
33+
env:
34+
RUNNING_IN_CI: 'true'
35+
- name: make check-diff
36+
run: make check-diff

.gitignore

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

.golangci.yml

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
linters-settings:
2+
errcheck:
3+
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
4+
# default is false: such cases aren't reported by default.
5+
check-type-assertions: false
6+
7+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
8+
# default is false: such cases aren't reported by default.
9+
check-blank: false
10+
11+
# [deprecated] comma-separated list of pairs of the form pkg:regex
12+
# the regex is used to ignore names within pkg. (default "fmt:.*").
13+
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
14+
exclude-functions:
15+
- fmt:.*
16+
- io/ioutil:^Read.*
17+
18+
govet:
19+
# report about shadowed variables
20+
disable:
21+
- shadow
22+
gofmt:
23+
# simplify code: gofmt with `-s` option, true by default
24+
simplify: true
25+
26+
goimports:
27+
# put imports beginning with prefix after 3rd-party packages;
28+
# it's a comma-separated list of prefixes
29+
local-prefixes: github.com/SAP/metrics-operator
30+
31+
gocyclo:
32+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
33+
min-complexity: 10
34+
35+
dupl:
36+
# tokens count to trigger issue, 150 by default
37+
threshold: 100
38+
39+
goconst:
40+
# minimal length of string constant, 3 by default
41+
min-len: 3
42+
# minimal occurrences count to trigger, 3 by default
43+
min-occurrences: 5
44+
45+
lll:
46+
# Max line length, lines longer will be reported.
47+
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.
48+
# Default: 120.
49+
line-length: 120
50+
# Tab width in spaces.
51+
# Default: 1
52+
tab-width: 1
53+
54+
unused:
55+
# treat code as a program (not a library) and report unused exported identifiers; default is false.
56+
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
57+
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
58+
# with golangci-lint call it on a directory with the changed file.
59+
exported-fields-are-used: false
60+
61+
unparam:
62+
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
63+
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
64+
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
65+
# with golangci-lint call it on a directory with the changed file.
66+
check-exported: false
67+
68+
nakedret:
69+
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
70+
max-func-lines: 30
71+
72+
prealloc:
73+
# XXX: we don't recommend using this linter before doing performance profiling.
74+
# For most programs usage of prealloc will be a premature optimization.
75+
76+
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
77+
# True by default.
78+
simple: true
79+
range-loops: true # Report preallocation suggestions on range loops, true by default
80+
for-loops: false # Report preallocation suggestions on for loops, false by default
81+
82+
gocritic:
83+
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
84+
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
85+
enabled-tags:
86+
- performance
87+
88+
settings: # settings passed to gocritic
89+
captLocal: # must be valid enabled check name
90+
paramsOnly: true
91+
rangeValCopy:
92+
sizeThreshold: 32
93+
94+
linters:
95+
enable:
96+
- gosimple
97+
- staticcheck
98+
- unused
99+
- govet
100+
- gocyclo
101+
- gocritic
102+
- goconst
103+
- goimports
104+
- gofmt # We enable this as well as goimports for its simplify mode.
105+
- prealloc
106+
- revive
107+
- unconvert
108+
- misspell
109+
- nakedret
110+
disable:
111+
- nilnesserr
112+
presets:
113+
- bugs
114+
- unused
115+
fast: false
116+
117+
118+
issues:
119+
exclude-files:
120+
- 'zz_generated.*\.go'
121+
# Excluding configuration per-path and per-linter
122+
exclude-rules:
123+
# Exclude some linters from running on tests files.
124+
- path: _test(ing)?\.go
125+
linters:
126+
- gocyclo
127+
- errcheck
128+
- dupl
129+
- gosec
130+
- scopelint
131+
- unparam
132+
- revive
133+
134+
# Ease some gocritic warnings on test files.
135+
- path: _test\.go
136+
text: "(unnamedResult|exitAfterDefer)"
137+
linters:
138+
- gocritic
139+
140+
# These are performance optimisations rather than style issues per se.
141+
# They warn when function arguments or range values copy a lot of memory
142+
# rather than using a pointer.
143+
- text: "(hugeParam|rangeValCopy):"
144+
linters:
145+
- gocritic
146+
147+
# This "TestMain should call os.Exit to set exit code" warning is not clever
148+
# enough to notice that we call a helper method that calls os.Exit.
149+
- text: "SA3000:"
150+
linters:
151+
- staticcheck
152+
153+
- text: "k8s.io/api/core/v1"
154+
linters:
155+
- goimports
156+
157+
# This is a "potential hardcoded credentials" warning. It's triggered by
158+
# any variable with 'secret' in the same, and thus hits a lot of false
159+
# positives in Kubernetes land where a Secret is an object type.
160+
- text: "G101:"
161+
linters:
162+
- gosec
163+
- gas
164+
165+
# This is an 'errors unhandled' warning that duplicates errcheck.
166+
- text: "G104:"
167+
linters:
168+
- gosec
169+
- gas
170+
# ease package comments rule
171+
- text: "package-comments:"
172+
linters:
173+
- revive
174+
175+
# Independently from option `exclude` we use default exclude patterns,
176+
# it can be disabled by this option. To list all
177+
# excluded by default patterns execute `golangci-lint run --help`.
178+
# Default value for this option is true.
179+
exclude-use-default: false
180+
181+
# Show only new issues: if there are unstaged changes or untracked files,
182+
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
183+
# It's a super-useful option for integration of golangci-lint into existing
184+
# large codebase. It's not practical to fix all existing issues at the moment
185+
# of integration: much better don't allow issues in new code.
186+
# Default is false.
187+
new: false
188+
189+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
190+
max-issues-per-linter: 0
191+
192+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
193+
max-same-issues: 0
194+
195+
run:
196+
timeout: 10m

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Use distroless as minimal base image to package the manager binary
2+
# Refer to https://github.com/GoogleContainerTools/distroless for more details
3+
FROM gcr.io/distroless/static:nonroot
4+
WORKDIR /
5+
COPY bin/manager-linux.amd64 /manager
6+
USER 65532:65532
7+
8+
ENTRYPOINT ["/manager"]

0 commit comments

Comments
 (0)