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 <sgrunert@redhat.com>
This commit is contained in:
Sascha Grunert 2023-02-09 16:17:09 +01:00
parent 119dc95369
commit 85106dc327
No known key found for this signature in database
GPG Key ID: 09D97D153EF94D93

View File

@ -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 {