From 2e601fb1f100f65071dd976481c5e46cf0e06e06 Mon Sep 17 00:00:00 2001 From: Eddy Moulton Date: Fri, 12 Dec 2025 16:42:31 +1100 Subject: [PATCH 1/2] Fix bash report kubernetes manifests functions --- .../Features/Scripting/Bash/Bootstrap.sh | 18 ++++++++++++++---- .../Fixtures/Bash/BashFixture.cs | 16 ++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh b/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh index 3a6ac85be1..e622ef6d24 100644 --- a/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh +++ b/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh @@ -15,6 +15,16 @@ function encode_servicemessagevalue echo -n "$1" | openssl enc -base64 -A } +# ----------------------------------------------------------------------------- +# Function to base64 encode a service message value +# Accepts 1 argument: +# string: the value to encode +# ----------------------------------------------------------------------------- +function encode_unescaped_servicemessagevalue +{ + echo -ne "$1" | openssl enc -base64 -A +} + # ----------------------------------------------------------------------------- # Function to base64 decode a service message value # Accepts 1 argument: @@ -337,9 +347,9 @@ function report_kubernetes_manifest for mf in "${MANIFESTS[@]}"; do if [ -z "$mf" ]; then continue - fi - - MESSAGE="##octopus[k8s-manifest-applied manifest='$(encode_servicemessagevalue "$mf")'" + fi + + MESSAGE="##octopus[k8s-manifest-applied manifest='$(encode_unescaped_servicemessagevalue "$mf")'" if [ -n "$NAMESPACE" ]; then MESSAGE="$MESSAGE ns='$(encode_servicemessagevalue "$NAMESPACE")'" @@ -347,7 +357,7 @@ function report_kubernetes_manifest MESSAGE="$MESSAGE]" - echo "$MESSAGE" + echo "$MESSAGE" done } diff --git a/source/Calamari.Tests/Fixtures/Bash/BashFixture.cs b/source/Calamari.Tests/Fixtures/Bash/BashFixture.cs index 938e3096d0..3d2f435ab6 100644 --- a/source/Calamari.Tests/Fixtures/Bash/BashFixture.cs +++ b/source/Calamari.Tests/Fixtures/Bash/BashFixture.cs @@ -89,10 +89,10 @@ public void ShouldReportKubernetesManifest() Assert.Multiple(() => { output.AssertSuccess(); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJleGFtcGxlIlxuImxhYmVscyI6XG4gICAgIm5hbWUiOiAiZXhhbXBsZSJcbg==']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJkaWZmcyJcbiJsYWJlbHMiOlxuICAgICJuYW1lIjogImRpZmZzIlxu']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJleGFtcGxlIlxuImxhYmVscyI6XG4gICAgIm5hbWUiOiAiZXhhbXBsZSJcbg==' ns='bXk=']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJkaWZmcyJcbiJsYWJlbHMiOlxuICAgICJuYW1lIjogImRpZmZzIlxu' ns='bXk=']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJleGFtcGxlIg0KImxhYmVscyI6DQogICAgIm5hbWUiOiAiZXhhbXBsZSINCg==']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJkaWZmcyINCiJsYWJlbHMiOg0KICAgICJuYW1lIjogImRpZmZzIg==']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJleGFtcGxlIg0KImxhYmVscyI6DQogICAgIm5hbWUiOiAiZXhhbXBsZSINCg==' ns='bXk=']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJkaWZmcyINCiJsYWJlbHMiOg0KICAgICJuYW1lIjogImRpZmZzIg==' ns='bXk=']"); }); } @@ -149,10 +149,10 @@ public void ShouldReportKubernetesManifestFile() Assert.Multiple(() => { output.AssertSuccess(); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJleGFtcGxlIlxuImxhYmVscyI6XG4gICAgIm5hbWUiOiAiZXhhbXBsZSJcbg==']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJkaWZmcyJcbiJsYWJlbHMiOlxuICAgICJuYW1lIjogImRpZmZzIlxu']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJleGFtcGxlIlxuImxhYmVscyI6XG4gICAgIm5hbWUiOiAiZXhhbXBsZSJcbg==' ns='bXk=']"); - output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiXG4ia2luZCI6ICJOYW1lc3BhY2UiXG4ibWV0YWRhdGEiOlxuICAibmFtZSI6ICJkaWZmcyJcbiJsYWJlbHMiOlxuICAgICJuYW1lIjogImRpZmZzIlxu' ns='bXk=']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJleGFtcGxlIg0KImxhYmVscyI6DQogICAgIm5hbWUiOiAiZXhhbXBsZSINCg==']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJkaWZmcyINCiJsYWJlbHMiOg0KICAgICJuYW1lIjogImRpZmZzIg==']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJleGFtcGxlIg0KImxhYmVscyI6DQogICAgIm5hbWUiOiAiZXhhbXBsZSINCg==' ns='bXk=']"); + output.AssertOutput("##octopus[k8s-manifest-applied manifest='ImFwaVZlcnNpb24iOiAidjEiDQoia2luZCI6ICJOYW1lc3BhY2UiDQoibWV0YWRhdGEiOg0KICAibmFtZSI6ICJkaWZmcyINCiJsYWJlbHMiOg0KICAgICJuYW1lIjogImRpZmZzIg==' ns='bXk=']"); }); } finally From 8a0989b8167f0cb629922d56499d4e1dea3faa46 Mon Sep 17 00:00:00 2001 From: Eddy Moulton Date: Mon, 15 Dec 2025 10:08:44 +1100 Subject: [PATCH 2/2] Comment --- source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh b/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh index e622ef6d24..2e91ff1b2c 100644 --- a/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh +++ b/source/Calamari.Common/Features/Scripting/Bash/Bootstrap.sh @@ -16,7 +16,7 @@ function encode_servicemessagevalue } # ----------------------------------------------------------------------------- -# Function to base64 encode a service message value +# Function to base64 encode a service message value without escaping the value # Accepts 1 argument: # string: the value to encode # -----------------------------------------------------------------------------