@@ -66,7 +66,7 @@ type Kube interface {
6666 WireguardPeerCreate (namespace string , wireguardPeer * vpnv1alpha1.WireguardPeer ) (* vpnv1alpha1.WireguardPeer , error )
6767 WireguardPeerDelete (namespace string , name string ) error
6868 Apply (path string , force bool ) error
69- CreateNamespace (namespace string ) error
69+ CreateNamespace (namespace string , managedByPlural bool ) error
7070 GetClient () * kubernetes.Clientset
7171 GetRestClient () * restclient.RESTClient
7272}
@@ -324,22 +324,24 @@ func (k *kube) Apply(path string, force bool) error {
324324 return nil
325325}
326326
327- func (k * kube ) CreateNamespace (namespace string ) error {
327+ func (k * kube ) CreateNamespace (namespace string , managedByPlural bool ) error {
328328 ctx := context .Background ()
329329 _ , err := k .Kube .CoreV1 ().Namespaces ().Get (ctx , namespace , metav1.GetOptions {})
330330 if err == nil {
331331 return nil
332332 }
333-
334- _ , err = k .Kube .CoreV1 ().Namespaces ().Create (ctx , & v1.Namespace {
333+ ns := & v1.Namespace {
335334 ObjectMeta : metav1.ObjectMeta {
336335 Name : namespace ,
337336 Labels : map [string ]string {
338- "app.kubernetes.io/managed-by" : "plural" ,
339- "app.plural.sh/name" : namespace ,
337+ "app.plural.sh/name" : namespace ,
340338 },
341339 },
342- }, metav1.CreateOptions {})
340+ }
341+ if managedByPlural {
342+ ns .Labels ["app.kubernetes.io/managed-by" ] = "plural"
343+ }
344+ _ , err = k .Kube .CoreV1 ().Namespaces ().Create (ctx , ns , metav1.CreateOptions {})
343345
344346 return err
345347}
0 commit comments