mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-05 17:07:20 +00:00
Fix: topology use original resource namespace when not specify (#3554)
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -180,10 +180,7 @@ func (p *provider) ExpandTopology(ctx wfContext.Context, v *value.Value, act wfT
|
||||
return errors.Wrapf(e, "failed to get cluster %s", cluster)
|
||||
}
|
||||
}
|
||||
if ns == "" {
|
||||
ns = p.app.GetNamespace()
|
||||
}
|
||||
if !resourcekeeper.AllowCrossNamespaceResource && ns != p.app.GetNamespace() {
|
||||
if !resourcekeeper.AllowCrossNamespaceResource && (ns != p.app.GetNamespace() && ns != "") {
|
||||
return errors.Errorf("cannot cross namespace")
|
||||
}
|
||||
placement := v1alpha1.PlacementDecision{Cluster: cluster, Namespace: ns}
|
||||
|
||||
@@ -576,7 +576,7 @@ func TestExpandTopology(t *testing.T) {
|
||||
},
|
||||
"topology-by-clusters": {
|
||||
Input: `{inputs:{policies:[{name:"topology-policy",type:"topology",properties:{clusters:["cluster-a"]}}]}}`,
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: "test"}},
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: ""}},
|
||||
},
|
||||
"topology-by-cluster-selector-404": {
|
||||
Input: `{inputs:{policies:[{name:"topology-policy",type:"topology",properties:{clusterSelector:{"key":"bad-value"}}}]}}`,
|
||||
@@ -584,11 +584,11 @@ func TestExpandTopology(t *testing.T) {
|
||||
},
|
||||
"topology-by-cluster-selector": {
|
||||
Input: `{inputs:{policies:[{name:"topology-policy",type:"topology",properties:{clusterSelector:{"key":"value"}}}]}}`,
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: "test"}, {Cluster: "cluster-b", Namespace: "test"}},
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: ""}, {Cluster: "cluster-b", Namespace: ""}},
|
||||
},
|
||||
"topology-by-cluster-label-selector": {
|
||||
Input: `{inputs:{policies:[{name:"topology-policy",type:"topology",properties:{clusterLabelSelector:{"key":"value"}}}]}}`,
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: "test"}, {Cluster: "cluster-b", Namespace: "test"}},
|
||||
Outputs: []v1alpha1.PlacementDecision{{Cluster: "cluster-a", Namespace: ""}, {Cluster: "cluster-b", Namespace: ""}},
|
||||
},
|
||||
"topology-by-cluster-selector-and-namespace-invalid": {
|
||||
Input: `{inputs:{policies:[{name:"topology-policy",type:"topology",properties:{clusterSelector:{"key":"value"},namespace:"override"}}]}}`,
|
||||
|
||||
Reference in New Issue
Block a user