Skip to content

Commit

Permalink
Merge pull request #3 from GitRon/master
Browse files Browse the repository at this point in the history
Changed rancher login from file- to cli-based login
  • Loading branch information
felixschul authored Nov 7, 2018
2 parents 8994f5a + ee380da commit a871925
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,34 +1,10 @@
#!/bin/sh

# This entrypoint creates a cli2.json file which rancher CLI uses to authenticate with rancher and
# select the current project. This is necessary, because the current rancher CLI has no real non-interactive mode.
# Otherwise we could directly use "rancher login" in our CI pipline. But if there are several projects, the CLI
# will ask us to select a project, see https://github.com/rancher/rancher/issues/14448
# Login to rancher and select project
echo Logging into rancher...

echo Writing rancher CLI2 file ...

mkdir ~/.rancher
echo "{
\"Servers\":
{
\"rancherDefault\":
{
\"accessKey\":\"$RANCHER2_ACCESS_KEY\",
\"secretKey\":\"$RANCHER2_SECRET_KEY\",
\"tokenKey\":\"$RANCHER2_ACCESS_KEY:$RANCHER2_SECRET_KEY\",
\"url\":\"$RANCHER2_SERVER_URL\",
\"project\":\"$RANCHER2_PROJECT_ID\",
\"cacert\":\"\"
}
},
\"CurrentServer\":\"rancherDefault\"
}" > ~/.rancher/cli2.json

echo Done

# Debug output
# cat ~/.rancher/cli2.json
rancher login $RANCHER2_SERVER_URL --token $RANCHER2_ACCESS_KEY:$RANCHER2_SECRET_KEY --context $RANCHER2_PROJECT_ID

# Since this is a "configuration data" entrypoint, we now want to execute the actual command.
# See https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data
exec "$@"
exec "$@"

0 comments on commit a871925

Please sign in to comment.