From ffc3c4a0bf27ed23ce8c083b1423d69d5d46558a Mon Sep 17 00:00:00 2001 From: Matt Rogers Date: Tue, 30 Jul 2024 13:00:08 +0100 Subject: [PATCH] fix: refine templates, code agent --- charts/snyk-broker/templates/_helpers.tpl | 38 +++++++++++- .../templates/broker_deployment.yaml | 2 +- .../templates/code_agent_deployment.yaml | 16 +++-- .../snyk-broker/templates/cra_deployment.yaml | 14 +++-- ..._deployment_disablesuffixes_test.yaml.snap | 4 +- ...ra_deployment_extraPodSpecs_test.yaml.snap | 6 +- .../broker_cra_deployment_test.yaml.snap | 4 +- ...cra_deployment_digitalocean_test.yaml.snap | 18 +++--- ..._deployment_disablesuffixes_test.yaml.snap | 18 +++--- .../cra_deployment_harbor_test.yaml.snap | 18 +++--- .../cra_deployment_test.yaml.snap | 36 ++++++----- charts/snyk-broker/tests/code_agent_test.yaml | 60 +++++++++++++++++++ .../tests/cra_deployment_test.yaml | 24 ++++---- 13 files changed, 183 insertions(+), 75 deletions(-) create mode 100644 charts/snyk-broker/tests/code_agent_test.yaml diff --git a/charts/snyk-broker/templates/_helpers.tpl b/charts/snyk-broker/templates/_helpers.tpl index 6b16518..b562d91 100644 --- a/charts/snyk-broker/templates/_helpers.tpl +++ b/charts/snyk-broker/templates/_helpers.tpl @@ -27,6 +27,42 @@ If release name contains chart name it will be used as a full name. {{- end }} {{- end }} +{{/* +Create a default fully qualified app name for CRA. +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 "container-registry-agent.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- ( printf "%s-container-registry-agent" .Values.fullnameOverride ) | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default "container-registry-agent" .Values.nameOverride }} +{{- if .Values.disableSuffixes }} +{{- printf "%s" $name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create a default fully qualified app name for CA. +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 "code-agent.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- ( printf "%s-code-agent" .Values.fullnameOverride ) | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default "code-agent" .Values.nameOverride }} +{{- if .Values.disableSuffixes }} +{{- printf "%s" $name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + {{/* Create chart name and version as used by the chart label. */}} @@ -191,7 +227,7 @@ Create the name of the service account to use {{/* CRA */}} {{- define "container-registry-agent.url" -}} -{{ printf "http://cra-service-%s:%d" (include "snyk-broker.fullname" . ) ( .Values.deployment.container.crSnykPort | int ) }} +{{ printf "http://%s:%d" (include "container-registry-agent.fullname" . ) ( .Values.deployment.container.crSnykPort | int ) }} {{- end }} {{/**/}} diff --git a/charts/snyk-broker/templates/broker_deployment.yaml b/charts/snyk-broker/templates/broker_deployment.yaml index 9edf478..bfdce6d 100644 --- a/charts/snyk-broker/templates/broker_deployment.yaml +++ b/charts/snyk-broker/templates/broker_deployment.yaml @@ -396,7 +396,7 @@ spec: {{- if .Values.enableCodeAgent }} # Code Agent - name: GIT_CLIENT_URL - value: {{ default (printf "http://code-agent-service:%s" (.Values.deployment.container.caSnykPort | toString)) .Values.gitClientUrl }} + value: {{ default (printf "http://%s:%s" (include "code-agent.fullname" .) (.Values.deployment.container.caSnykPort | toString)) .Values.gitClientUrl }} {{- end }} # Logging - name: LOG_LEVEL diff --git a/charts/snyk-broker/templates/code_agent_deployment.yaml b/charts/snyk-broker/templates/code_agent_deployment.yaml index f6f995f..006ae14 100644 --- a/charts/snyk-broker/templates/code_agent_deployment.yaml +++ b/charts/snyk-broker/templates/code_agent_deployment.yaml @@ -2,18 +2,16 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: "{{ .Values.scmType}}-code-agent{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}" + name: {{ include "code-agent.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: {{ .Release.Name }}-ca + app.kubernetes.io/name: {{ include "code-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: - {{- if not .Values.autoscaling.enabled }} replicas: 1 - {{- end }} selector: matchLabels: - app.kubernetes.io/name: {{ .Release.Name }}-ca + app.kubernetes.io/name: {{ include "code-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: @@ -22,7 +20,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - app.kubernetes.io/name: {{ .Release.Name }}-ca + app.kubernetes.io/name: {{ include "code-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: {{- with .Values.imagePullSecrets }} @@ -58,7 +56,7 @@ spec: - name: SNYK_TOKEN valueFrom: secretKeyRef: - name: snyk-token{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }} + name: {{ include "snyk-broker.snykTokenName" . }} key: snyk-token-key {{- if .Values.tlsRejectUnauthorized }} # Troubleshooting - Set to 0 for SSL inspection testing @@ -85,7 +83,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: "code-agent-service{{if not .Values.disableSuffixes }}-{{ .Release.Name }}{{ end }}" + name: {{ include "code-agent.fullname" . }} namespace: {{ .Release.Namespace }} labels: {{- include "snyk-broker.labels" . | nindent 4 }} @@ -95,7 +93,7 @@ spec: - port: {{ .Values.deployment.container.caSnykPort }} targetPort: {{ .Values.deployment.container.caSnykPort}} selector: - app.kubernetes.io/name: {{ .Release.Name }}-ca + app.kubernetes.io/name: {{ include "code-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} diff --git a/charts/snyk-broker/templates/cra_deployment.yaml b/charts/snyk-broker/templates/cra_deployment.yaml index 1ad31b9..c36c9ed 100644 --- a/charts/snyk-broker/templates/cra_deployment.yaml +++ b/charts/snyk-broker/templates/cra_deployment.yaml @@ -2,16 +2,16 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: cr-{{ include "snyk-broker.deploymentName" . }} + name: {{ include "container-registry-agent.fullname" . }} namespace: {{ .Release.Namespace }} labels: - app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }} + app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }} + app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: @@ -20,7 +20,7 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }} + app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: {{- if .Values.extraPodSpecsCr }} @@ -50,6 +50,8 @@ spec: - name: http containerPort: {{ .Values.deployment.container.crSnykPort }} env: + - name: DEBUG + value: "*" - name: SNYK_PORT value: {{ .Values.deployment.container.crSnykPort | squote }} {{- if .Values.tlsRejectUnauthorized }} @@ -85,7 +87,7 @@ spec: apiVersion: v1 kind: Service metadata: - name: cra-service-{{ include "snyk-broker.fullname" . }} + name: {{ include "container-registry-agent.fullname" . }} namespace: {{ .Release.Namespace }} labels: {{- include "snyk-broker.labels" . | nindent 4 }} @@ -95,6 +97,6 @@ spec: - port: {{ .Values.deployment.container.crSnykPort }} targetPort: {{ .Values.deployment.container.crSnykPort}} selector: - app.kubernetes.io/name: cr-{{ include "snyk-broker.deploymentName" . }} + app.kubernetes.io/name: {{ include "container-registry-agent.fullname" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} diff --git a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap index 6711715..4e84d9f 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_disablesuffixes_test.yaml.snap @@ -36,7 +36,7 @@ with CRA: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: ecr - name: CR_ROLE_ARN @@ -50,7 +50,7 @@ with CRA: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY diff --git a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_extraPodSpecs_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_extraPodSpecs_test.yaml.snap index a255773..16d6d22 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_extraPodSpecs_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_extraPodSpecs_test.yaml.snap @@ -14,7 +14,7 @@ renders extraPodSpecs CRA: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: ecr - name: CR_ROLE_ARN @@ -28,7 +28,7 @@ renders extraPodSpecs CRA: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -88,6 +88,8 @@ renders extraPodSpecs CRA: 2: | containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest diff --git a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap index 6711715..4e84d9f 100644 --- a/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/broker_cra_deployment_test.yaml.snap @@ -36,7 +36,7 @@ with CRA: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: ecr - name: CR_ROLE_ARN @@ -50,7 +50,7 @@ with CRA: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap index b36ab0d..2d9e1b3 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_digitalocean_test.yaml.snap @@ -36,7 +36,7 @@ default values: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: digitalocean-cr - name: CR_BASE @@ -51,7 +51,7 @@ default values: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -107,23 +107,25 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker - name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: replicas: 1 selector: matchLabels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent template: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent spec: containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest @@ -158,7 +160,7 @@ default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME-snyk-broker helm.sh/chart: snyk-broker-0.0.0 - name: cra-service-RELEASE-NAME-snyk-broker + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: ports: @@ -166,5 +168,5 @@ default values: targetPort: 8081 selector: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent type: ClusterIP diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap index c2fcb5a..43598e2 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_disablesuffixes_test.yaml.snap @@ -36,7 +36,7 @@ default values: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-snyk-broker:8081 + value: http://container-registry-agent:8081 - name: CR_TYPE value: ecr - name: CR_ROLE_ARN @@ -50,7 +50,7 @@ default values: - name: BROKER_CLIENT_URL value: http://container-registry-agent-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-snyk-broker:8081/healthcheck + value: http://container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -106,23 +106,25 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker - name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent + name: container-registry-agent namespace: NAMESPACE spec: replicas: 1 selector: matchLabels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent template: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent spec: containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest @@ -157,7 +159,7 @@ default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker helm.sh/chart: snyk-broker-0.0.0 - name: cra-service-snyk-broker + name: container-registry-agent namespace: NAMESPACE spec: ports: @@ -165,5 +167,5 @@ default values: targetPort: 8081 selector: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent type: ClusterIP diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap index 55fc3d0..3693ebc 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_harbor_test.yaml.snap @@ -36,7 +36,7 @@ default values: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: harbor-cr - name: CR_BASE @@ -53,7 +53,7 @@ default values: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -109,23 +109,25 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker - name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: replicas: 1 selector: matchLabels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent template: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent spec: containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest @@ -160,7 +162,7 @@ default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME-snyk-broker helm.sh/chart: snyk-broker-0.0.0 - name: cra-service-RELEASE-NAME-snyk-broker + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: ports: @@ -168,5 +170,5 @@ default values: targetPort: 8081 selector: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent type: ClusterIP diff --git a/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap b/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap index 56f5de9..331d46e 100644 --- a/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap +++ b/charts/snyk-broker/tests/__snapshot__/cra_deployment_test.yaml.snap @@ -36,7 +36,7 @@ default values: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-RELEASE-NAME-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081 + value: http://RELEASE-NAME-container-registry-agent:8081 - name: CR_TYPE value: nexus-cr - name: CR_BASE @@ -53,7 +53,7 @@ default values: - name: BROKER_CLIENT_URL value: http://container-registry-agent-RELEASE-NAME-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-RELEASE-NAME-snyk-broker:8081/healthcheck + value: http://RELEASE-NAME-container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -109,23 +109,25 @@ default values: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker - name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: replicas: 1 selector: matchLabels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent template: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent spec: containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest @@ -160,7 +162,7 @@ default values: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: RELEASE-NAME-snyk-broker helm.sh/chart: snyk-broker-0.0.0 - name: cra-service-RELEASE-NAME-snyk-broker + name: RELEASE-NAME-container-registry-agent namespace: NAMESPACE spec: ports: @@ -168,7 +170,7 @@ default values: targetPort: 8081 selector: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-RELEASE-NAME-snyk-broker + app.kubernetes.io/name: RELEASE-NAME-container-registry-agent type: ClusterIP with suffixes disabled: 1: | @@ -208,7 +210,7 @@ with suffixes disabled: key: container-registry-agent-broker-token-key name: container-registry-agent-broker-token-snyk-broker - name: CR_AGENT_URL - value: http://cra-service-snyk-broker:8081 + value: http://container-registry-agent:8081 - name: CR_TYPE value: nexus-cr - name: CR_BASE @@ -225,7 +227,7 @@ with suffixes disabled: - name: BROKER_CLIENT_URL value: http://container-registry-agent-snyk-broker:8000 - name: BROKER_CLIENT_VALIDATION_URL - value: http://cra-service-snyk-broker:8081/healthcheck + value: http://container-registry-agent:8081/healthcheck - name: LOG_LEVEL value: info - name: LOG_ENABLE_BODY @@ -281,23 +283,25 @@ with suffixes disabled: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker - name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent + name: container-registry-agent namespace: NAMESPACE spec: replicas: 1 selector: matchLabels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent template: metadata: labels: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent spec: containers: - env: + - name: DEBUG + value: '*' - name: SNYK_PORT value: "8081" image: snyk/container-registry-agent:latest @@ -332,7 +336,7 @@ with suffixes disabled: app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: snyk-broker helm.sh/chart: snyk-broker-0.0.0 - name: cra-service-snyk-broker + name: container-registry-agent namespace: NAMESPACE spec: ports: @@ -340,5 +344,5 @@ with suffixes disabled: targetPort: 8081 selector: app.kubernetes.io/instance: RELEASE-NAME - app.kubernetes.io/name: cr-container-registry-agent-snyk-broker + app.kubernetes.io/name: container-registry-agent type: ClusterIP diff --git a/charts/snyk-broker/tests/code_agent_test.yaml b/charts/snyk-broker/tests/code_agent_test.yaml new file mode 100644 index 0000000..4e8f572 --- /dev/null +++ b/charts/snyk-broker/tests/code_agent_test.yaml @@ -0,0 +1,60 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json +suite: code agent +values: + - ./fixtures/default_values.yaml +set: + enableCodeAgent: true +templates: + - code_agent_deployment.yaml + - broker_deployment.yaml +tests: + - it: Renders with default values + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: GIT_CLIENT_URL + value: "http://RELEASE-NAME-code-agent:3000" + template: broker_deployment.yaml + - equal: + path: metadata.name + value: RELEASE-NAME-code-agent + template: code_agent_deployment.yaml + documentSelector: + path: kind + value: Service + - contains: + path: spec.template.spec.containers[0].ports + content: + name: http + containerPort: 3000 + template: code_agent_deployment.yaml + documentSelector: + path: kind + value: Deployment + - contains: + path: spec.template.spec.containers[0].env + content: + name: PORT + value: "3000" + template: code_agent_deployment.yaml + documentSelector: + path: kind + value: Deployment + - it: Renders with suffixes disabled + set: + disableSuffixes: true + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: GIT_CLIENT_URL + value: "http://code-agent:3000" + template: broker_deployment.yaml + - equal: + path: metadata.name + value: code-agent + template: code_agent_deployment.yaml + documentSelector: + path: kind + value: Service diff --git a/charts/snyk-broker/tests/cra_deployment_test.yaml b/charts/snyk-broker/tests/cra_deployment_test.yaml index 460dfd9..5b8540c 100644 --- a/charts/snyk-broker/tests/cra_deployment_test.yaml +++ b/charts/snyk-broker/tests/cra_deployment_test.yaml @@ -15,24 +15,24 @@ tests: - ./fixtures/default_values_cra.yaml asserts: - matchSnapshot: {} - - contains: - path: spec.template.spec.containers[0].env - content: - name: CR_AGENT_URL - value: "http://cra-service-RELEASE-NAME-snyk-broker:8081" - template: - broker_deployment.yaml - equal: path: metadata.name - value: "cra-service-RELEASE-NAME-snyk-broker" + value: &serviceName RELEASE-NAME-container-registry-agent template: cra_deployment.yaml documentSelector: path: kind value: Service + - contains: + path: spec.template.spec.containers[0].env + content: + name: CR_AGENT_URL + value: "http://RELEASE-NAME-container-registry-agent:8081" + template: + broker_deployment.yaml - equal: path: spec.selector["app.kubernetes.io/name"] - value: cr-container-registry-agent-RELEASE-NAME-snyk-broker + value: RELEASE-NAME-container-registry-agent template: cra_deployment.yaml documentSelector: path: kind @@ -62,12 +62,12 @@ tests: path: spec.template.spec.containers[0].env content: name: CR_AGENT_URL - value: "http://cra-service-snyk-broker:8081" + value: "http://container-registry-agent:8081" template: broker_deployment.yaml - equal: path: metadata.name - value: "cra-service-snyk-broker" + value: container-registry-agent template: cra_deployment.yaml documentSelector: @@ -75,7 +75,7 @@ tests: value: Service - equal: path: spec.selector["app.kubernetes.io/name"] - value: cr-container-registry-agent-snyk-broker + value: container-registry-agent template: cra_deployment.yaml documentSelector: path: kind