Skip to content

Commit

Permalink
Merge pull request #6 from GitGuardian/ctourriere/-/rename_and_bump_c…
Browse files Browse the repository at this point in the history
…hart

chore(name): Rename to nhi-scout
  • Loading branch information
clement-tourriere authored Dec 17, 2024
2 parents bf79aef + 00f030a commit f547554
Show file tree
Hide file tree
Showing 26 changed files with 233 additions and 97 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
Add the repository to Helm with:

```shell
helm repo add gg-nhi https://gitguardian.github.io/nhi-explorer-helm-charts
helm repo add gg-nhi https://gitguardian.github.io/gitguardian-nhi-scout-helm-charts
```

Then install the explorer, with a values file (examples below):
Then install the scout, with a values file (examples below):

```shell
helm upgrade explorer gg-nhi/nhi-explorer --install --values values.yml
helm upgrade scout gg-nhi/nhi-scout --install --values values.yml
```

An example values file that fetches from HashiCorp Vault and GitLab CI:
Expand All @@ -33,9 +33,9 @@ inventory:
type: gitlabci
token: "${GITLAB_TOKEN}"
url: "https://gitlab.gitguardian.ovh"
# To upload, set the upload URL and tokens. Ensure the endpoint path ends with /v1
# To upload, set the gitguardian URL and tokens. Ensure the endpoint path ends with /v1
# This is optional: omit this to prevent uploading and to only test collection.
upload:
gitguardian:
endpoint: "https://your-gg-instance/v1"
api_token: "${GG_API_TOKEN}"

Expand All @@ -44,10 +44,10 @@ inventory:
# - `GG_API_TOKEN` - the GitGuardian token to send results with
envFrom:
- secretRef:
name: inventory-explorer-secrets
name: gitguardian-nhi-scout-secrets
```
Other examples can be found in [charts/nhi-explorer/examples](charts/nhi-explorer/examples).
Other examples can be found in [charts/nhi-scout/examples](charts/nhi-scout/examples).
## Development
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
apiVersion: v2
name: nhi-explorer
name: nhi-scout
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ inventory:
config:
sources:
kubernetes:
name: my-cluster
type: k8s
context: null # Kubernetes context or null
namespaces: # List of namespaces or null
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "nhi-explorer.name" -}}
{{- define "nhi-scout.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

Expand All @@ -10,7 +10,7 @@ Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "nhi-explorer.fullname" -}}
{{- define "nhi-scout.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
Expand All @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "nhi-explorer.chart" -}}
{{- define "nhi-scout.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "nhi-explorer.labels" -}}
helm.sh/chart: {{ include "nhi-explorer.chart" . }}
{{ include "nhi-explorer.selectorLabels" . }}
{{- define "nhi-scout.labels" -}}
helm.sh/chart: {{ include "nhi-scout.chart" . }}
{{ include "nhi-scout.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/*
Selector labels
*/}}
{{- define "nhi-explorer.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nhi-explorer.name" . }}
{{- define "nhi-scout.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nhi-scout.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "nhi-explorer.serviceAccountName" -}}
{{- define "nhi-scout.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "nhi-explorer.fullname" .) .Values.serviceAccount.name }}
{{- default (include "nhi-scout.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
labels:
{{- include "nhi-explorer.labels" . | nindent 4 }}
{{- include "nhi-scout.labels" . | nindent 4 }}
rules:
- apiGroups: [""]
resources: ["namespaces"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
labels:
{{- include "nhi-explorer.labels" . | nindent 4 }}
{{- include "nhi-scout.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
namespace: {{ .Values.namespace }}
roleRef:
kind: ClusterRole
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
apiGroup: rbac.authorization.k8s.io
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
labels:
{{- include "nhi-explorer.labels" . | nindent 4 }}
{{- include "nhi-scout.labels" . | nindent 4 }}
data:
config.yml: {{ toYaml .Values.inventory.config|quote }}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
labels:
{{- include "nhi-explorer.labels" . | nindent 4 }}
{{- include "nhi-scout.labels" . | nindent 4 }}
spec:
schedule: {{ toJson .Values.inventory.schedule }}
jobTemplate:
Expand All @@ -15,7 +15,7 @@ spec:
annotations: {{- toJson . }}
{{- end }}
labels:
{{- include "nhi-explorer.labels" . | nindent 12 }}
{{- include "nhi-scout.labels" . | nindent 12 }}
{{- with .Values.podLabels }}
{{ toYaml . | nindent 12 }}
{{- end }}
Expand All @@ -26,10 +26,10 @@ spec:
image: "{{ .Values.image.repository }}:{{ .Values.inventory.version }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{- if ne .Values.inventory.config.upload nil }}
- fetch-from-config-and-send
{{- if ne .Values.inventory.config.gitguardian nil }}
- fetch-and-send
{{- else }}
- from-config
- fetch
{{- end }}
resources: {{ toJson .Values.resources }}
envFrom: {{ toJson .Values.envFrom }}
Expand All @@ -49,7 +49,7 @@ spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets: {{ toJson . }}
{{- end }}
serviceAccountName: {{ include "nhi-explorer.serviceAccountName" . }}
serviceAccountName: {{ include "nhi-scout.serviceAccountName" . }}
securityContext: {{ toJson .Values.podSecurityContext }}
{{- with .Values.nodeSelector }}
nodeSelector: {{ toJson . }}
Expand All @@ -67,4 +67,4 @@ spec:
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: {{ include "nhi-explorer.fullname" . }}
name: {{ include "nhi-scout.fullname" . }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "nhi-explorer.serviceAccountName" . }}
name: {{ include "nhi-scout.serviceAccountName" . }}
labels:
{{- include "nhi-explorer.labels" . | nindent 4 }}
{{- include "nhi-scout.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
inventory:
config:
sources: {}
upload: null
gitguardian: null

imagePullSecrets:
- name: ghcr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tests:
of: ClusterRole
- matchRegex:
path: metadata.name
pattern: -nhi-explorer$
pattern: -nhi-scout$
- it: "does not create a ClusterRole"
set:
clusterRole.create: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ templates:
set:
clusterRole.create: true
serviceAccount.create: true
namespace: nhi-explorer
namespace: nhi-scout
tests:
- it: should have the correct kind for ClusterRoleBinding
asserts:
Expand All @@ -18,7 +18,7 @@ tests:
asserts:
- equal:
path: subjects[0].namespace
value: nhi-explorer
value: nhi-scout
- it: "does not create a ClusterRoleBinding if clusterRole.create is false"
set:
clusterRole.create: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ tests:
sources:
kube:
type: k8s
upload: null
name: my-cluster
gitguardian: null
asserts:
- isKind:
of: ConfigMap
- matchRegex:
path: metadata.name
pattern: -nhi-explorer$
pattern: -nhi-scout$
- equal:
path: data["config.yml"]
value: |-
gitguardian: null
sources:
kube:
name: my-cluster
type: k8s
upload: null
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ tests:
of: CronJob
- matchRegex:
path: metadata.name
pattern: -nhi-explorer$
pattern: -nhi-scout$
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].image
value: ghcr.io/gitguardian/gg-nhi-explorer/chainguard:latest
value: ghcr.io/gitguardian/gitguardian-nhi-scout/chainguard:latest

- it: should set schedule
set:
Expand Down Expand Up @@ -70,7 +70,7 @@ tests:
content:
name: config
configMap:
name: RELEASE-NAME-nhi-explorer
name: RELEASE-NAME-nhi-scout
- contains:
path: spec.jobTemplate.spec.template.spec.containers[0].env
content:
Expand All @@ -97,24 +97,24 @@ tests:
name: foo
value: bar

- it: should use the upload command if set
- it: should use the gitguardian command if set
set:
inventory.config.upload.api_token: "foobar"
inventory.config.upload.endpoint: "https://some-url.com"
inventory.config.gitguardian.api_token: "foobar"
inventory.config.gitguardian.endpoint: "https://some-url.com"
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].args
value:
- fetch-from-config-and-send
- fetch-and-send

- it: should use the fetch command if no upload is set
set:
inventory.config.upload: null
inventory.config.gitguardian: null
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].args
value:
- from-config
- fetch

- it: should use the right log level
set:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ tests:
of: ServiceAccount
- matchRegex:
path: metadata.name
pattern: -nhi-explorer$
pattern: -nhi-scout$
Loading

0 comments on commit f547554

Please sign in to comment.