Browse Source

add back velero form

Alexander Belanger 4 năm trước cách đây
mục cha
commit
756f9283dd
1 tập tin đã thay đổi với 41 bổ sung0 xóa
  1. 41 0
      api/server/handlers/release/get.go

+ 41 - 0
api/server/handlers/release/get.go

@@ -125,6 +125,12 @@ func (c *ReleaseGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 		if res.Release.Chart.Name() == "cert-manager" {
 			formYAML, err := parser.FormYAMLFromBytes(parserDef, []byte(certManagerForm), "", "")
 
+			if err == nil {
+				res.Form = formYAML
+			}
+		} else if res.Release.Chart.Name() == "velero" {
+			formYAML, err := parser.FormYAMLFromBytes(parserDef, []byte(veleroForm), "", "")
+
 			if err == nil {
 				res.Form = formYAML
 			}
@@ -184,3 +190,38 @@ tabs:
           message: [.status.conditions[].message] | unique | join(","),
           data: {}
         }`
+
+const veleroForm string = `tags:
+- hello
+tabs:
+- name: main
+  context:
+    type: cluster
+    config:
+      group: velero.io
+      version: v1
+      resource: backups
+  label: Backups
+  sections:
+  - name: section_one
+    contents: 
+    - type: heading
+      label: 💾 Velero Backups
+    - type: resource-list
+      value: |
+        .items[] | { 
+          name: .metadata.name, 
+          label: .metadata.namespace,
+          status: .status.phase,
+          timestamp: .status.completionTimestamp,
+          message: [
+            (if .status.volumeSnapshotsAttempted then "\(.status.volumeSnapshotsAttempted) volume snapshots attempted, \(.status.volumeSnapshotsCompleted) completed." else null end),
+            "Finished \(.status.completionTimestamp).",
+            "Backup expires on \(.status.expiration)."
+          ]|join(" "),
+          data: {
+            "Included Namespaces": (if .spec.includedNamespaces then .spec.includedNamespaces|join(",") else "* (all)" end),
+            "Included Resources": (if .spec.includedResources then .spec.includedResources|join(",") else "* (all)" end),
+            "Storage Location": .spec.storageLocation
+          }
+        }`