add command to generate jwt for portainer api

This commit is contained in:
oscar 2022-06-23 08:02:24 +12:00
parent 5da99536d1
commit 4f933b4e38

View File

@ -192,12 +192,31 @@ function run_before_commit_k8s() {
docker run --rm -it -w /repo -v `pwd`:/repo quay.io/helmpack/chart-testing ct lint --all --config=.ci/ct-config.yaml
}
function generate_portainer_jwt() {
printf "${HIGHLIGHT_COLOR}Generate Portainter JWT${NO_COLOR}\n"
read -p "Username(admin):" username
if [ -z "$username" ]; then
username="admin";
fi
read -p "Password(****):" password
read -p "Address(127.0.0.1):" address
if [ -z "$address" ]; then
address="127.0.0.1";
fi
payload="{\"username\":\"${username}\",\"password\":\"${password}\"}"
curl -d ${payload} -H 'Content-Type: application/json' "http://${address}:9000/api/auth"
}
function menu() {
PS3='Please select the option: '
OPTIONS=(
'Build Portainer EE/CE All'
'Build Portainer EE/CE Frontend'
'Build Portainer EE/CE Backend'
'Generate Portainer EE/CE JWT'
'Run Before Commit [Portainer EE/CE]'
'Run Before Commit [k8s]'
'Build Portainer Agent'
@ -217,6 +236,9 @@ function menu() {
'Build Portainer EE/CE Backend')
build_portainer_backend
;;
'Generate Portainer EE/CE JWT')
generate_portainer_jwt
;;
'Run Before Commit [Portainer EE/CE]')
run_before_commit
;;