Skip to content

Commit

Permalink
Don't prompt before switching over to service account on Sandbox
Browse files Browse the repository at this point in the history
Per our discussion, this makes the experience smoother

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 authored and vrubezhny committed Feb 21, 2024
1 parent 8adf65d commit 84c8b61
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/openshift/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,7 @@ export class Cluster extends OpenShiftItem {
try {
await Oc.Instance.loginWithToken(clusterURL, ocToken);
if (Cluster.isOpenShiftSandbox(clusterURL)) {
const YES = 'Yes';
const result = await window.showInformationMessage('OpenShift Sandbox logs you out after 15 minutes. Would you like to switch to a service account to prevent this?', YES, 'No');
if (result === YES) {
await Cluster.installPipelineUserContext();
}
await Cluster.installPipelineUserContext();
}
return Cluster.loginMessage(clusterURL);
} catch (error) {
Expand Down Expand Up @@ -913,6 +909,11 @@ export class Cluster extends OpenShiftItem {
const sandboxUser = currentCtxObj.context.user;
const sandboxUserObj = kcActual.users.find(user => user.name === sandboxUser);

const serviceAccounts = await Oc.Instance.getKubernetesObjects('ServiceAccount');
const pipelineServiceAccount = serviceAccounts.find(serviceAccount => serviceAccount.metadata.name === 'pipeline');
if (!pipelineServiceAccount) {
return;
}
const secrets = await Oc.Instance.getKubernetesObjects('Secret');
const pipelineTokenSecret = secrets.find((secret) => secret.metadata.name.startsWith('pipeline-token')) as any;
const pipelineToken = Buffer.from(pipelineTokenSecret.data.token, 'base64').toString();
Expand Down

0 comments on commit 84c8b61

Please sign in to comment.