Update ephemeral-bmc-secret to use base64 data

Transform stringData into base64-enc data manually so the
annotation won't remain from the stringData.

Closes: #424
Change-Id: I4bcfd57601d9199307c749e8e6deb5ee5445d821
This commit is contained in:
Graham Steffaniak 2021-03-12 13:39:18 -06:00
parent 0d588c83b1
commit 97377236ec
6 changed files with 38 additions and 2 deletions

View File

@ -3,7 +3,6 @@ module opendev.org/airship/airshipctl/functions/cloud-init/image
go 1.14 go 1.14
require ( require (
opendev.org/airship/airshipctl v0.0.0-20210421143147-014e24cd1591
sigs.k8s.io/kustomize/kyaml v0.10.0 sigs.k8s.io/kustomize/kyaml v0.10.0
sigs.k8s.io/kustomize/api v0.7.2 sigs.k8s.io/kustomize/api v0.7.2
) )

View File

@ -0,0 +1,12 @@
apiVersion: builtin
kind: PatchStrategicMergeTransformer
metadata:
name: delete-secret-stringData
patches: |-
---
apiVersion: v1
kind: Secret
metadata:
name: ephemeral-bmc-secret
stringData:
$patch: delete

View File

@ -4,3 +4,5 @@ resources:
- ephemeral-env-vars.yaml - ephemeral-env-vars.yaml
- networking.yaml - networking.yaml
- generated-secrets.yaml - generated-secrets.yaml
- stringData-encode.yaml
- cleanup.yaml

View File

@ -0,0 +1,21 @@
# These rules inject networking info artifacts into the ephemeral function.
apiVersion: airshipit.org/v1alpha1
kind: ReplacementTransformer
metadata:
name: secret-encode
annotations:
config.kubernetes.io/function: |-
container:
image: localhost/replacement-transformer
replacements:
# converts and moves stringData to data field
- source:
objref:
kind: Secret
name: ephemeral-bmc-secret
fieldref: stringData.userData
target:
objref:
name: ephemeral-bmc-secret
kind: Secret
fieldrefs: ["data.userData"]

View File

@ -6,6 +6,8 @@ metadata:
airshipit.org/deploy-k8s: "false" airshipit.org/deploy-k8s: "false"
name: ephemeral-bmc-secret # replacement rules key off this name name: ephemeral-bmc-secret # replacement rules key off this name
type: Opaque type: Opaque
data:
userData: null
stringData: stringData:
# These substrings must be overriden via the `replacements` entrypoint and networking catalogue: # These substrings must be overriden via the `replacements` entrypoint and networking catalogue:
# REPLACEMENT_CP_IP, REPLACEMENT_CP_PORT, REPLACEMENT_CERT_SANS, REPLACEMENT_POD_CIDR # REPLACEMENT_CP_IP, REPLACEMENT_CP_PORT, REPLACEMENT_CERT_SANS, REPLACEMENT_POD_CIDR

View File

@ -37,7 +37,7 @@ func GetSecretDataKey(cfg Document, key string) (string, error) {
if err != nil { if err != nil {
return "", ErrDocumentMalformed{ return "", ErrDocumentMalformed{
DocName: docName, DocName: docName,
Message: "The secret document lacks a data or stringData top level field", Message: "The data or stringData structure is missing or malformed.",
} }
} }
} }