ignore vela-system, which is specified in needNamespace for addon metadata information (#3109)

Signed-off-by: StevenLeiZhang <zhangleiic@163.com>
This commit is contained in:
StevenLeiZhang
2022-01-17 20:02:05 +08:00
committed by GitHub
parent f57815a5bf
commit af27e6a776
2 changed files with 15 additions and 0 deletions

View File

@@ -467,6 +467,10 @@ func RenderApp(ctx context.Context, addon *InstallPackage, config *rest.Config,
}
app.Labels = util.MergeMapOverrideWithDst(app.Labels, map[string]string{oam.LabelAddonName: addon.Name})
for _, namespace := range addon.NeedNamespace {
// vela-system must exist before rendering vela addon
if namespace == types.DefaultKubeVelaNS {
continue
}
comp := common2.ApplicationComponent{
Type: "raw",
Name: fmt.Sprintf("%s-namespace", namespace),

View File

@@ -226,6 +226,17 @@ func TestRenderApp(t *testing.T) {
assert.Equal(t, len(app.Spec.Components), 2)
}
func TestRenderAppWithNeedNamespace(t *testing.T) {
addon := baseAddon
addon.NeedNamespace = append(addon.NeedNamespace, types.DefaultKubeVelaNS)
app, err := RenderApp(ctx, &addon, nil, nil, map[string]interface{}{})
assert.NoError(t, err, "render app fail")
assert.Equal(t, len(app.Spec.Components), 2)
for _, c := range app.Spec.Components {
assert.NotEqual(t, types.DefaultKubeVelaNS+"-namespace", c.Name, "namespace vela-system should not be rendered")
}
}
func TestRenderDeploy2RuntimeAddon(t *testing.T) {
addonDeployToRuntime := baseAddon
addonDeployToRuntime.Meta.DeployTo = &DeployTo{