forked from kubeflow/internal-acls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_group.sh
executable file
·67 lines (53 loc) · 1.27 KB
/
create_group.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#
# Helper script to create a group
set -xe
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
parseArgs() {
# Parse all command line options
while [[ $# -gt 0 ]]; do
# Parameters should be of the form
# --{name}=${value}
echo parsing "$1"
if [[ $1 =~ ^--(.*)=(.*)$ ]]; then
name=${BASH_REMATCH[1]}
value=${BASH_REMATCH[2]}
eval ${name}="${value}"
elif [[ $1 =~ ^--(.*)$ ]]; then
name=${BASH_REMATCH[1]}
value=true
eval ${name}="${value}"
else
echo "Argument $1 did not match the pattern --{name}={value} or --{name}"
fi
shift
done
}
usage() {
echo "Usage: checkout_repos --group=<name for group> --description=<description>"
}
main() {
cd "${DIR}"
# List of required parameters
names=(group description)
missingParam=false
for i in ${names[@]}; do
if [ -z ${!i} ]; then
echo "--${i} not set"
missingParam=true
fi
done
if ${missingParam}; then
usage
exit 1
fi
GROUP_EMAIL=${group}@kubeflow.org
if [ ! -f ${group}.members.txt ]; then
touch ${group}.members.txt
fi
gam create group ${GROUP_EMAIL} who_can_join invited_can_join \
name ${group} description "${description}" \
allow_external_members true
}
parseArgs $*
main