Skip to content

Commit 4f2f503

Browse files
committed
Merge branch 'dev'
2 parents d58de6b + e358478 commit 4f2f503

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

scripts/register-destination

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ DESTINATION_CONTEXT=""
1111
PLATFORM_CONTEXT="kind-platform"
1212
STATE_STORE="default"
1313
GITOPS_PATH="platform-cluster"
14+
STRICT_MATCH_LABELS=false
1415

1516
usage() {
16-
echo -e "Usage: register-destination [--help] [--git] [--with-label foo=bar] [--context k8s-context] [--name some-name ] [--platform-context 'kind-platform'] [--path platform-cluster]"
17+
echo -e "Usage: register-destination [--help] [--git] [--with-label foo=bar] [--context k8s-context] [--name some-name ] [--platform-context 'kind-platform'] [--path platform-cluster] [--strict-match-labels]"
1718
echo -e "\t--context='', -c,\t The Kubernetes context where to install FluxCD onto"
1819
echo -e "\t--git, -g\t Use Gitea as local repository in place of default local MinIO"
1920
echo -e "\t--help, -h\t Prints this message"
@@ -22,27 +23,29 @@ usage() {
2223
echo -e "\t--platform-context='', -p,\t The Kubernetes context of the Platform destination"
2324
echo -e "\t--state-store,-s\t Name of the state store to use"
2425
echo -e "\t--with-label foo=bar, -l\t Adds a label to the destination during registration"
26+
echo -e "\t--strict-match-labels\t If set, the destination will only be matched if all labels are present"
2527
exit "${1:-0}"
2628
}
2729

2830
load_options() {
2931
for arg in "$@"; do
3032
shift
3133
case "$arg" in
32-
'--context') set -- "$@" '-c' ;;
33-
'--git') set -- "$@" '-g' ;;
34-
'--help') set -- "$@" '-h' ;;
35-
'--name') set -- "$@" '-n' ;;
36-
'--platform-context') set -- "$@" '-p' ;;
37-
'--state-store') set -- "$@" '-s' ;;
38-
'--with-label') set -- "$@" '-l' ;;
39-
'--path') set -- "$@" '-t' ;;
40-
*) set -- "$@" "$arg" ;;
34+
'--context') set -- "$@" '-c' ;;
35+
'--git') set -- "$@" '-g' ;;
36+
'--help') set -- "$@" '-h' ;;
37+
'--name') set -- "$@" '-n' ;;
38+
'--platform-context') set -- "$@" '-p' ;;
39+
'--state-store') set -- "$@" '-s' ;;
40+
'--with-label') set -- "$@" '-l' ;;
41+
'--strict-match-labels') set -- "$@" '-m' ;;
42+
'--path') set -- "$@" '-t' ;;
43+
*) set -- "$@" "$arg" ;;
4144
esac
4245
done
4346

4447
OPTIND=1
45-
while getopts "p:hgn:c:l:s:t:" opt
48+
while getopts "p:hgn:c:l:s:t:m" opt
4649
do
4750
case "$opt" in
4851
'c') DESTINATION_CONTEXT="$OPTARG";;
@@ -53,6 +56,7 @@ load_options() {
5356
'p') PLATFORM_CONTEXT="$OPTARG";;
5457
's') STATE_STORE="$OPTARG";;
5558
't') GITOPS_PATH="$OPTARG";;
59+
'm') STRICT_MATCH_LABELS=true;;
5660
*) usage 1 ;;
5761
esac
5862
done
@@ -78,7 +82,7 @@ prepare_destination() {
7882
fi
7983
$ROOT/scripts/install-gitops --context $DESTINATION_CONTEXT --path "$GITOPS_PATH" "$flags"
8084

81-
local yqOpts=".metadata.name = \"$NAME\" | .metadata.labels = {} | .spec.stateStoreRef.name = \"$STATE_STORE\" | .spec.stateStoreRef.kind = \"$state_store_type\""
85+
local yqOpts=".metadata.name = \"$NAME\" | .metadata.labels = {} | .spec.stateStoreRef.name = \"$STATE_STORE\" | .spec.stateStoreRef.kind = \"$state_store_type\" | .spec.strictMatchLabels = $STRICT_MATCH_LABELS"
8286
yq "${yqOpts}" $ROOT/config/samples/platform_v1alpha1_worker.yaml |
8387
kubectl --context $PLATFORM_CONTEXT apply -f -
8488

0 commit comments

Comments
 (0)