scripts/uffd-sync-mattermost-groups: add -s to curl

i.e. disable curl's progress meter, it spams our logs and doesn't really
leave useful info.
This commit is contained in:
stuebinm 2024-11-25 12:10:00 +01:00
parent cb012aba67
commit 849098c386

View file

@ -5,20 +5,20 @@ source /run/secrets/auamost/secrets.fish
for i in (seq 1 (count $groups)) for i in (seq 1 (count $groups))
set team $teams[$i] set team $teams[$i]
set group $groups[$i] set group $groups[$i]
set users (curl -u $uffd_token --basic https://login.infra4future.de/api/v1/getusers -d group="$group") set users (curl -s -u $uffd_token --basic https://login.infra4future.de/api/v1/getusers -d group="$group")
set usernames (echo "$users" | jq -c "[.[] | .loginname]") set usernames (echo "$users" | jq -c "[.[] | .loginname]")
for user in (echo "$users" | jq -c ".[]") for user in (echo "$users" | jq -c ".[]")
set id (echo "$user" | jq .id) set id (echo "$user" | jq .id)
set username (echo "$user" | jq .loginname) set username (echo "$user" | jq .loginname)
set email (echo "$user" | jq .email) set email (echo "$user" | jq .email)
curl -H $mattermost_token \ curl -s -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users \ -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users \
-d '{"email": '"$email"', "username": '"$username"', "auth_service": "gitlab", "auth_data": "'"$id"'"}' -d '{"email": '"$email"', "username": '"$username"', "auth_service": "gitlab", "auth_data": "'"$id"'"}'
end end
set userids (curl -H $mattermost_token \ set userids (curl -s -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users/usernames \ -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users/usernames \
-d "$usernames" | jq '[.[] | {user_id: .id, team_id: "'$team'"} ]') -d "$usernames" | jq '[.[] | {user_id: .id, team_id: "'$team'"} ]')
curl -H $mattermost_token \ curl -s -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members/batch \ -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members/batch \
-d "$userids" -d "$userids"
@ -26,11 +26,11 @@ for i in (seq 1 (count $groups))
continue continue
end end
set current_members (curl -H $mattermost_token \ set current_members (curl -s -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members | jq '[.[] | .user_id]') -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members | jq '[.[] | .user_id]')
# membership relations don't contain e.g. usernames, so fetch those, too # membership relations don't contain e.g. usernames, so fetch those, too
set current_users (curl -H $mattermost_token \ set current_users (curl -s -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users/ids \ -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/users/ids \
-d "$current_members" | jq -c '.[]') -d "$current_members" | jq -c '.[]')
@ -40,7 +40,7 @@ for i in (seq 1 (count $groups))
if not contains -i $id $userids > /dev/null then if not contains -i $id $userids > /dev/null then
set id_unquoted (echo $member | jq -r .id) set id_unquoted (echo $member | jq -r .id)
echo removing $id_unquoted (echo $member | jq '.email') from $team \($group\) echo removing $id_unquoted (echo $member | jq '.email') from $team \($group\)
curl -X DELETE -H $mattermost_token \ curl -s -X DELETE -H $mattermost_token \
-H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members/"$id_unquoted" -H "Content-Type: application/json" https://mattermost.infra4future.de/api/v4/teams/"$team"/members/"$id_unquoted"
end end
end end