mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
Fix: the definition namespace is empty (#3227)
Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
@@ -559,6 +559,9 @@ func RenderApp(ctx context.Context, addon *InstallPackage, config *rest.Config,
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fail to render definition: %s in cue's format", cueDef.Name)
|
||||
}
|
||||
if def.Unstructured.GetNamespace() == "" {
|
||||
def.Unstructured.SetNamespace(types.DefaultKubeVelaNS)
|
||||
}
|
||||
app.Spec.Components = append(app.Spec.Components, common2.ApplicationComponent{
|
||||
Name: cueDef.Name,
|
||||
Type: "raw",
|
||||
@@ -605,6 +608,9 @@ func RenderDefinitions(addon *InstallPackage, config *rest.Config) ([]*unstructu
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "fail to render definition: %s in cue's format", cueDef.Name)
|
||||
}
|
||||
if def.GetNamespace() == "" {
|
||||
def.SetNamespace(types.DefaultKubeVelaNS)
|
||||
}
|
||||
defObjs = append(defObjs, &def.Unstructured)
|
||||
}
|
||||
}
|
||||
|
||||
+10
-2
@@ -134,7 +134,11 @@ func NewAddonEnableCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra.Com
|
||||
}
|
||||
addonOrDir := args[0]
|
||||
var name = addonOrDir
|
||||
if _, err := os.Stat(addonOrDir); err == nil {
|
||||
if file, err := os.Stat(addonOrDir); err == nil {
|
||||
if !file.IsDir() {
|
||||
return fmt.Errorf("%s is not addon dir", addonOrDir)
|
||||
}
|
||||
ioStream.Infof("enable addon by local dir: %s", addonOrDir)
|
||||
// args[0] is a local path install with local dir, use base dir name as addonName
|
||||
name = filepath.Base(addonOrDir)
|
||||
err = enableAddonByLocal(ctx, name, addonOrDir, k8sClient, config, addonArgs)
|
||||
@@ -200,7 +204,11 @@ func NewAddonUpgradeCommand(c common.Args, ioStream cmdutil.IOStreams) *cobra.Co
|
||||
}
|
||||
addonOrDir := args[0]
|
||||
var name string
|
||||
if _, err := os.Stat(addonOrDir); err == nil {
|
||||
if file, err := os.Stat(addonOrDir); err == nil {
|
||||
if !file.IsDir() {
|
||||
return fmt.Errorf("%s is not addon dir", addonOrDir)
|
||||
}
|
||||
ioStream.Infof("enable addon by local dir: %s", addonOrDir)
|
||||
// args[0] is a local path install with local dir
|
||||
name := filepath.Base(addonOrDir)
|
||||
_, err = pkgaddon.FetchAddonRelatedApp(context.Background(), k8sClient, name)
|
||||
|
||||
Reference in New Issue
Block a user