genpolicy: read binaryData value as String

While Kubernetes defines `binaryData` as `[]byte`,
when defined in a YAML file the raw bytes are
base64 encoded. Therefore, we need to read the YAML
value as `String` and not as `Vec<u8>`.

Fixes: #10410

Signed-off-by: Leonard Cohnen <lc@edgeless.systems>
This commit is contained in:
Leonard Cohnen 2024-10-10 15:35:05 +02:00
parent 614e21ccfb
commit c06bf2e3bb
2 changed files with 7 additions and 1 deletions

View File

@ -28,8 +28,10 @@ pub struct ConfigMap {
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<BTreeMap<String, String>>,
// When parsing a YAML file, binaryData is encoded as base64.
// Therefore, this is a BTreeMap<String, String> instead of BTreeMap<String, Vec<u8>>.
#[serde(skip_serializing_if = "Option::is_none")]
pub binaryData: Option<BTreeMap<String, Vec<u8>>>,
pub binaryData: Option<BTreeMap<String, String>>,
#[serde(skip_serializing_if = "Option::is_none")]
immutable: Option<bool>,

View File

@ -11,3 +11,7 @@ data:
data-1: value-1
data-2: value-2
data-3: value-3
binaryData:
bin-data-1: YmluLXZhbHVlLTE=
bin-data-2: YmluLXZhbHVlLTI=
bin-data-3: YmluLXZhbHVlLTM=