Skip to content

Commit f6c01c4

Browse files
committed
Initial commit
0 parents  commit f6c01c4

25 files changed

+1196
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
9+
[*.yaml]
10+
indent_style = space
11+
indent_size = 2

.github/workflows/pre-commit.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ main ]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
env:
12+
HELM_CACHE_HOME: "/tmp/helm-cache/"
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-python@v3
16+
17+
- name: Restore helm cache
18+
uses: actions/cache@v4
19+
with:
20+
path: ${{ env.HELM_CACHE_HOME }}
21+
key: ${{ runner.os }}-helm
22+
23+
- name: Install helm
24+
uses: azure/[email protected]
25+
- name: Install helm plugins
26+
run: |
27+
helm plugin install https://github.com/helm-unittest/helm-unittest.git
28+
29+
- name: Run pre-commit
30+
uses: pre-commit/[email protected]

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

.pre-commit-config.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
repos:
3+
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
4+
rev: 0.2.3 # or other specific tag
5+
hooks:
6+
- id: yamlfmt
7+
files: .*.(yaml|yml)
8+
exclude: templates/
9+
args: [--mapping, '2', --sequence, '2', --offset, '0']
10+
- repo: local
11+
hooks:
12+
- entry: ./scripts/bundle_schemas.sh
13+
id: schema-bundle
14+
language: node
15+
name: schema-bundle
16+
pass_filenames: false
17+
- entry: ./scripts/test.sh
18+
id: helm-unittest
19+
language: script
20+
name: helm-unittest
21+
pass_filenames: false
22+
- entry: ./scripts/lint.sh
23+
id: helm-lint
24+
language: script
25+
name: helm-lint
26+
pass_filenames: false

.tool-versions

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
nodejs 22.11.0
2+
helm 3.16.3

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# GitGuardian NHI Helm Charts
2+
3+
## Development
4+
5+
Install the [helm unittest plugin](https://github.com/helm-unittest/helm-unittest)
6+
7+
```shell
8+
$ helm plugin install https://github.com/helm-unittest/helm-unittest.git
9+
```

charts/inventory-agent/.helmignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
24+
25+
tests/
26+
test_values.yaml

charts/inventory-agent/Chart.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
apiVersion: v2
3+
name: inventory-agent
4+
description: A Helm chart for Kubernetes
5+
6+
# A chart can be either an 'application' or a 'library' chart.
7+
#
8+
# Application charts are a collection of templates that can be packaged into versioned archives
9+
# to be deployed.
10+
#
11+
# Library charts provide useful utilities or functions for the chart developer. They're included as
12+
# a dependency of application charts to inject those utilities and functions into the rendering
13+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
14+
type: application
15+
16+
# This is the chart version. This version number should be incremented each time you make changes
17+
# to the chart and its templates, including the app version.
18+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
19+
version: 0.1.0
20+
21+
# This is the version number of the application being deployed. This version number should be
22+
# incremented each time you make changes to the application. Versions are not expected to
23+
# follow Semantic Versioning. They should reflect the version the application is using.
24+
# It is recommended to use it with quotes.
25+
appVersion: 1.16.0
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Thank you for installing {{ .Chart.Name }}.
2+
3+
Your release is named {{ .Release.Name }}.
4+
5+
The agent will run with the following schedule: {{ .Values.inventory.schedule }}
6+
7+
To learn more about the release, try:
8+
9+
$ helm status {{ .Release.Name }}
10+
$ helm get all {{ .Release.Name }}
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "inventory-agent.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "inventory-agent.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "inventory-agent.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "inventory-agent.labels" -}}
37+
helm.sh/chart: {{ include "inventory-agent.chart" . }}
38+
{{ include "inventory-agent.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "inventory-agent.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "inventory-agent.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "inventory-agent.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "inventory-agent.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "inventory-agent.fullname" . }}
5+
labels:
6+
{{- include "inventory-agent.labels" . | nindent 4 }}
7+
data:
8+
config.yml: {{ toYaml .Values.inventory.config|quote }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
name: {{ include "inventory-agent.fullname" . }}
5+
labels:
6+
{{- include "inventory-agent.labels" . | nindent 4 }}
7+
spec:
8+
schedule: {{ toJson .Values.inventory.schedule }}
9+
jobTemplate:
10+
spec:
11+
template:
12+
metadata:
13+
{{- with .Values.podAnnotations }}
14+
annotations: {{- toJson . }}
15+
{{- end }}
16+
labels:
17+
{{- include "inventory-agent.labels" . | nindent 12 }}
18+
{{- with .Values.podLabels }}
19+
{{ toYaml . | nindent 12 }}
20+
{{- end }}
21+
spec:
22+
containers:
23+
- name: {{ .Chart.Name }}
24+
securityContext: {{ toJson .Values.securityContext }}
25+
image: "{{ .Values.image.repository }}:{{ .Values.inventory.version }}"
26+
imagePullPolicy: {{ .Values.image.pullPolicy }}
27+
resources: {{ toJson .Values.resources }}
28+
env:
29+
- name: INVENTORY_CONFIG_PATH
30+
value: /etc/inventory/config.yml
31+
volumeMounts:
32+
- name: config
33+
mountPath: /etc/inventory
34+
{{- with .Values.imagePullSecrets }}
35+
imagePullSecrets: {{ toJson . }}
36+
{{- end }}
37+
serviceAccountName: {{ include "inventory-agent.serviceAccountName" . }}
38+
securityContext: {{ toJson .Values.podSecurityContext }}
39+
{{- with .Values.nodeSelector }}
40+
nodeSelector: {{ toJson . }}
41+
{{- end }}
42+
{{- with .Values.affinity }}
43+
affinity: {{ toJson . }}
44+
{{- end }}
45+
{{- with .Values.tolerations }}
46+
tolerations: {{ toJson . }}
47+
{{- end }}
48+
restartPolicy: {{ .Values.restartPolicy }}
49+
50+
volumes:
51+
- name: config
52+
configMap:
53+
# Provide the name of the ConfigMap containing the files you want
54+
# to add to the container
55+
name: {{ include "inventory-agent.fullname" . }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.serviceAccount.create -}}
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: {{ include "inventory-agent.serviceAccountName" . }}
6+
labels:
7+
{{- include "inventory-agent.labels" . | nindent 4 }}
8+
{{- with .Values.serviceAccount.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
13+
{{- end }}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# yaml-language-server: $schema=values.schema.json
3+
4+
inventory:
5+
config:
6+
sources: {}
7+
8+
imagePullSecrets:
9+
- name: ghcr
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
# Test docs: https://github.com/helm-unittest/helm-unittest/blob/main/DOCUMENT.md
3+
suite: test configmap
4+
values:
5+
- ../test_values.yaml
6+
templates:
7+
- configmap.yaml
8+
tests:
9+
- it: should work
10+
set:
11+
inventory.config.sources:
12+
kube:
13+
type: k8s
14+
asserts:
15+
- isKind:
16+
of: ConfigMap
17+
- matchRegex:
18+
path: metadata.name
19+
pattern: -inventory-agent$
20+
- equal:
21+
path: data["config.yml"]
22+
value: |-
23+
sources:
24+
kube:
25+
type: k8s

0 commit comments

Comments
 (0)