mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 20:17:04 +00:00
Fix: fix multi clusters bottom in vela adopt (#5834)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
@@ -90,9 +90,11 @@ import (
|
||||
for key, kinds in resourceCategoryMap if list.Contains(kinds, r.kind) {
|
||||
_category: key
|
||||
},
|
||||
_cluster: r.metadata.annotations["app.oam.dev/cluster"]
|
||||
if r.metadata.annotations != _|_ if r.metadata.annotations["app.oam.dev/cluster"] != _|_ {
|
||||
_cluster: r.metadata.annotations["app.oam.dev/cluster"]
|
||||
}
|
||||
}]
|
||||
_clusters: [ for r in _resources {r._cluster} ]
|
||||
_clusters: [ for r in _resources if r._cluster != _|_ {r._cluster} ]
|
||||
resourceMap: {
|
||||
for key, val in resourceCategoryMap {
|
||||
"\(key)": [ for r in _resources if r._category == key {r}]
|
||||
@@ -114,7 +116,9 @@ import (
|
||||
apiVersion: r.apiVersion
|
||||
kind: r.kind
|
||||
metadata: name: r.metadata.name
|
||||
metadata: annotations: "app.oam.dev/cluster": "\(r._cluster)"
|
||||
if r._cluster != _|_ {
|
||||
metadata: annotations: "app.oam.dev/cluster": (r._cluster)
|
||||
}
|
||||
}]
|
||||
},
|
||||
if len(resourceMap.ns) > 0 {
|
||||
@@ -124,7 +128,9 @@ import (
|
||||
apiVersion: r.apiVersion
|
||||
kind: r.kind
|
||||
metadata: name: r.metadata.name
|
||||
metadata: annotations: "app.oam.dev/cluster": "\(r._cluster)"
|
||||
if r._cluster != _|_ {
|
||||
metadata: annotations: "app.oam.dev/cluster": (r._cluster)
|
||||
}
|
||||
}]
|
||||
},
|
||||
for r in resourceMap.workload + resourceMap.service {
|
||||
@@ -150,7 +156,9 @@ import (
|
||||
if r.metadata.namespace != _|_ {
|
||||
metadata: namespace: r.metadata.namespace
|
||||
}
|
||||
metadata: annotations: "app.oam.dev/cluster": "\(r._cluster)"
|
||||
if r._cluster != _|_ {
|
||||
metadata: annotations: "app.oam.dev/cluster": (r._cluster)
|
||||
}
|
||||
}]
|
||||
},
|
||||
for kind, rs in unknownByKinds {
|
||||
@@ -160,19 +168,21 @@ import (
|
||||
apiVersion: r.apiVersion
|
||||
kind: r.kind
|
||||
metadata: name: r.metadata.name
|
||||
metadata: annotations: "app.oam.dev/cluster": "\(r._cluster)"
|
||||
if r._cluster != _|_ {
|
||||
metadata: annotations: "app.oam.dev/cluster": (r._cluster)
|
||||
}
|
||||
}]
|
||||
},
|
||||
]
|
||||
|
||||
clusterCompMap: {
|
||||
for cluster in _clusters {
|
||||
"\(cluster)": [ for comp in comps if comp.properties.objects[0].metadata.annotations["app.oam.dev/cluster"] == cluster {comp.name} ]
|
||||
"\(cluster)": [ for comp in comps if comp.properties.objects[0].metadata.annotations != _|_ if comp.properties.objects[0].metadata.annotations["app.oam.dev/cluster"] == cluster {comp.name} ]
|
||||
}
|
||||
}
|
||||
|
||||
compClusterMap: {
|
||||
for comp in comps {
|
||||
for comp in comps if comp.properties.objects[0].metadata.annotations != _|_ {
|
||||
"\(comp.name)": comp.properties.objects[0].metadata.annotations["app.oam.dev/cluster"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,9 +288,9 @@ func (opt *AdoptOptions) MultipleRun(f velacmd.Factory, cmd *cobra.Command) erro
|
||||
_, _ = fmt.Fprintf(opt.Out, "Warning: failed to list resources from %s/%s: %s", apiVersion, kind, err.Error())
|
||||
continue
|
||||
}
|
||||
engine := resourcetopology.New(opt.ResourceTopologyRule)
|
||||
dedup := make([]k8s.ResourceIdentifier, 0)
|
||||
for _, item := range list.Items {
|
||||
engine := resourcetopology.New(opt.ResourceTopologyRule)
|
||||
itemIdentifier := k8s.ResourceIdentifier{
|
||||
Name: item.GetName(),
|
||||
Namespace: item.GetNamespace(),
|
||||
|
||||
@@ -58,8 +58,10 @@ commonPeerResources: [{
|
||||
resource: "configMap"
|
||||
selectors: {
|
||||
name: [
|
||||
for v in context.data.spec.template.spec.volumes if v.configMap != _|_ if v.configMap.name != _|_ {
|
||||
v.configMap.name
|
||||
if context.data.spec.template.spec.volumes != _|_ {
|
||||
for v in context.data.spec.template.spec.volumes if v.configMap != _|_ if v.configMap.name != _|_ {
|
||||
v.configMap.name
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -68,8 +70,10 @@ commonPeerResources: [{
|
||||
resource: "secret"
|
||||
selectors: {
|
||||
name: [
|
||||
for v in context.data.spec.template.spec.volumes if v.secret != _|_ if v.secret.name != _|_ {
|
||||
v.secret.name
|
||||
if context.data.spec.template.spec.volumes != _|_ {
|
||||
for v in context.data.spec.template.spec.volumes if v.secret != _|_ if v.secret.name != _|_ {
|
||||
v.secret.name
|
||||
},
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user