add bi rmq
This commit is contained in:
parent
a70bc9b0e6
commit
dca654690b
@ -42,9 +42,37 @@ spec:
|
|||||||
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
||||||
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/users/${username}" \
|
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/users/${username}" \
|
||||||
-d "{\"password\":\"${password}\",\"tags\":\"\"}" >/dev/null
|
-d "{\"password\":\"${password}\",\"tags\":\"\"}" >/dev/null
|
||||||
|
|
||||||
|
vhosts_count="$(echo "${app_json}" | jq -r '(.data.data.vhosts // []) | length')"
|
||||||
|
if [ "${vhosts_count}" -gt 0 ]; then
|
||||||
|
echo "${app_json}" | jq -c '.data.data.vhosts[]' | while read -r vhost_item; do
|
||||||
|
vhost="$(echo "${vhost_item}" | jq -r '.name // "/"')"
|
||||||
|
configure="$(echo "${vhost_item}" | jq -r '.permissions.configure // ".*"')"
|
||||||
|
write="$(echo "${vhost_item}" | jq -r '.permissions.write // ".*"')"
|
||||||
|
read="$(echo "${vhost_item}" | jq -r '.permissions.read // ".*"')"
|
||||||
|
vhost_uri="$(jq -rn --arg v "${vhost}" '$v|@uri')"
|
||||||
|
|
||||||
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
||||||
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/permissions/%2F/${username}" \
|
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/vhosts/${vhost_uri}" \
|
||||||
-d '{"configure":".*","write":".*","read":".*"}' >/dev/null
|
-d '{}' >/dev/null
|
||||||
|
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
||||||
|
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/permissions/${vhost_uri}/${username}" \
|
||||||
|
-d "{\"configure\":\"${configure}\",\"write\":\"${write}\",\"read\":\"${read}\"}" >/dev/null
|
||||||
|
done
|
||||||
|
else
|
||||||
|
vhost="$(echo "${app_json}" | jq -r '.data.data.vhost // "/"')"
|
||||||
|
configure="$(echo "${app_json}" | jq -r '.data.data.permissions.configure // ".*"')"
|
||||||
|
write="$(echo "${app_json}" | jq -r '.data.data.permissions.write // ".*"')"
|
||||||
|
read="$(echo "${app_json}" | jq -r '.data.data.permissions.read // ".*"')"
|
||||||
|
vhost_uri="$(jq -rn --arg v "${vhost}" '$v|@uri')"
|
||||||
|
|
||||||
|
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
||||||
|
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/vhosts/${vhost_uri}" \
|
||||||
|
-d '{}' >/dev/null
|
||||||
|
curl -sS -u "${admin_user}:${admin_pass}" -H "content-type:application/json" \
|
||||||
|
-X PUT "http://rabbitmq.rabbitmq.svc.cluster.local:15672/api/permissions/${vhost_uri}/${username}" \
|
||||||
|
-d "{\"configure\":\"${configure}\",\"write\":\"${write}\",\"read\":\"${read}\"}" >/dev/null
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
---
|
---
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user