mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 12:06:38 +00:00
Fix: restrict the rules that automatically add topology strategy to addons to be valid only for the yaml type (#5957)
Signed-off-by: zhaohuihui <zhaohuihui_yewu@cmss.chinamobile.com>
This commit is contained in:
@@ -421,6 +421,10 @@ func renderResources(addon *InstallPackage, args map[string]interface{}) ([]comm
|
||||
// checkNeedAttachTopologyPolicy will check this addon want to deploy to runtime-cluster, but application template doesn't specify the
|
||||
// topology policy, then will attach the policy to application automatically.
|
||||
func checkNeedAttachTopologyPolicy(app *v1beta1.Application, addon *InstallPackage) bool {
|
||||
// the cue template will not be attached topology policy for the white-box principle
|
||||
if len(addon.AppCueTemplate.Data) != 0 {
|
||||
return false
|
||||
}
|
||||
if !isDeployToRuntime(addon) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -304,6 +304,29 @@ func TestAppComponentRender(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCheckNeedAttachTopologyPolicy(t *testing.T) {
|
||||
addon := &InstallPackage{
|
||||
AppCueTemplate: ElementFile{
|
||||
Data: "not empty",
|
||||
Name: "template.cue",
|
||||
},
|
||||
}
|
||||
assert.Equal(t, checkNeedAttachTopologyPolicy(&v1beta1.Application{Spec: v1beta1.ApplicationSpec{Policies: []v1beta1.AppPolicy{{
|
||||
Type: v1alpha1.SharedResourcePolicyType,
|
||||
}}}}, addon), false)
|
||||
|
||||
addon0 := &InstallPackage{
|
||||
AppCueTemplate: ElementFile{
|
||||
Data: "",
|
||||
Name: "template.cue",
|
||||
},
|
||||
Meta: Meta{
|
||||
DeployTo: &DeployTo{RuntimeCluster: true},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, checkNeedAttachTopologyPolicy(&v1beta1.Application{Spec: v1beta1.ApplicationSpec{Policies: []v1beta1.AppPolicy{{
|
||||
Type: v1alpha1.SharedResourcePolicyType,
|
||||
}}}}, addon0), true)
|
||||
|
||||
addon1 := &InstallPackage{
|
||||
Meta: Meta{
|
||||
DeployTo: nil,
|
||||
@@ -335,6 +358,7 @@ func TestCheckNeedAttachTopologyPolicy(t *testing.T) {
|
||||
assert.Equal(t, checkNeedAttachTopologyPolicy(&v1beta1.Application{Spec: v1beta1.ApplicationSpec{Policies: []v1beta1.AppPolicy{{
|
||||
Type: v1alpha1.SharedResourcePolicyType,
|
||||
}}}}, addon4), true)
|
||||
|
||||
}
|
||||
|
||||
func TestGenerateAppFrameworkWithCue(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user