Feat: apply-component supports namespace (#6248)

This commit is contained in:
JohnJan
2023-08-31 14:08:48 +08:00
committed by GitHub
parent c4f9c8f63f
commit d787e95a08
5 changed files with 15 additions and 4 deletions

View File

@@ -19,5 +19,7 @@ spec:
component: string component: string
// +usage=Specify the cluster // +usage=Specify the cluster
cluster: *"" | string cluster: *"" | string
// +usage=Specify the namespace
namespace: *"" | string
} }

View File

@@ -254,6 +254,7 @@ func convertStepProperties(step *workflowv1alpha1.WorkflowStep, app *v1beta1.App
o := struct { o := struct {
Component string `json:"component"` Component string `json:"component"`
Cluster string `json:"cluster"` Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
}{} }{}
js, err := common.RawExtensionPointer{RawExtension: step.Properties}.MarshalJSON() js, err := common.RawExtensionPointer{RawExtension: step.Properties}.MarshalJSON()
if err != nil { if err != nil {
@@ -293,6 +294,9 @@ func convertStepProperties(step *workflowv1alpha1.WorkflowStep, app *v1beta1.App
"value": c, "value": c,
"cluster": o.Cluster, "cluster": o.Cluster,
} }
if o.Namespace != "" {
stepProperties["namespace"] = o.Namespace
}
step.Properties = util.Object2RawExtension(stepProperties) step.Properties = util.Object2RawExtension(stepProperties)
return nil return nil
} }

View File

@@ -5,8 +5,9 @@ import (
oam: op.oam oam: op.oam
// apply component and traits // apply component and traits
apply: oam.#ApplyComponent & { apply: oam.#ApplyComponent & {
value: parameter.value value: parameter.value
cluster: parameter.cluster cluster: parameter.cluster
namespace: parameter.namespace
} }
if apply.output != _|_ { if apply.output != _|_ {
@@ -18,5 +19,6 @@ if apply.outputs != _|_ {
} }
parameter: { parameter: {
value: {...} value: {...}
cluster: *"" | string cluster: *"" | string
namespace: *"" | string
} }

View File

@@ -24,4 +24,5 @@ spec:
properties: properties:
component: express-server component: express-server
# cluster: <your cluster name> # cluster: <your cluster name>
``` # namespace: <your namespace name>
```

View File

@@ -14,5 +14,7 @@ template: {
component: string component: string
// +usage=Specify the cluster // +usage=Specify the cluster
cluster: *"" | string cluster: *"" | string
// +usage=Specify the namespace
namespace: *"" | string
} }
} }