From a170ea5f9b72631d11130ffead815ec3f3977446 Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Wed, 2 Aug 2023 16:04:09 +0200 Subject: [PATCH 1/3] fix(agent): fix indentation for custom settings --- charts/agent/Chart.yaml | 2 +- .../agent/templates/configmap-deployment.yaml | 4 +- charts/agent/templates/configmap.yaml | 4 +- charts/agent/tests/custom_settings_test.yaml | 101 ++++++++++++++++++ 4 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 charts/agent/tests/custom_settings_test.yaml diff --git a/charts/agent/Chart.yaml b/charts/agent/Chart.yaml index cb6749a63..5b1c238ed 100644 --- a/charts/agent/Chart.yaml +++ b/charts/agent/Chart.yaml @@ -5,7 +5,7 @@ description: Sysdig Monitor and Secure agent type: application # currently matching sysdig 1.14.32 -version: 1.13.0 +version: 1.13.1 appVersion: 12.15.0 diff --git a/charts/agent/templates/configmap-deployment.yaml b/charts/agent/templates/configmap-deployment.yaml index 51b4cbf07..dda0090dc 100644 --- a/charts/agent/templates/configmap-deployment.yaml +++ b/charts/agent/templates/configmap-deployment.yaml @@ -51,8 +51,8 @@ data: {{- $baseSettings := .Values.sysdig.settings -}} {{- $caFilePath := printf "%s%s" "/etc/ca-certs/" (include "sysdig.custom_ca.keyName" (dict "global" .Values.global.ssl "component" .Values.ssl)) }} {{- $mergedSettings := mergeOverwrite $baseSettings (dict "http_proxy" (dict "ca_certificate" $caFilePath)) -}} - {{ toYaml $mergedSettings | indent 4 }} + {{ toYaml $mergedSettings | nindent 4 }} {{- else if .Values.sysdig.settings }} - {{ toYaml .Values.sysdig.settings | indent 4 }} + {{ toYaml .Values.sysdig.settings | nindent 4 }} {{- end }} {{- end }} diff --git a/charts/agent/templates/configmap.yaml b/charts/agent/templates/configmap.yaml index 9947d63df..d02d13ccd 100644 --- a/charts/agent/templates/configmap.yaml +++ b/charts/agent/templates/configmap.yaml @@ -34,9 +34,9 @@ data: {{- $baseSettings := .Values.sysdig.settings -}} {{- $caFilePath := printf "%s%s" "/etc/ca-certs/" (include "sysdig.custom_ca.keyName" (dict "global" .Values.global.ssl "component" .Values.ssl)) }} {{- $mergedSettings := mergeOverwrite $baseSettings (dict "http_proxy" (dict "ca_certificate" $caFilePath)) -}} - {{ toYaml $mergedSettings | indent 4 }} + {{ toYaml $mergedSettings | nindent 4 }} {{- else if .Values.sysdig.settings }} - {{ toYaml .Values.sysdig.settings | indent 4 }} + {{ toYaml .Values.sysdig.settings | nindent 4 }} {{- end }} {{- if .Values.leaderelection.enable }} k8s_delegation_election: true diff --git a/charts/agent/tests/custom_settings_test.yaml b/charts/agent/tests/custom_settings_test.yaml new file mode 100644 index 000000000..24bf25b13 --- /dev/null +++ b/charts/agent/tests/custom_settings_test.yaml @@ -0,0 +1,101 @@ +suite: Testing pre-generated values and best-known edge cases +templates: + - configmap.yaml + - configmap-deployment.yaml +tests: + - it: Testing custom settings + set: + sysdig: + accessKey: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE + settings: + first: + value: 1 + second: example + asserts: + - matchRegex: + path: data['dragent.yaml'] + pattern: |- + .* + first: + value: 1 + second: example + .* + template: configmap.yaml + + - it: Testing custom settings when custom CA is in place + set: + ssl: + ca: + certs: + - | + -----BEGIN CERTIFICATE----- + my-test-cert + -----END CERTIFICATE----- + keyName: "root_ca.crt" + sysdig: + accessKey: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE + settings: + first: + value: 1 + second: example + asserts: + - matchRegex: + path: data['dragent.yaml'] + pattern: |- + .* + first: + value: 1 + second: example + .* + template: configmap.yaml + + + - it: Testing custom settings in deployment + set: + delegatedAgentDeployment: + enabled: true + sysdig: + accessKey: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE + settings: + first: + value: 1 + second: example + asserts: + - matchRegex: + path: data['dragent.yaml'] + pattern: |- + .* + first: + value: 1 + second: example + .* + template: configmap-deployment.yaml + + - it: Testing custom settings in deployment when custom CA is in place + set: + delegatedAgentDeployment: + enabled: true + ssl: + ca: + certs: + - | + -----BEGIN CERTIFICATE----- + my-test-cert + -----END CERTIFICATE----- + keyName: "root_ca.crt" + sysdig: + accessKey: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE + settings: + first: + value: 1 + second: example + asserts: + - matchRegex: + path: data['dragent.yaml'] + pattern: |- + .* + first: + value: 1 + second: example + .* + template: configmap-deployment.yaml \ No newline at end of file From dcd58e6c0359bfb534ebb5965a8338802876928f Mon Sep 17 00:00:00 2001 From: Adam Roberts Date: Wed, 2 Aug 2023 10:34:03 -0400 Subject: [PATCH 2/3] fix(agent): add newline to custom_settings_test.yaml --- charts/agent/tests/custom_settings_test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/agent/tests/custom_settings_test.yaml b/charts/agent/tests/custom_settings_test.yaml index 24bf25b13..bf300381f 100644 --- a/charts/agent/tests/custom_settings_test.yaml +++ b/charts/agent/tests/custom_settings_test.yaml @@ -98,4 +98,4 @@ tests: value: 1 second: example .* - template: configmap-deployment.yaml \ No newline at end of file + template: configmap-deployment.yaml From 111b638025911e4794b6757e31cbc2cbb55f0e5d Mon Sep 17 00:00:00 2001 From: Adam Roberts Date: Wed, 2 Aug 2023 10:37:01 -0400 Subject: [PATCH 3/3] fix(agent): remove trailing whitespaces from custom_settings_test.yaml --- charts/agent/tests/custom_settings_test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/charts/agent/tests/custom_settings_test.yaml b/charts/agent/tests/custom_settings_test.yaml index bf300381f..a909f8933 100644 --- a/charts/agent/tests/custom_settings_test.yaml +++ b/charts/agent/tests/custom_settings_test.yaml @@ -49,8 +49,7 @@ tests: .* template: configmap.yaml - - - it: Testing custom settings in deployment + - it: Testing custom settings in deployment set: delegatedAgentDeployment: enabled: true