Skip to content

Commit 7855622

Browse files
dark-vexsthwang-metalmavimo
authored
feat(harbor-scanner-sysdig-deploy): Allow usage of an existing secret for cliScanning (#2254)
Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com> Co-authored-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com> Co-authored-by: Marco Vito Moscaritolo <mavimo@gmail.com>
1 parent 3fed7ff commit 7855622

File tree

6 files changed

+58
-6
lines changed

6 files changed

+58
-6
lines changed

.github/workflows/helm-unit-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,8 @@ jobs:
6565
- name: Test sysdig-stackdriver-bridge
6666
run: helm unittest --strict ./charts/sysdig-stackdriver-bridge
6767

68+
- name: Test harbor-scanner-sysdig-secure
69+
run: helm unittest --strict ./charts/harbor-scanner-sysdig-secure
70+
6871
- name: Test shield
6972
run: helm unittest --strict -f 'tests/*/*_test.yaml' ./charts/shield

charts/harbor-scanner-sysdig-secure/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: harbor-scanner-sysdig-secure
33
description: Harbor Scanner for Sysdig Secure
44
type: application
5-
version: 0.8.0
5+
version: 0.9.0
66
appVersion: 0.8.0
77
home: https://github.com/sysdiglabs/harbor-scanner-sysdig-secure
88
icon: https://avatars.githubusercontent.com/u/5068817?s=200&v=4

charts/harbor-scanner-sysdig-secure/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ Sysdig Secure chart and their default values:
8585
| `nodeSelector` | Specifies the nodeSelector for scheduling. | `{}` |
8686
| `tolerations` | Specifies the tolerations for scheduling. | `[]` |
8787
| `affinity` | Enables affinity rules | `{}` |
88-
| `sysdig.secure.apiToken` | Specifies the API Token to access Sysdig Secure. This value is **mandatory**. | ` ` |
88+
| `sysdig.secure.apiToken` | Specifies the API Token to access Sysdig Secure. This value is **required** if the `sysdig.secure.existingSecureAPITokenSecret` is not specified. | ` ` |
8989
| `sysdig.secure.existingSecureAPITokenSecret` | Specifies the existing secret name with API Token to access Sysdig Secure <br/>Alternatively, you can specify the name of a Kubernetes secret containing `sysdig_secure_api_token` entry. <br/><br/>If both are not configured, you must provide the deployment with the `SECURE_API_TOKEN` environment variables. | ` ` |
9090
| `sysdig.secure.url` | Specifies the Sysdig Secure endpoint. | `https://secure.sysdig.com` |
9191
| `sysdig.secure.verifySSL` | Verifies whether SSL certificate when connecting to Sysdig Secure endpoint. | `true` |
92-
| `proxy.httpProxy` | Specifies the URL of the proxy for HTTP connections. Leave empty if not using proxy. It sets the `http_proxy` environment variable. | ` ` |
92+
| `proxy.httpProxy` | Specifies the URL of the proxy for HTTP connections. Leave empty if not using proxy. It sets the `http_proxy` environment variable. | ` ` |
9393
| `proxy.httpsProxy` | Specifies the URL of the proxy for HTTPS connections. Leave empty if not using proxy. It sets the `https_proxy` environment variable. | ` ` |
9494
| `proxy.noProxy` | Specifies the comma-separated list of domain extensions proxy should not be used for. Includes the internal IP of the kube API server. | ` ` |
95-
| `cliScanning.enabled` | Enables the CLI Scanning feature. | `true` |
96-
| `cliScanning.image` | Specifies the pullstring for the CLI Scanner Image. | `alpine:latest` |
95+
| `cliScanning.enabled` | Enables the CLI Scanning feature. | `true` |
96+
| `cliScanning.image` | Specifies the pullstring for the CLI Scanner Image. | `alpine:latest` |
97+
| `cliScanning.existingSecureAPITokenSecret` | Specifies the existing secret name with API Token to access Sysdig Secure | `{{ include "harbor-scanner-sysdig-secure.fullname" . }}` |
9798
| `asyncMode.enabled` | Enables the Async-Mode feature. | `false` |

charts/harbor-scanner-sysdig-secure/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ spec:
7777
- name: NAMESPACE_NAME
7878
value: {{ .Release.Namespace }}
7979
- name: SECRET_NAME
80-
value: {{ include "harbor-scanner-sysdig-secure.fullname" . }}
80+
value: {{ .Values.cliScanning.existingSecureAPITokenSecret | default (include "harbor-scanner-sysdig-secure.fullname" .) }}
8181
- name: CLI_SCANNER_IMAGE
8282
value: {{ .Values.cliScanning.image | quote }}
8383
{{- end }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
suite: Test Harbor Scanner secrets
2+
templates:
3+
- templates/secret.yaml
4+
- templates/deployment.yaml
5+
tests:
6+
- it: Do not create the secret if the API Token is not set
7+
asserts:
8+
- hasDocuments:
9+
count: 0
10+
template: templates/secret.yaml
11+
12+
- it: Create the secret if the API Token is set
13+
set:
14+
sysdig:
15+
secure:
16+
apiToken: 1234-1234
17+
asserts:
18+
- containsDocument:
19+
kind: Secret
20+
apiVersion: v1
21+
- equal:
22+
path: .data.sysdig_secure_api_token
23+
value: MTIzNC0xMjM0
24+
template: templates/secret.yaml
25+
26+
- it: Use the default secret
27+
set:
28+
sysdig:
29+
secure:
30+
apiToken: 1234-1234
31+
asserts:
32+
- equal:
33+
path: .spec.template.spec.containers[0].env[?(@.name=="SECURE_API_TOKEN")].valueFrom.secretKeyRef.name
34+
value: RELEASE-NAME-harbor-scanner-sysdig-secure
35+
template: templates/deployment.yaml
36+
37+
- it: Use the custome secret when specified
38+
set:
39+
sysdig:
40+
secure:
41+
existingSecureAPITokenSecret: custom-secure-api-token-secret
42+
asserts:
43+
- equal:
44+
path: .spec.template.spec.containers[0].env[?(@.name=="SECURE_API_TOKEN")].valueFrom.secretKeyRef.name
45+
value: custom-secure-api-token-secret
46+
template: templates/deployment.yaml

charts/harbor-scanner-sysdig-secure/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ proxy:
9090
cliScanning:
9191
enabled: true
9292
image: alpine:latest
93+
# specify the name of a Kubernetes secret containing an 'sysdig_secure_api_token' entry, defaults to harbor-scanner-sysdig-secure.fullname
94+
existingSecureAPITokenSecret: ""
9395

9496
asyncMode:
9597
enabled: true

0 commit comments

Comments
 (0)