Implement oc smart login
This commit is contained in:
6 files changed
+1701
No files matched your search
@@ -0,0 +1,206 @@
|
||||
# ============================================================================
|
||||
# OCP Smart Login/Context Switch Aliases
|
||||
# ============================================================================
|
||||
# These aliases intelligently switch between OCP clusters:
|
||||
# - If logged in with valid token: just switch context (fast)
|
||||
# - If token expired or not logged in: full login with browser (safe)
|
||||
#
|
||||
# Source this after .bash_aliases to override the old context-only aliases
|
||||
# ============================================================================
|
||||
|
||||
# First, source the helper functions
|
||||
source ~/.bash_oc_smart.sh
|
||||
|
||||
# ============================================================================
|
||||
# AWS Clusters - Smart Switch Aliases
|
||||
# ============================================================================
|
||||
|
||||
# AWS-Test1 (aws01t)
|
||||
alias ocAWS-Test1='oc_smart_switch \
|
||||
"aws01t" \
|
||||
"AWS-Test1" \
|
||||
"kihub-u241100-dev/api-aws01t-sbb-aws-test-net:6443/u241100" \
|
||||
"kihub-dev-u241100" \
|
||||
"OPENSHIFT_TOKEN_AWS_TEST" \
|
||||
"https://api.aws01t.sbb-aws-test.net:6443" \
|
||||
"https://oauth-openshift.apps.aws01t.sbb-aws-test.net/oauth/token/request"'
|
||||
|
||||
# AWS-Test2 (aws02t)
|
||||
alias ocAWS-Test2='oc_smart_switch \
|
||||
"aws02t" \
|
||||
"AWS-Test2" \
|
||||
"kihub-u241100-dev/api-aws02t-sbb-aws-test-net:6443/u241100" \
|
||||
"kihub-dev-u241100" \
|
||||
"OPENSHIFT_TOKEN_AWS_TEST" \
|
||||
"https://api.aws02t.sbb-aws-test.net:6443" \
|
||||
"https://oauth-openshift.apps.aws02t.sbb-aws-test.net/oauth/token/request"'
|
||||
|
||||
# AWS-Dev (Development on aws01t)
|
||||
alias ocAWS-Dev='oc_smart_switch \
|
||||
"aws01t" \
|
||||
"AWS-Dev" \
|
||||
"kihub-u241100-dev/api-aws01t-sbb-aws-test-net:6443/u241100" \
|
||||
"kihub-dev-u241100" \
|
||||
"OPENSHIFT_TOKEN_AWS_TEST" \
|
||||
"https://api.aws01t.sbb-aws-test.net:6443" \
|
||||
"https://oauth-openshift.apps.aws01t.sbb-aws-test.net/oauth/token/request"'
|
||||
|
||||
# AWS-RT (Runtime on aws01t)
|
||||
alias ocAWS-RT='oc_smart_switch \
|
||||
"aws01t" \
|
||||
"AWS-RT" \
|
||||
"kihub-rt/api-aws01t-sbb-aws-test-net:6443/u241100" \
|
||||
"kihub-rt" \
|
||||
"OPENSHIFT_TOKEN_AWS_TEST" \
|
||||
"https://api.aws01t.sbb-aws-test.net:6443" \
|
||||
"https://oauth-openshift.apps.aws01t.sbb-aws-test.net/oauth/token/request"'
|
||||
|
||||
# AWS-Test (Test on aws01t)
|
||||
alias ocAWS-Test='oc_smart_switch \
|
||||
"aws01t" \
|
||||
"AWS-Test" \
|
||||
"kihub-test/api-aws01t-sbb-aws-test-net:6443/u241100" \
|
||||
"kihub-test" \
|
||||
"OPENSHIFT_TOKEN_AWS_TEST" \
|
||||
"https://api.aws01t.sbb-aws-test.net:6443" \
|
||||
"https://oauth-openshift.apps.aws01t.sbb-aws-test.net/oauth/token/request"'
|
||||
|
||||
# AWS-Int (Integration on Lisa)
|
||||
alias ocAWS-Int='oc_smart_switch \
|
||||
"lisa" \
|
||||
"AWS-Int" \
|
||||
"kihub-int/api-lisa-sbb-aws-net:6443/u241100" \
|
||||
"kihub-int" \
|
||||
"OPENSHIFT_TOKEN_AWS_PROD" \
|
||||
"https://api.lisa.sbb-aws.net:6443" \
|
||||
"https://oauth-openshift.apps.lisa.sbb-aws.net/oauth/token/request"'
|
||||
|
||||
# AWS-Prod (Production on Lisa)
|
||||
alias ocAWS-Prod='oc_smart_switch \
|
||||
"lisa" \
|
||||
"AWS-Prod" \
|
||||
"kihub-prod/api-lisa-sbb-aws-net:6443/u241100" \
|
||||
"kihub-prod" \
|
||||
"OPENSHIFT_TOKEN_AWS_PROD" \
|
||||
"https://api.lisa.sbb-aws.net:6443" \
|
||||
"https://oauth-openshift.apps.lisa.sbb-aws.net/oauth/token/request"'
|
||||
|
||||
# AWS-Lisa (Production cluster)
|
||||
alias ocAWS-Lisa='oc_smart_switch \
|
||||
"lisa" \
|
||||
"AWS-Lisa" \
|
||||
"kihub-prod/api-lisa-sbb-aws-net:6443/u241100" \
|
||||
"kihub-prod" \
|
||||
"OPENSHIFT_TOKEN_AWS_PROD" \
|
||||
"https://api.lisa.sbb-aws.net:6443" \
|
||||
"https://oauth-openshift.apps.lisa.sbb-aws.net/oauth/token/request"'
|
||||
|
||||
# AWS-Maggie (Production cluster)
|
||||
alias ocAWS-Maggie='oc_smart_switch \
|
||||
"maggie" \
|
||||
"AWS-Maggie" \
|
||||
"kihub-prod/api-maggie-sbb-aws-net:6443/u241100" \
|
||||
"kihub-prod" \
|
||||
"OPENSHIFT_TOKEN_AWS_PROD" \
|
||||
"https://api.maggie.sbb-aws.net:6443" \
|
||||
"https://oauth-openshift.apps.maggie.sbb-aws.net/oauth/token/request"'
|
||||
|
||||
# AWS-WZU
|
||||
alias ocAWS-WZU='oc_smart_switch \
|
||||
"wzu01t" \
|
||||
"AWS-WZU" \
|
||||
"kihub-test/api-wzu01t-ocp-test-sbb-aws-net:6443/u241100" \
|
||||
"" \
|
||||
"OPENSHIFT_TOKEN_WZU" \
|
||||
"https://api.wzu01t.ocp-test.sbb-aws.net:6443" \
|
||||
"https://oauth-openshift.apps.wzu01t.ocp-test.sbb-aws.net/oauth/token/request"'
|
||||
|
||||
# ============================================================================
|
||||
# SC (OTC) Clusters - Smart Switch Aliases
|
||||
# ============================================================================
|
||||
|
||||
# SC-Dev (Development on sc02t)
|
||||
alias ocSC-Dev='oc_smart_switch \
|
||||
"sc02t" \
|
||||
"SC-Dev" \
|
||||
"kihub-u241100-dev/api-sc02t-otc-test-sbb-ch:6443/u241100" \
|
||||
"kihub-dev-u241100" \
|
||||
"OPENSHIFT_TOKEN_SC02" \
|
||||
"https://api.sc02t.otc-test.sbb.ch:6443" \
|
||||
"https://oauth-openshift.apps.sc02t.otc-test.sbb.ch/oauth/token/request"'
|
||||
|
||||
# SC-RT (Runtime on sc02t)
|
||||
alias ocSC-RT='oc_smart_switch \
|
||||
"sc02t" \
|
||||
"SC-RT" \
|
||||
"kihub-rt/api-sc02t-otc-test-sbb-ch:6443/u241100" \
|
||||
"kihub-rt" \
|
||||
"OPENSHIFT_TOKEN_SC02" \
|
||||
"https://api.sc02t.otc-test.sbb.ch:6443" \
|
||||
"https://oauth-openshift.apps.sc02t.otc-test.sbb.ch/oauth/token/request"'
|
||||
|
||||
# SC-Test (Test on sc02t)
|
||||
alias ocSC-Test='oc_smart_switch \
|
||||
"sc02t" \
|
||||
"SC-Test" \
|
||||
"kihub-test/api-sc02t-otc-test-sbb-ch:6443/u241100" \
|
||||
"kihub-test" \
|
||||
"OPENSHIFT_TOKEN_SC02" \
|
||||
"https://api.sc02t.otc-test.sbb.ch:6443" \
|
||||
"https://oauth-openshift.apps.sc02t.otc-test.sbb.ch/oauth/token/request"'
|
||||
|
||||
# SC-Int (Integration on Sputnix)
|
||||
alias ocSC-Int='oc_smart_switch \
|
||||
"sputnix" \
|
||||
"SC-Int" \
|
||||
"kihub-int/api-sputnix-otc-sbb-ch:6443/u241100" \
|
||||
"kihub-int" \
|
||||
"OPENSHIFT_TOKEN_SCSputnix" \
|
||||
"https://api.sputnix.otc.sbb.ch:6443" \
|
||||
"https://oauth-openshift.apps.sputnix.otc.sbb.ch/oauth/token/request"'
|
||||
|
||||
# SC-Prod (Production on Sputnix)
|
||||
alias ocSC-Prod='oc_smart_switch \
|
||||
"sputnix" \
|
||||
"SC-Prod" \
|
||||
"kihub-prod/api-sputnix-otc-sbb-ch:6443/u241100" \
|
||||
"kihub-prod" \
|
||||
"OPENSHIFT_TOKEN_SCSputnix" \
|
||||
"https://api.sputnix.otc.sbb.ch:6443" \
|
||||
"https://oauth-openshift.apps.sputnix.otc.sbb.ch/oauth/token/request"'
|
||||
|
||||
# ============================================================================
|
||||
# Convenience Aliases for Helper Functions
|
||||
# ============================================================================
|
||||
|
||||
alias ocStatus='oc_status'
|
||||
alias ocCtx='oc_contexts'
|
||||
alias ocLogout='oc_logout'
|
||||
alias ocWhoami='oc whoami'
|
||||
|
||||
# ============================================================================
|
||||
# Notes on Usage
|
||||
# ============================================================================
|
||||
#
|
||||
# Old way (still works):
|
||||
# ocLoginAWS-Test1 → Full login every time
|
||||
# ocAWS-Dev → Only context switch (fails if not logged in)
|
||||
#
|
||||
# New way (smart):
|
||||
# ocAWS-Dev → Auto-detect & do the right thing
|
||||
# - Logged in? → Switch context only (FAST)
|
||||
# - Not logged in? → Full login (SAFE)
|
||||
#
|
||||
# Helper commands:
|
||||
# ocStatus → Show current auth status
|
||||
# ocCtx → List all available contexts
|
||||
# ocLogout → Logout from current cluster
|
||||
# ocWhoami → Show current user
|
||||
#
|
||||
# Example workflow:
|
||||
# 1. ocAWS-Test1 → Switch to Test1, full login if needed
|
||||
# 2. ocAWS-Int → Switch to Int, just context switch (fast!)
|
||||
# 3. ocAWS-Prod → Switch to Prod, just context switch (fast!)
|
||||
# 4. ocSC-Int → Switch to SC Int, full login if different token
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user