diff --git a/package.json b/package.json index d443c20..01eb004 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,12 @@ "scope": "KubernetesProviderConnectionFactory", "description": "Context name for Developer Sandbox to easily find it in your Kubernetes contexts" }, + "redhat.sandbox.context.default": { + "type": "boolean", + "default": false, + "scope": "KubernetesProviderConnectionFactory", + "description": "Set as current context" + }, "redhat.sandbox.login.command": { "type": "string", "default": "", diff --git a/src/extension.ts b/src/extension.ts index b9411b6..14b5459 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -244,6 +244,7 @@ export async function activate(extensionContext: extensionApi.ExtensionContext): const LoginCommandParam = 'redhat.sandbox.login.command'; const ContextNameParam = 'redhat.sandbox.context.name'; + const DefaultContextParam = 'redhat.sandbox.context.default'; const kubeconfigUri = extensionApi.kubernetes.getKubeconfig(); const kubeconfigFile = kubeconfigUri.fsPath; @@ -306,6 +307,11 @@ export async function activate(extensionContext: extensionApi.ExtensionContext): namespace: `${username}-dev`, }); + console.log('Default context =>', params[DefaultContextParam]); + if (params[DefaultContextParam] === 'on') { + config.setCurrentContext(params[ContextNameParam]); + } + kubeconfig.exportToFile(config, kubeconfigFile); await registerConnection(params[ContextNameParam], apiURL, token);