Last active
February 9, 2023 11:30
-
-
Save zettca/1cddc1c52d05db9882e307f8f24c7699 to your computer and use it in GitHub Desktop.
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
// Preview: docs | |
// Name: Open Cluster URL | |
// Shortcut: cmd shift k | |
import "@johnlindquist/kit"; | |
const k8s = await npm("@kubernetes/client-node"); | |
const kc = new k8s.KubeConfig(); | |
kc.loadFromDefault(); | |
// const k8sApi = kc.makeApiClient(k8s.CoreV1Api); | |
const contexts = kc.getContexts(); | |
const selectedCtx: Record<string, string> = await arg("K8s Context", contexts); | |
const { namespace: ns, cluster: clusterName } = selectedCtx; | |
const { server: serverUrl } = kc.getCluster(clusterName); | |
const { protocol, hostname } = new URL(serverUrl); | |
const baseUrl = `${protocol}//${hostname}`; | |
const services = { | |
"Control Plane": `${ns}/control-plane/control-plane-lcp-app/`, | |
"Control Plane Automation": `${ns}/control-plane-automation/control-plane-automation-lcp-app/`, | |
"Foundry UI": `${ns}/hscp-${ns}/solution-control-plane/`, | |
"Keycloak Admin": `${ns}/hscp-${ns}/keycloak/admin/default/console/`, | |
}; | |
const serviceKey = await arg("Service", Object.keys(services)); | |
const url = new URL(services[serviceKey], baseUrl); | |
open(url.toString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment