mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 03:56:36 +00:00
Feat: add scope label in workflow step defs (#4980)
Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com> Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
@@ -64,6 +64,8 @@ const (
|
||||
LabelDefinitionDeprecated = "custom.definition.oam.dev/deprecated"
|
||||
// LabelDefinitionHidden is the label which describe whether the capability is hidden by UI
|
||||
LabelDefinitionHidden = "custom.definition.oam.dev/ui-hidden"
|
||||
// LabelDefinitionScope is the label which describe whether the capability's scope
|
||||
LabelDefinitionScope = "custom.definition.oam.dev/scope"
|
||||
// LabelNodeRoleGateway gateway role of node
|
||||
LabelNodeRoleGateway = "node-role.kubernetes.io/gateway"
|
||||
// LabelNodeRoleWorker worker role of node
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply components of an application in parallel for your workflow steps
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-application-in-parallel
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply application for your workflow steps, it has no arguments, should be used for custom steps before or after application applied.
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-application
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply remaining components and traits
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-remaining
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Deploy cloud resource and deliver secret to multi clusters.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: deploy-cloud-resource
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: A powerful and unified deploy step for components multi-cluster delivery with policies.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: deploy
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Deploy env binding component to target env
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: deploy2env
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Deploy application to runtime clusters
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: deploy2runtime
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Sync secrets created by terraform component to runtime clusters so that runtime clusters can share the created cloud resource.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: share-cloud-resource
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply components of an application in parallel for your workflow steps
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-application-in-parallel
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply application for your workflow steps, it has no arguments, should be used for custom steps before or after application applied.
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-application
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Apply remaining components and traits
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: apply-remaining
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Deploy cloud resource and deliver secret to multi clusters.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: deploy-cloud-resource
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: A powerful and unified deploy step for components multi-cluster delivery with policies.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: deploy
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -7,6 +7,7 @@ metadata:
|
||||
definition.oam.dev/description: Deploy application to runtime clusters
|
||||
labels:
|
||||
custom.definition.oam.dev/deprecated: "true"
|
||||
custom.definition.oam.dev/scope: Application
|
||||
custom.definition.oam.dev/ui-hidden: "true"
|
||||
name: deploy2runtime
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
|
||||
@@ -5,6 +5,8 @@ kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Sync secrets created by terraform component to runtime clusters so that runtime clusters can share the created cloud resource.
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
name: share-cloud-resource
|
||||
namespace: {{ include "systemDefinitionNamespace" . }}
|
||||
spec:
|
||||
|
||||
@@ -69,6 +69,7 @@ type DefinitionQueryOption struct {
|
||||
AppliedWorkloads string `json:"appliedWorkloads"`
|
||||
OwnerAddon string `json:"sourceAddon"`
|
||||
QueryAll bool `json:"queryAll"`
|
||||
Scope string `json:"scope"`
|
||||
}
|
||||
|
||||
// String return cache key string
|
||||
@@ -109,6 +110,19 @@ func (d *definitionServiceImpl) listDefinitions(ctx context.Context, list *unstr
|
||||
},
|
||||
},
|
||||
}
|
||||
if ops.Scope != "" {
|
||||
var filterScope string
|
||||
if ops.Scope == "Application" {
|
||||
filterScope = "WorkflowRun"
|
||||
} else {
|
||||
filterScope = "Application"
|
||||
}
|
||||
matchLabels.MatchExpressions = append(matchLabels.MatchExpressions, metav1.LabelSelectorRequirement{
|
||||
Key: types.LabelDefinitionScope,
|
||||
Operator: metav1.LabelSelectorOpNotIn,
|
||||
Values: []string{filterScope},
|
||||
})
|
||||
}
|
||||
if !ops.QueryAll {
|
||||
matchLabels.MatchExpressions = append(matchLabels.MatchExpressions, metav1.LabelSelectorRequirement{
|
||||
Key: types.LabelDefinitionHidden,
|
||||
|
||||
@@ -112,6 +112,11 @@ var _ = Describe("Test namespace service functions", func() {
|
||||
Expect(wfstep[0].WorkflowStep.Schematic).ShouldNot(BeNil())
|
||||
Expect(wfstep[0].Alias).Should(Equal("test-alias"))
|
||||
|
||||
wfstep, err = definitionService.ListDefinitions(context.TODO(), DefinitionQueryOption{Type: "workflowstep", Scope: "WorkflowRun"})
|
||||
Expect(err).Should(BeNil())
|
||||
// the definition should be filtered
|
||||
Expect(cmp.Diff(len(wfstep), 1)).Should(BeEmpty())
|
||||
|
||||
step, err = ioutil.ReadFile("./testdata/apply-application-hide.yaml")
|
||||
Expect(err).Should(Succeed())
|
||||
var sd2 v1beta1.WorkflowStepDefinition
|
||||
|
||||
@@ -8,6 +8,8 @@ metadata:
|
||||
definition.oam.dev/alias: test-alias
|
||||
name: apply-application
|
||||
namespace: vela-system
|
||||
labels:
|
||||
custom.definition.oam.dev/scope: Application
|
||||
spec:
|
||||
schematic:
|
||||
cue:
|
||||
|
||||
@@ -51,6 +51,7 @@ func (d *definitionAPIInterface) GetWebServiceRoute() *restful.WebService {
|
||||
Param(ws.QueryParameter("queryAll", "query all definitions include hidden in UI").DataType("boolean").DefaultValue("false")).
|
||||
Param(ws.QueryParameter("appliedWorkload", "if specified, query the trait definition applied to the workload").DataType("string")).
|
||||
Param(ws.QueryParameter("ownerAddon", "query by which addon created the definition").DataType("string")).
|
||||
Param(ws.QueryParameter("scope", "query by the specified scope like WorkflowRun or Application").DataType("string")).
|
||||
Returns(200, "OK", apis.ListDefinitionResponse{}).
|
||||
Writes(apis.ListDefinitionResponse{}).Do(returns200, returns500))
|
||||
|
||||
@@ -97,6 +98,7 @@ func (d *definitionAPIInterface) listDefinitions(req *restful.Request, res *rest
|
||||
Type: req.QueryParameter("type"),
|
||||
AppliedWorkloads: req.QueryParameter("appliedWorkload"),
|
||||
OwnerAddon: req.QueryParameter("ownerAddon"),
|
||||
Scope: req.QueryParameter("scope"),
|
||||
QueryAll: queryAll,
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
labels: {
|
||||
"ui-hidden": "true"
|
||||
"deprecated": "true"
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Apply components of an application in parallel for your workflow steps"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
labels: {
|
||||
"ui-hidden": "true"
|
||||
"deprecated": "true"
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Apply application for your workflow steps, it has no arguments, should be used for custom steps before or after application applied."
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
labels: {
|
||||
"ui-hidden": "true"
|
||||
"deprecated": "true"
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Apply remaining components and traits"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"deploy-cloud-resource": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
labels: {
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Deploy cloud resource and deliver secret to multi clusters."
|
||||
}
|
||||
template: {
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"deploy": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
labels: {
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "A powerful and unified deploy step for components multi-cluster delivery with policies."
|
||||
}
|
||||
template: {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
labels: {
|
||||
"ui-hidden": "true"
|
||||
"deprecated": "true"
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Deploy env binding component to target env"
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
labels: {
|
||||
"ui-hidden": "true"
|
||||
"deprecated": "true"
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Deploy application to runtime clusters"
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
"share-cloud-resource": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
labels: {
|
||||
"scope": "Application"
|
||||
}
|
||||
description: "Sync secrets created by terraform component to runtime clusters so that runtime clusters can share the created cloud resource."
|
||||
}
|
||||
template: {
|
||||
|
||||
Reference in New Issue
Block a user