From 39338dd6ac6d3e44fb986b3d217ac6486c1bcfe677ff53660d9ca2262ecb9904 Mon Sep 17 00:00:00 2001
From: Steven Hardy <steven.hardy@suse.com>
Date: Thu, 5 Dec 2024 11:31:40 +0000
Subject: [PATCH] rancher-turtles-chart: Update to 0.14.1 upstream release

Aligns with https://github.com/suse-edge/charts/pull/174 which
rebases to 0.14.1, which is marked as compatible with Rancher 2.10

(cherry picked from commit 7721c66ab0b2eae8aefbca8bdb7e2fd82cda1363a2b115ba715a8164589bfafe)
---
 rancher-turtles-chart/Chart.lock              |   2 +-
 rancher-turtles-chart/Chart.yaml              |  10 +-
 ...er-turtles-exp-etcdrestore-components.yaml | 147 ++++++++----------
 rancher-turtles-chart/values.yaml             |  16 +-
 4 files changed, 82 insertions(+), 93 deletions(-)

diff --git a/rancher-turtles-chart/Chart.lock b/rancher-turtles-chart/Chart.lock
index 1609e64..be85685 100644
--- a/rancher-turtles-chart/Chart.lock
+++ b/rancher-turtles-chart/Chart.lock
@@ -3,4 +3,4 @@ dependencies:
   repository: https://kubernetes-sigs.github.io/cluster-api-operator
   version: 0.14.0
 digest: sha256:9e9e851dbab3212c279efec06bcf0da147228ea1590470f3a8cbbb5806a250d4
-generated: "2024-10-28T11:44:34.392387979Z"
+generated: "2024-12-03T09:34:12.871417074Z"
diff --git a/rancher-turtles-chart/Chart.yaml b/rancher-turtles-chart/Chart.yaml
index fe8edfc..4a806fd 100644
--- a/rancher-turtles-chart/Chart.yaml
+++ b/rancher-turtles-chart/Chart.yaml
@@ -1,5 +1,5 @@
-#!BuildTag: %%IMG_PREFIX%%rancher-turtles-chart:%%CHART_MAJOR%%.0.0_up0.13.0
-#!BuildTag: %%IMG_PREFIX%%rancher-turtles-chart:%%CHART_MAJOR%%.0.0_up0.13.0-%RELEASE%
+#!BuildTag: %%IMG_PREFIX%%rancher-turtles-chart:%%CHART_MAJOR%%.0.0_up0.14.1
+#!BuildTag: %%IMG_PREFIX%%rancher-turtles-chart:%%CHART_MAJOR%%.0.0_up0.14.1-%RELEASE%
 annotations:
   catalog.cattle.io/certified: rancher
   catalog.cattle.io/display-name: Rancher Turtles - the Cluster API Extension
@@ -7,12 +7,12 @@ annotations:
   catalog.cattle.io/namespace: rancher-turtles-system
   catalog.cattle.io/os: linux
   catalog.cattle.io/permits-os: linux
-  catalog.cattle.io/rancher-version: '>= 2.9.0-1'
+  catalog.cattle.io/rancher-version: '>= 2.10.0-1'
   catalog.cattle.io/release-name: rancher-turtles
   catalog.cattle.io/scope: management
   catalog.cattle.io/type: cluster-tool
 apiVersion: v2
-appVersion: 0.13.0
+appVersion: 0.14.1
 dependencies:
 - condition: cluster-api-operator.enabled
   name: cluster-api-operator
@@ -29,4 +29,4 @@ keywords:
 - provisioning
 name: rancher-turtles
 type: application
-version: "%%CHART_MAJOR%%.0.0+up0.13.0"
+version: "%%CHART_MAJOR%%.0.0+up0.14.1"
diff --git a/rancher-turtles-chart/templates/rancher-turtles-exp-etcdrestore-components.yaml b/rancher-turtles-chart/templates/rancher-turtles-exp-etcdrestore-components.yaml
index 3b39284..d305dca 100644
--- a/rancher-turtles-chart/templates/rancher-turtles-exp-etcdrestore-components.yaml
+++ b/rancher-turtles-chart/templates/rancher-turtles-exp-etcdrestore-components.yaml
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
 metadata:
   annotations:
-    cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert
+    cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert
     controller-gen.kubebuilder.io/version: v0.14.0
   labels:
     turtles-capi.cattle.io: etcd-restore
@@ -45,77 +45,65 @@ spec:
             properties:
               clusterName:
                 type: string
-              configRef:
-                type: string
               location:
                 type: string
               machineName:
                 type: string
             required:
             - clusterName
-            - configRef
-            - location
-            - machineName
             type: object
             x-kubernetes-validations:
             - message: ETCD snapshot location can't be empty.
-              rule: size(self.location)>0
+              rule: size(self.clusterName)>0
           status:
             default: {}
             description: EtcdSnapshotRestoreStatus defines observed state of EtcdSnapshotRestore
             properties:
-              conditions:
-                description: Conditions provide observations of the operational state
-                  of a Cluster API resource.
-                items:
-                  description: Condition defines an observation of a Cluster API resource
-                    operational state.
-                  properties:
-                    lastTransitionTime:
-                      description: |-
-                        Last time the condition transitioned from one status to another.
-                        This should be when the underlying condition changed. If that is not known, then using the time when
-                        the API field changed is acceptable.
-                      format: date-time
-                      type: string
-                    message:
-                      description: |-
-                        A human readable message indicating details about the transition.
-                        This field may be empty.
-                      type: string
-                    reason:
-                      description: |-
-                        The reason for the condition's last transition in CamelCase.
-                        The specific API may choose whether or not this field is considered a guaranteed API.
-                        This field may not be empty.
-                      type: string
-                    severity:
-                      description: |-
-                        Severity provides an explicit classification of Reason code, so the users or machines can immediately
-                        understand the current situation and act accordingly.
-                        The Severity field MUST be set only when Status=False.
-                      type: string
-                    status:
-                      description: Status of the condition, one of True, False, Unknown.
-                      type: string
-                    type:
-                      description: |-
-                        Type of condition in CamelCase or in foo.example.com/CamelCase.
-                        Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
-                        can be useful (see .node.status.conditions), the ability to deconflict is important.
-                      type: string
-                  required:
-                  - lastTransitionTime
-                  - status
-                  - type
-                  type: object
-                type: array
-              manual:
-                type: boolean
+              error:
+                type: string
               phase:
                 description: ETCDSnapshotPhase is a string representation of the phase
                   of the etcd snapshot
                 type: string
+              s3Snapshots:
+                items:
+                  properties:
+                    creationTime:
+                      description: CreationTime is the timestamp when the snapshot
+                        was taken by etcd.
+                      format: date-time
+                      type: string
+                    location:
+                      type: string
+                    name:
+                      type: string
+                  required:
+                  - location
+                  - name
+                  type: object
+                type: array
+              snapshotFileName:
+                type: string
+              snapshots:
+                items:
+                  properties:
+                    creationTime:
+                      description: CreationTime is the timestamp when the snapshot
+                        was taken by etcd.
+                      format: date-time
+                      type: string
+                    location:
+                      type: string
+                    machineName:
+                      type: string
+                    name:
+                      type: string
+                  required:
+                  - location
+                  - machineName
+                  - name
+                  type: object
+                type: array
             type: object
         type: object
     served: true
@@ -127,7 +115,7 @@ apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
 metadata:
   annotations:
-    cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert
+    cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert
     controller-gen.kubebuilder.io/version: v0.14.0
   labels:
     turtles-capi.cattle.io: etcd-restore
@@ -246,7 +234,7 @@ apiVersion: apiextensions.k8s.io/v1
 kind: CustomResourceDefinition
 metadata:
   annotations:
-    cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert
+    cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert
     controller-gen.kubebuilder.io/version: v0.14.0
   labels:
     turtles-capi.cattle.io: etcd-restore
@@ -306,8 +294,6 @@ spec:
                     type: string
                   insecure:
                     type: boolean
-                  location:
-                    type: string
                   region:
                     type: string
                   s3CredentialSecret:
@@ -337,7 +323,7 @@ metadata:
     app.kubernetes.io/part-of: rancher-turtles
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-manager
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 ---
 apiVersion: rbac.authorization.k8s.io/v1
 kind: Role
@@ -351,7 +337,7 @@ metadata:
     app.kubernetes.io/part-of: rancher-turtles
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-leader-election-role
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 rules:
 - apiGroups:
   - ""
@@ -600,7 +586,7 @@ metadata:
     app.kubernetes.io/part-of: rancher-turtles
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-leader-election-rolebinding
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: Role
@@ -608,7 +594,7 @@ roleRef:
 subjects:
 - kind: ServiceAccount
   name: rancher-turtles-etcdsnapshotrestore-manager
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 ---
 apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRoleBinding
@@ -629,7 +615,7 @@ roleRef:
 subjects:
 - kind: ServiceAccount
   name: rancher-turtles-etcdsnapshotrestore-manager
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 ---
 apiVersion: v1
 kind: Service
@@ -637,7 +623,7 @@ metadata:
   labels:
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-webhook-service
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 spec:
   ports:
   - port: 443
@@ -652,7 +638,7 @@ metadata:
     control-plane: controller-manager
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-controller-manager
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 spec:
   replicas: 1
   selector:
@@ -671,7 +657,7 @@ spec:
       - args:
         - --leader-elect
         command:
-        - /manager
+        - ./etcd-snapshot-restore
         env:
         - name: POD_NAMESPACE
           valueFrom:
@@ -685,8 +671,13 @@ spec:
           valueFrom:
             fieldRef:
               fieldPath: metadata.uid
-        image: ghcr.io/rancher/turtles-etcd-snapshot-restore:dev
-        imagePullPolicy: IfNotPresent
+        {{- $imageVersion := index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" -}}
+        {{- if contains "sha256:" $imageVersion }}
+        image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}@{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }}
+        {{- else }}
+        image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}:{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }}
+        {{- end }}
+        imagePullPolicy: '{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imagePullPolicy" }}'
         livenessProbe:
           httpGet:
             path: /healthz
@@ -733,11 +724,11 @@ metadata:
   labels:
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-serving-cert
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 spec:
   dnsNames:
-  - rancher-turtles-etcdsnapshotrestore-webhook-service.rancher-turtles-system.svc
-  - rancher-turtles-etcdsnapshotrestore-webhook-service.rancher-turtles-system.svc.cluster.local
+  - rancher-turtles-etcdsnapshotrestore-webhook-service.{{ index .Values "rancherTurtles" "namespace" }}.svc
+  - rancher-turtles-etcdsnapshotrestore-webhook-service.{{ index .Values "rancherTurtles" "namespace" }}.svc.cluster.local
   issuerRef:
     kind: Issuer
     name: rancher-turtles-etcdsnapshotrestore-selfsigned-issuer
@@ -749,7 +740,7 @@ metadata:
   labels:
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-selfsigned-issuer
-  namespace: rancher-turtles-system
+  namespace: {{ index .Values "rancherTurtles" "namespace" }}
 spec:
   selfSigned: {}
 ---
@@ -757,7 +748,7 @@ apiVersion: admissionregistration.k8s.io/v1
 kind: MutatingWebhookConfiguration
 metadata:
   annotations:
-    cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert
+    cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert
   labels:
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-mutating-webhook-configuration
@@ -767,7 +758,7 @@ webhooks:
   clientConfig:
     service:
       name: rancher-turtles-etcdsnapshotrestore-webhook-service
-      namespace: rancher-turtles-system
+      namespace: {{ index .Values "rancherTurtles" "namespace" }}
       path: /mutate-bootstrap-cluster-x-k8s-io-v1beta1-rke2config
   failurePolicy: Fail
   name: systemagentrke2config.kb.io
@@ -787,7 +778,7 @@ apiVersion: admissionregistration.k8s.io/v1
 kind: ValidatingWebhookConfiguration
 metadata:
   annotations:
-    cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert
+    cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert
   labels:
     turtles-capi.cattle.io: etcd-restore
   name: rancher-turtles-etcdsnapshotrestore-validating-webhook-configuration
@@ -797,7 +788,7 @@ webhooks:
   clientConfig:
     service:
       name: rancher-turtles-etcdsnapshotrestore-webhook-service
-      namespace: rancher-turtles-system
+      namespace: {{ index .Values "rancherTurtles" "namespace" }}
       path: /validate-turtles-capi-cattle-io-v1alpha1-etcdmachinesnapshot
   failurePolicy: Fail
   matchPolicy: Equivalent
@@ -818,7 +809,7 @@ webhooks:
   clientConfig:
     service:
       name: rancher-turtles-etcdsnapshotrestore-webhook-service
-      namespace: rancher-turtles-system
+      namespace: {{ index .Values "rancherTurtles" "namespace" }}
       path: /validate-turtles-capi-cattle-io-v1alpha1-etcdsnapshotrestore
   failurePolicy: Fail
   matchPolicy: Equivalent
diff --git a/rancher-turtles-chart/values.yaml b/rancher-turtles-chart/values.yaml
index 92db701..cd93abd 100644
--- a/rancher-turtles-chart/values.yaml
+++ b/rancher-turtles-chart/values.yaml
@@ -1,6 +1,6 @@
 rancherTurtles:
   image: registry.rancher.com/rancher/rancher/turtles
-  imageVersion: v0.13.0
+  imageVersion: v0.14.1
   imagePullPolicy: IfNotPresent
   namespace: rancher-turtles-system
   managerArguments: []
@@ -25,6 +25,9 @@ rancherTurtles:
       enabled: false
     etcd-snapshot-restore:
       enabled: false
+      image: registry.rancher.com/rancher/rancher/turtles
+      imageVersion: v0.14.1
+      imagePullPolicy: IfNotPresent
     addon-provider-fleet:
       enabled: false
 cluster-api-operator:
@@ -52,40 +55,35 @@ cluster-api-operator:
         readOnly: true
   cluster-api:
     enabled: true
-    version: "v1.7.7"
     configSecret:
       name: ""
       defaultName: capi-env-variables
     core:
       namespace: capi-system
-      imageUrl: "registry.rancher.com/rancher/cluster-api-controller:v1.7.7"
       fetchConfig:
         url: ""
         selector: ""
     rke2:
       enabled: true
-      version: "v0.8.0"
       bootstrap:
         namespace: rke2-bootstrap-system
-        imageUrl: "registry.rancher.com/rancher/cluster-api-provider-rke2-bootstrap:v0.8.0"
         fetchConfig:
           url: ""
           selector: ""
       controlPlane:
         namespace: rke2-control-plane-system
-        imageUrl: "registry.rancher.com/rancher/cluster-api-provider-rke2-controlplane:v0.8.0"
         fetchConfig:
           url: ""
           selector: ""
     metal3:
       enabled: true
-      version: "v1.7.2"
+      version: "v1.8.2"
       infrastructure:
         namespace: capm3-system
-        imageUrl: "%%IMG_REPO%%/%%IMG_PREFIX%%cluster-api-provider-metal3:1.7.2"
+        imageUrl: "registry.rancher.com/rancher/cluster-api-metal3-controller:v1.8.2"
         fetchConfig:
           url: ""
           selector: ""
       ipam:
         namespace: capm3-system
-        imageUrl: "%%IMG_REPO%%/%%IMG_PREFIX%%ip-address-manager:1.7.2"
+        imageUrl: "registry.rancher.com/rancher/cluster-api-metal3-ipam-controller:v1.8.1"