Skip to content

Commit

Permalink
fix: only consider ADDED events
Browse files Browse the repository at this point in the history
  • Loading branch information
Matéo Mévollon committed Oct 26, 2022
1 parent 2bd31af commit b78c1d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions nsplease.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh
#! /usr/bin/env sh

debug() {
printf "[DEBUG]\t%s\n" "$*"
Expand All @@ -19,17 +19,16 @@ out() {
}

main() {
info "waiting for labelled namespaces..."
info "waiting for 'nsplease/project' labelled namespaces..."
kubectl get namespace --watch --output-watch-events -o json |
jq --unbuffered --raw-output \
'if .object.metadata.labels | has("nsplease/project") then
[.type, .object.metadata.name, .object.metadata.labels."nsplease/project"]
| select(.[0] == "ADDED")
| @tsv
else empty
end' |
while read -r TYPE NAME LABEL; do
debug "got event: $TYPE $NAME $LABEL"
'if (.object.metadata.labels | has("nsplease/project"))
and .type == "ADDED" then
[.object.metadata.name, .object.metadata.labels."nsplease/project"] | @tsv
else empty
end' |
while read -r NAME LABEL; do
debug "got labelled namespace: $NAME $LABEL"
done
}

Expand Down
2 changes: 1 addition & 1 deletion nsplease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
spec:
serviceAccountName: nsplease
containers:
- image: ghcr.io/socialgouv/nsplease
- image: ghcr.io/socialgouv/nsplease:main
name: nsplease
---
apiVersion: v1
Expand Down

0 comments on commit b78c1d1

Please sign in to comment.