Feat: apply-component supports namespace (#6228)

* Feat: apply-component supports namespace

Signed-off-by: wuzhongjian <wuzhongjian_yewu@cmss.chinamobile.com>

* Feat: apply-component supports namespace

Signed-off-by: wuzhongjian <wuzhongjian_yewu@cmss.chinamobile.com>

---------

Signed-off-by: wuzhongjian <wuzhongjian_yewu@cmss.chinamobile.com>
This commit is contained in:
JohnJan
2023-07-25 10:31:18 +08:00
committed by GitHub
parent ef8b0ac00f
commit f0357fdc8f
5 changed files with 18 additions and 6 deletions
@@ -252,6 +252,7 @@ func convertStepProperties(step *workflowv1alpha1.WorkflowStep, app *v1beta1.App
o := struct {
Component string `json:"component"`
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
}{}
js, err := common.RawExtensionPointer{RawExtension: step.Properties}.MarshalJSON()
if err != nil {
@@ -260,6 +261,9 @@ func convertStepProperties(step *workflowv1alpha1.WorkflowStep, app *v1beta1.App
if err := json.Unmarshal(js, &o); err != nil {
return err
}
if len(o.Namespace) == 0 {
o.Namespace = app.Namespace
}
var componentNames []string
for _, c := range app.Spec.Components {
@@ -288,8 +292,9 @@ func convertStepProperties(step *workflowv1alpha1.WorkflowStep, app *v1beta1.App
c.Outputs = nil
c.DependsOn = nil
stepProperties := map[string]interface{}{
"value": c,
"cluster": o.Cluster,
"value": c,
"cluster": o.Cluster,
"namespace": o.Namespace,
}
step.Properties = util.Object2RawExtension(stepProperties)
return nil