Skip to content

Commit

Permalink
cli: add admin email & password options to run-cli
Browse files Browse the repository at this point in the history
Also fixes shellcheck issues

closes #394
closes #393
  • Loading branch information
mvidalgarcia committed Sep 4, 2020
1 parent dc6877e commit 20dc858
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion reana/reana_dev/cli.py
Expand Up @@ -59,9 +59,10 @@ def reana_dev(): # noqa: D301
$ # example (a): fast, CLI mode only, fast example
$ reana-dev cluster-delete
$ reana-dev run-ci -m /var/reana:/var/reana -c r-d-helloworld --exclude-components=r-ui,r-a-vomsproxy
--admin-email john.doe@example.org --admin-password mysecretpassword
$ # example (b): slow, CLI and Web modes, all examples
$ reana-dev cluster-delete
$ reana-dev run-ci
$ reana-dev run-ci --admin-email john.doe@example.org --admin-password mysecretpassword
How to create REANA cluster:
Expand Down
23 changes: 20 additions & 3 deletions reana/reana_dev/run.py
Expand Up @@ -141,9 +141,23 @@ def run_commands():
default=["DEMO"],
help="Which examples to run? [default=DEMO]",
)
@click.option(
"--admin-email", required=True, help="Admin user email address",
)
@click.option(
"--admin-password", required=True, help="Admin user password",
)
@run_commands.command(name="run-ci")
def run_ci(
build_arg, mode, exclude_components, mounts, job_mounts, no_cache, component,
build_arg,
mode,
exclude_components,
mounts,
job_mounts,
no_cache,
component,
admin_email,
admin_password,
): # noqa: D301
"""Run CI build.
Expand All @@ -162,12 +176,15 @@ def run_ci(
\b
Example:
$ reana-dev run-cli -m /var/reana:/var/reana
$ reana-dev run-ci -m /var/reana:/var/reana
-m /usr/share/local/mydata:/mydata
-j /mydata:/mydata
-c r-d-helloworld
--exclude-components=r-ui,r-a-vomsproxy
--mode debug
--admin-email john.doe@example.org
--admin-password mysecretpassword
"""
# parse arguments
components = select_components(component)
Expand Down Expand Up @@ -204,7 +221,7 @@ def run_ci(
# deploy cluster
cmd = (
f"reana-dev cluster-deploy --mode {mode}"
" --admin-email john.doe@example.org --admin-password 123456"
f" --admin-email {admin_email} --admin-password {admin_password}"
)
for job_mount in job_mounts:
cmd += " -j {}".format(job_mount)
Expand Down
10 changes: 5 additions & 5 deletions scripts/create-admin-user.sh
Expand Up @@ -22,7 +22,7 @@ REANA_SERVER=$(kubectl get pod -l "app=$instance_name-server" | grep Running | a

# Wait for DB to be ready
REANA_DB=$(kubectl get pod -l "app=$instance_name-db" | grep Running | awk '{print $1}')
echo $REANA_DB
echo "$REANA_DB"
while [ "0" -ne "$(kubectl exec "$REANA_DB" -- pg_isready -U reana -h 127.0.0.1 -p 5432 &> /dev/null && echo $? || echo 1)" ]
do
echo "Waiting for REANA-DB to be ready."
Expand All @@ -34,11 +34,11 @@ echo "REANA-DB ready"
kubectl exec "$REANA_SERVER" -- ./scripts/setup

# Create admin user
admin_access_token=$(kubectl exec "$REANA_SERVER" -- \
flask reana-admin create-admin-user --email $email_address --password $password)
if [ $? -ne 0 ]; then
if ! admin_access_token=$(kubectl exec "$REANA_SERVER" -- \
flask reana-admin create-admin-user --email "$email_address" --password "$password")
then
# Failure output
echo $admin_access_token
echo "$admin_access_token"
exit 1
fi

Expand Down

0 comments on commit 20dc858

Please sign in to comment.