Skip to content

Commit

Permalink
fix: add oblik label to workloads
Browse files Browse the repository at this point in the history
  • Loading branch information
devthejo committed Oct 23, 2024
1 parent 6488967 commit 72e5f3b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions plugins/fabrique/patches/04-oblik.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = async (manifests, _options, _context) => {
const labelKey = "oblik.socialgouv.io/enabled"
const labelValue = "true"

const targetKinds = [
"cluster.postgresql.cnpg.io",
"cronjob.batch",
"deployment.apps",
"statefulset.apps",
]

const addLabelIfMissing = (manifest) => {
if (!manifest.metadata.labels) {
manifest.metadata.labels = {}
}
if (!manifest.metadata.labels[labelKey]) {
manifest.metadata.labels[labelKey] = labelValue
}
}

for (const manifest of manifests) {
const kind = manifest.kind.toLowerCase()
const apiGroup = manifest.apiVersion.split("/")[0].toLowerCase()
const key = `${kind}.${apiGroup}`

if (targetKinds.includes(key)) {
addLabelIfMissing(manifest)
}
}
}

0 comments on commit 72e5f3b

Please sign in to comment.