Last active
February 12, 2025 12:55
-
-
Save kimdre/6e31383feba8e1b1c3c0785be6567d13 to your computer and use it in GitHub Desktop.
Automated login to openshift
This file contains hidden or 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
# Add this to your .bashrc or .zshrc etc. | |
function oc { | |
if [[ "$@" == "login" ]] | |
then | |
OS_USER="my_user" | |
OS_PASSWORD="my_password" | |
OS_URL="https://openshift.master.com:443" | |
echo Optaining api token... | |
export OC_TOKEN=$(curl -u ${OS_USER}:${OS_PASSWORD} -kv -H "X-CSRF-Token: xxx" "${OS_URL}/oauth/authorize?client_id=openshift-challenging-client&response_type=token" 2>&1 | ggrep -oP "access_token=\K[^&]*") | |
command oc login --token=${OC_TOKEN} | |
else | |
command oc "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment