Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit a155f48

Browse files
authored
Force resource namespace to be appwrapper namespace (#70)
1 parent fb9795c commit a155f48

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

internal/controller/resource_manager.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controller
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"strings"
2223
"time"
2324

@@ -93,8 +94,11 @@ func parseResource(appWrapper *mcadv1beta1.AppWrapper, raw []byte) (*unstructure
9394
return nil, err
9495
}
9596
fixMap(appWrapper, obj.UnstructuredContent())
96-
if obj.GetNamespace() == "" {
97-
obj.SetNamespace("default")
97+
namespace := obj.GetNamespace()
98+
if namespace == "" {
99+
obj.SetNamespace(appWrapper.Namespace)
100+
} else if namespace != appWrapper.Namespace {
101+
return nil, fmt.Errorf("generic item namespace \"%s\" is different from AppWrapper namespace \"%s\"", namespace, appWrapper.Namespace)
98102
}
99103
return obj, nil
100104
}

0 commit comments

Comments
 (0)