From e0ac42265f2ed827a73b529ef635078b3a97a5ea Mon Sep 17 00:00:00 2001 From: okozachenko1203 Date: Fri, 15 Dec 2023 05:02:14 +1100 Subject: [PATCH] add elements one by one in the json array https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-class/write-clusterclass#json-patches-tips--tricks --- magnum_cluster_api/resources.py | 54 ++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/magnum_cluster_api/resources.py b/magnum_cluster_api/resources.py index 0b3c3566..d6fa106f 100644 --- a/magnum_cluster_api/resources.py +++ b/magnum_cluster_api/resources.py @@ -1610,27 +1610,47 @@ def get_object(self) -> objects.ClusterClass: }, { "op": "add", - "path": "/spec/template/spec/kubeadmConfigSpec/files", + "path": "/spec/template/spec/kubeadmConfigSpec/files/-", "valueFrom": { "template": textwrap.dedent( """\ - - path: "/etc/containerd/config.toml" - owner: "root:root" - permissions: "0644" - content: "{{ .containerdConfig }}" - encoding: "base64" - - path: "/etc/kubernetes/cloud.conf" - owner: "root:root" - permissions: "0600" - content: "{{ .cloudControllerManagerConfig }}" - encoding: "base64" - - path: "/etc/kubernetes/cloud_ca.crt" - owner: "root:root" - permissions: "0600" - content: "{{ .cloudCaCert }}" - encoding: "base64" + path: "/etc/containerd/config.toml" + owner: "root:root" + permissions: "0644" + content: "{{ .containerdConfig }}" + encoding: "base64" """ - ), + ) + }, + }, + { + "op": "add", + "path": "/spec/template/spec/kubeadmConfigSpec/files/-", + "valueFrom": { + "template": textwrap.dedent( + """\ + path: "/etc/kubernetes/cloud.conf" + owner: "root:root" + permissions: "0600" + content: "{{ .cloudControllerManagerConfig }}" + encoding: "base64" + """ + ) + }, + }, + { + "op": "add", + "path": "/spec/template/spec/kubeadmConfigSpec/files/-", + "valueFrom": { + "template": textwrap.dedent( + """\ + path: "/etc/kubernetes/cloud_ca.crt" + owner: "root:root" + permissions: "0600" + content: "{{ .cloudCaCert }}" + encoding: "base64" + """ + ) }, }, ],