From 68a13ef0192e43bb01a7ebc758065656d1583438 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Tue, 30 Jan 2024 02:11:06 +0100
Subject: [PATCH] fix(shared): Make sure labels aren't unintentionally dropped

The first patch that "adds" `{}` to `/metadata/labels` would replace any
existing labels resulting in unexpected behaviour. Instead we rely on
the preexistence of the labels field in the namespace.
---
 apps/base/findmydevice/namespace.yaml                 | 1 +
 apps/base/forecastle/namespace.yaml                   | 1 +
 shared/components/namespace-baseline/namespace.yaml   | 3 ---
 shared/components/namespace-restricted/namespace.yaml | 3 ---
 4 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/apps/base/findmydevice/namespace.yaml b/apps/base/findmydevice/namespace.yaml
index b4df4036f..a7a816c3c 100644
--- a/apps/base/findmydevice/namespace.yaml
+++ b/apps/base/findmydevice/namespace.yaml
@@ -2,3 +2,4 @@ apiVersion: v1
 kind: Namespace
 metadata:
   name: findmydevice
+  labels: {}
diff --git a/apps/base/forecastle/namespace.yaml b/apps/base/forecastle/namespace.yaml
index e154a059d..c68e43ae4 100644
--- a/apps/base/forecastle/namespace.yaml
+++ b/apps/base/forecastle/namespace.yaml
@@ -2,3 +2,4 @@ apiVersion: v1
 kind: Namespace
 metadata:
   name: forecastle
+  labels: {}
diff --git a/shared/components/namespace-baseline/namespace.yaml b/shared/components/namespace-baseline/namespace.yaml
index 97788fd6e..7ba0b3b15 100644
--- a/shared/components/namespace-baseline/namespace.yaml
+++ b/shared/components/namespace-baseline/namespace.yaml
@@ -1,6 +1,3 @@
-- op: add
-  path: /metadata/labels
-  value: {}
 - op: add
   path: /metadata/labels/pod-security.kubernetes.io~1audit
   value: restricted
diff --git a/shared/components/namespace-restricted/namespace.yaml b/shared/components/namespace-restricted/namespace.yaml
index fe13196e9..9093b4124 100644
--- a/shared/components/namespace-restricted/namespace.yaml
+++ b/shared/components/namespace-restricted/namespace.yaml
@@ -1,6 +1,3 @@
-- op: add
-  path: /metadata/labels
-  value: {}
 - op: add
   path: /metadata/labels/pod-security.kubernetes.io~1audit
   value: restricted
-- 
GitLab