Feat: Semantic versioning support for Definitions (#6648)
Some checks failed
CodeQL / Analyze (go) (push) Failing after 1m43s
Definition-Lint / definition-doc (push) Failing after 6m13s
E2E MultiCluster Test / detect-noop (push) Successful in 24s
E2E Test / detect-noop (push) Successful in 17s
Go / detect-noop (push) Successful in 21s
license / Check for unapproved licenses (push) Failing after 2m38s
Registry / publish-core-images (push) Failing after 40s
Unit-Test / detect-noop (push) Successful in 20s
E2E MultiCluster Test / e2e-multi-cluster-tests (v1.29) (push) Failing after 1m55s
E2E Test / e2e-tests (v1.29) (push) Failing after 1m18s
Go / staticcheck (push) Successful in 18m35s
Go / lint (push) Failing after 19m38s
Go / check-diff (push) Failing after 15m7s
Go / check-core-image-build (push) Failing after 3m45s
Go / check-cli-image-build (push) Failing after 2m23s
Unit-Test / unit-tests (push) Failing after 12m43s
Go / check-windows (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Failing after 48s

* feature: Add Semantic versioning to KubeVela Definitions

Fixes https://github.com/kubevela/kubevela/issues/6435
Fixes https://github.com/kubevela/kubevela/issues/6534

Changes:
- Adds an optional "Version" field for all Definition Specs.
- Adds the following new validations to Webhooks for Definitions:
	- Validate the "Version" field follows Semantic versioning.
	- Dis-allow conflicting versioning fields ( Name annotation, Spec.Version)
- Adds the following new validations to Webhooks for Application:
	- Dis-allow the use of both the "publishVersion" & "autoUpdate" annotations.
- Enahnce "multiStageComponentApply" feature to support auto updates.

Boy Scout Changes:
- Fixes Plugin e2e tests broken by the fix for 6534.
- Fixes the dryRun and livediff commands to respect the "-n" namespace flag.
- Fixes the Application ValidationWebhook to respect the "-n" namespace flag.

Co-authored-by: Rahul Kumar <35751394+bugbounce@users.noreply.github.com>
Co-authored-by: Chaitanya Reddy <chaitanyareddy0702@gmail.com>
Co-authored-by: Vibhor Chinda <vibhorchinda@gmail.com>
Co-authored-by: Shivin Gopalani <gopalanishivin@gmail.com>

Signed-off-by: kanchan-dhamane <74534570+kanchan-dhamane@users.noreply.github.com>

* feature: Add KEP to define the proposal

Signed-off-by: kanchan-dhamane <74534570+kanchan-dhamane@users.noreply.github.com>

* fix: Rebase and fix merge conflicts

Signed-off-by: kanchan-dhamane <74534570+kanchan-dhamane@users.noreply.github.com>

* Fix: Adds unit test cases

Signed-off-by: kanchan-dhamane <74534570+kanchan-dhamane@users.noreply.github.com>

---------

Signed-off-by: kanchan-dhamane <74534570+kanchan-dhamane@users.noreply.github.com>
Co-authored-by: bugbounce <35751394+bugbounce@users.noreply.github.com>
This commit is contained in:
Kanchan Dhamane
2025-02-03 08:39:28 +05:30
committed by GitHub
parent d0d7beb700
commit bc15e5b359
56 changed files with 3093 additions and 99 deletions

View File

@@ -122,6 +122,79 @@ var _ = Describe("Test application of the specified definition version", func()
Expect(k8sClient.Delete(ctx, &ns, client.PropagationPolicy(metav1.DeletePropagationForeground))).Should(Succeed())
})
It("Test tries to deploy component which has both spec.version and revision name annotation", func() {
workerV1 := workerWithNoTemplate.DeepCopy()
workerV1.Spec.Workload = common.WorkloadTypeDescriptor{
Definition: common.WorkloadGVK{
APIVersion: "batch/v1",
Kind: "Job",
},
}
workerV1.ObjectMeta.Annotations[oam.AnnotationDefinitionRevisionName] = "1.0.0"
workerV1.Spec.Version = "1.0.0"
workerV1.Spec.Schematic.CUE.Template = workerV1Template
workerV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, workerV1)).ShouldNot(Succeed())
})
It("Test tries to deploy component which has spec.version and but no revision name annotation", func() {
workerV1 := workerWithNoTemplate.DeepCopy()
workerV1.Spec.Workload = common.WorkloadTypeDescriptor{
Definition: common.WorkloadGVK{
APIVersion: "batch/v1",
Kind: "Job",
},
}
workerV1.Spec.Version = "1.0.0"
workerV1.Spec.Schematic.CUE.Template = workerV1Template
workerV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, workerV1)).Should(Succeed())
})
It("Test tries to deploy trait which has both spec.version and revision name annotation", func() {
traitV1 := scalerTrait.DeepCopy()
traitV1.Spec.Schematic.CUE.Template = scalerTraitOutputTemplate
traitV1.ObjectMeta.Annotations[oam.AnnotationDefinitionRevisionName] = "1.0.0"
// traitV1.Spec.Version = "1.0.0"
traitV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, traitV1)).ShouldNot(Succeed())
})
It("Test tries to deploy trait which has spec.version and but no revision name annotation", func() {
traitV1 := scalerTrait.DeepCopy()
traitV1.Spec.Schematic.CUE.Template = scalerTraitOutputTemplate
traitV1.Spec.Version = "1.0.0"
traitV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, traitV1)).Should(Succeed())
})
It("Test tries to deploy policy which has both spec.version and revision name annotation", func() {
policyV1 := policyDef.DeepCopy()
policyV1.ObjectMeta.Annotations[oam.AnnotationDefinitionRevisionName] = "1.0.0"
policyV1.Spec.Version = "1.0.0"
policyV1.Spec.Schematic.CUE.Template = workerV1Template
policyV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, policyV1)).ShouldNot(Succeed())
})
It("Test tries to deploy policy which has spec.version and but no revision name annotation", func() {
policyV1 := policyDef.DeepCopy()
policyV1.Spec.Version = "1.0.0"
policyV1.Spec.Schematic.CUE.Template = workerV1Template
policyV1.SetNamespace(namespace)
Expect(k8sClient.Create(ctx, policyV1)).Should(Succeed())
})
It("Test deploy application which containing cue rendering module", func() {
var (
appName = "test-website-app"
@@ -465,7 +538,8 @@ var workerWithNoTemplate = &v1beta1.ComponentDefinition{
APIVersion: "core.oam.dev/v1beta1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "worker",
Name: "worker",
Annotations: map[string]string{},
},
Spec: v1beta1.ComponentDefinitionSpec{
Schematic: &common.Schematic{
@@ -502,6 +576,27 @@ var jobComponentDef = &v1beta1.ComponentDefinition{
},
}
var policyDefOutputTemplate = `properties: enable: true`
var policyDef = &v1beta1.PolicyDefinition{
TypeMeta: metav1.TypeMeta{
Kind: "PolicyDefinition",
APIVersion: "core.oam.dev/v1beta1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "policy-apply-once",
Annotations: map[string]string{},
},
Spec: v1beta1.PolicyDefinitionSpec{
Version: "1.0.0",
Schematic: &common.Schematic{
CUE: &common.CUE{
Template: policyDefOutputTemplate,
},
},
},
}
var KUBEWorker = &v1beta1.ComponentDefinition{
TypeMeta: metav1.TypeMeta{
Kind: "ComponentDefinition",