From 85106dc327bf64578d01f9b9d01a1921f23d44b7 Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 9 Feb 2023 16:17:09 +0100 Subject: [PATCH] Allow SSH e2e node base64 key injection With the change of the CRI-O jobs to use butane, we now have a verification for base64 data urls in place. This means that the following URL is invalid: ``` data:text/plain;base64,GCE_SSH_PUBLIC_KEY_FILE_CONTENT ``` This means we have to pass valid base64 to the URL. To fix that, we now allow to inject SSH key values with both, the `GCE_SSH_PUBLIC_KEY_FILE_CONTENT` field and its base64 encoded variant. Signed-off-by: Sascha Grunert --- test/e2e_node/runner/remote/run_remote.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/e2e_node/runner/remote/run_remote.go b/test/e2e_node/runner/remote/run_remote.go index 8e4373e4d18..26872d5b4f1 100644 --- a/test/e2e_node/runner/remote/run_remote.go +++ b/test/e2e_node/runner/remote/run_remote.go @@ -935,12 +935,13 @@ func ignitionInjectGCEPublicKey(path string, content string) string { } const sshPublicKeyFileContentMarker = "GCE_SSH_PUBLIC_KEY_FILE_CONTENT" - return strings.Replace( - content, - sshPublicKeyFileContentMarker, - base64.StdEncoding.EncodeToString(sshPublicKey), - 1, + key := base64.StdEncoding.EncodeToString(sshPublicKey) + base64Marker := base64.StdEncoding.EncodeToString([]byte(sshPublicKeyFileContentMarker)) + replacer := strings.NewReplacer( + sshPublicKeyFileContentMarker, key, + base64Marker, key, ) + return replacer.Replace(content) } func imageToInstanceName(imageConfig *internalGCEImage) string {