From b53f4f4fdd0ed36e1b905fc6cdd89cd3e7565c97 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Oct 2021 10:08:29 +0800 Subject: [PATCH] Feat: add cluster in read or apply object (#2560) (cherry picked from commit 5dbd8c87655ca1e1885fa28beff99d2cfd5e5a5c) Co-authored-by: FogDong --- .../defwithtemplate/apply-object.yaml | 10 +++++-- .../defwithtemplate/read-object.yaml | 4 +++ .../defwithtemplate/apply-object.yaml | 10 +++++-- .../defwithtemplate/read-object.yaml | 4 +++ docs/examples/workflow/apply-object/app.yaml | 27 ++++++++++--------- docs/examples/workflow/read-object/app.yaml | 2 ++ .../definitions/internal/apply-object.cue | 10 +++++-- .../definitions/internal/read-object.cue | 4 +++ 8 files changed, 53 insertions(+), 18 deletions(-) diff --git a/charts/vela-core/templates/defwithtemplate/apply-object.yaml b/charts/vela-core/templates/defwithtemplate/apply-object.yaml index 21249f4e3..74ead0a6a 100644 --- a/charts/vela-core/templates/defwithtemplate/apply-object.yaml +++ b/charts/vela-core/templates/defwithtemplate/apply-object.yaml @@ -16,7 +16,13 @@ spec: ) apply: op.#Apply & { - value: parameter + value: parameter.value + cluster: parameter.cluster + } + parameter: { + // +usage=Specify the value of the object + value: {...} + // +usage=Specify the cluster of the object + cluster: *"" | string } - parameter: {} diff --git a/charts/vela-core/templates/defwithtemplate/read-object.yaml b/charts/vela-core/templates/defwithtemplate/read-object.yaml index b170b18a0..95fdad2ab 100644 --- a/charts/vela-core/templates/defwithtemplate/read-object.yaml +++ b/charts/vela-core/templates/defwithtemplate/read-object.yaml @@ -28,6 +28,7 @@ spec: } } } + cluster: parameter.cluster } } if parameter.apiVersion != _|_ || parameter.kind != _|_ { @@ -42,6 +43,7 @@ spec: } } } + cluster: parameter.cluster } } } @@ -54,5 +56,7 @@ spec: name: string // +usage=Specify the namespace of the object namespace?: string + // +usage=Specify the cluster of the object + cluster: *"" | string } diff --git a/charts/vela-minimal/templates/defwithtemplate/apply-object.yaml b/charts/vela-minimal/templates/defwithtemplate/apply-object.yaml index 21249f4e3..74ead0a6a 100644 --- a/charts/vela-minimal/templates/defwithtemplate/apply-object.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/apply-object.yaml @@ -16,7 +16,13 @@ spec: ) apply: op.#Apply & { - value: parameter + value: parameter.value + cluster: parameter.cluster + } + parameter: { + // +usage=Specify the value of the object + value: {...} + // +usage=Specify the cluster of the object + cluster: *"" | string } - parameter: {} diff --git a/charts/vela-minimal/templates/defwithtemplate/read-object.yaml b/charts/vela-minimal/templates/defwithtemplate/read-object.yaml index b170b18a0..95fdad2ab 100644 --- a/charts/vela-minimal/templates/defwithtemplate/read-object.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/read-object.yaml @@ -28,6 +28,7 @@ spec: } } } + cluster: parameter.cluster } } if parameter.apiVersion != _|_ || parameter.kind != _|_ { @@ -42,6 +43,7 @@ spec: } } } + cluster: parameter.cluster } } } @@ -54,5 +56,7 @@ spec: name: string // +usage=Specify the namespace of the object namespace?: string + // +usage=Specify the cluster of the object + cluster: *"" | string } diff --git a/docs/examples/workflow/apply-object/app.yaml b/docs/examples/workflow/apply-object/app.yaml index 172c740d8..c5a9d3446 100644 --- a/docs/examples/workflow/apply-object/app.yaml +++ b/docs/examples/workflow/apply-object/app.yaml @@ -21,18 +21,21 @@ spec: - name: apply-pvc type: apply-object properties: - apiVersion: v1 - kind: PersistentVolumeClaim - metadata: - name: myclaim - namespace: default - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 8Gi - storageClassName: standard + value: + apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: myclaim + namespace: default + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: standard + # for multi-cluster + # cluster: my-cluster - name: apply-server type: apply-component properties: diff --git a/docs/examples/workflow/read-object/app.yaml b/docs/examples/workflow/read-object/app.yaml index e3cfc1884..23da7458f 100644 --- a/docs/examples/workflow/read-object/app.yaml +++ b/docs/examples/workflow/read-object/app.yaml @@ -23,6 +23,8 @@ spec: apiVersion: v1 kind: ConfigMap name: my-cm-name + # for multi cluster + # cluster: my-cluster - name: apply type: apply-component inputs: diff --git a/vela-templates/definitions/internal/apply-object.cue b/vela-templates/definitions/internal/apply-object.cue index edb29984d..4ec79713f 100644 --- a/vela-templates/definitions/internal/apply-object.cue +++ b/vela-templates/definitions/internal/apply-object.cue @@ -10,7 +10,13 @@ import ( } template: { apply: op.#Apply & { - value: parameter + value: parameter.value + cluster: parameter.cluster + } + parameter: { + // +usage=Specify the value of the object + value: {...} + // +usage=Specify the cluster of the object + cluster: *"" | string } - parameter: {} } diff --git a/vela-templates/definitions/internal/read-object.cue b/vela-templates/definitions/internal/read-object.cue index 58b33d581..a8e8d594e 100644 --- a/vela-templates/definitions/internal/read-object.cue +++ b/vela-templates/definitions/internal/read-object.cue @@ -22,6 +22,7 @@ template: { } } } + cluster: parameter.cluster } } if parameter.apiVersion != _|_ || parameter.kind != _|_ { @@ -36,6 +37,7 @@ template: { } } } + cluster: parameter.cluster } } } @@ -48,5 +50,7 @@ template: { name: string // +usage=Specify the namespace of the object namespace?: string + // +usage=Specify the cluster of the object + cluster: *"" | string } }