-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GitRon/master
Changed rancher login from file- to cli-based login
- Loading branch information
Showing
1 changed file
with
4 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |