Skip to content

Commit

Permalink
fix: add 'Set as default context' option when creating sandbox connec…
Browse files Browse the repository at this point in the history
…tion (#87)

Signed-off-by: Denis Golovin <[email protected]>
  • Loading branch information
dgolovin authored Aug 1, 2023
1 parent 2489917 commit f5ed1c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f5ed1c3

Please sign in to comment.