Skip to content

Commit f564b41

Browse files
committed
[build] Build errors on updating @kubernetes/client-node to v.1.x #5086
Fixes: #5086 Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
1 parent d7c16e8 commit f564b41

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

src/openshift/cluster.ts

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,24 +1175,17 @@ export class Cluster extends OpenShiftItem implements Disposable {
11751175

11761176
static prepareSSOInKubeConfig(proxy: string, username: string, accessToken: string): KubeConfig {
11771177
const kcu = new KubeConfig();
1178-
const clusterProxy = {
1179-
name: 'sandbox-proxy',
1180-
server: proxy,
1181-
};
1182-
const user = {
1183-
name: 'sso-user',
1184-
token: accessToken,
1185-
};
1186-
const context = {
1187-
cluster: clusterProxy.name,
1188-
name: 'sandbox-proxy-context',
1189-
user: user.name,
1190-
namespace: `${username}-dev`,
1191-
};
1192-
kcu.addCluster(clusterProxy);
1193-
kcu.addUser(user)
1194-
kcu.addContext(context);
1195-
kcu.setCurrentContext(context.name);
1178+
kcu.loadFromOptions({
1179+
clusters: [{ name: 'sandbox-proxy', server: proxy, skipTLSVerify: false }],
1180+
users: [{ name: 'sso-user', token: accessToken }],
1181+
contexts: [{
1182+
name: 'sandbox-proxy-context',
1183+
cluster: 'sandbox-proxy',
1184+
user: 'sso-user',
1185+
namespace: `${username}-dev`,
1186+
}],
1187+
currentContext: 'sandbox-proxy-context',
1188+
});
11961189
return kcu;
11971190
}
11981191

@@ -1211,24 +1204,24 @@ export class Cluster extends OpenShiftItem implements Disposable {
12111204
} as V1Secret
12121205

12131206
try {
1214-
await k8sApi.createNamespacedSecret(`${username}-dev`, v1Secret);
1207+
await k8sApi.createNamespacedSecret({ namespace: `${username}-dev`, body: v1Secret });
12151208
} catch {
12161209
// Ignore
12171210
}
1218-
const newSecrets = await k8sApi.listNamespacedSecret(`${username}-dev`);
1219-
return newSecrets?.body.items.find((secret) => secret.metadata.name === `pipeline-secret-${username}-dev`);
1211+
const newSecrets = await k8sApi.listNamespacedSecret({ namespace: `${username}-dev` });
1212+
return newSecrets?.items.find((secret) => secret.metadata.name === `pipeline-secret-${username}-dev`);
12201213
}
12211214

12221215
static async getPipelineServiceAccountToken(k8sApi: CoreV1Api, username: string): Promise<string> {
12231216
try {
1224-
const serviceAccounts = await k8sApi.listNamespacedServiceAccount(`${username}-dev`);
1225-
const pipelineServiceAccount = serviceAccounts.body.items.find(serviceAccount => serviceAccount.metadata.name === 'pipeline');
1217+
const serviceAccounts = await k8sApi.listNamespacedServiceAccount({ namespace: `${username}-dev` });
1218+
const pipelineServiceAccount = serviceAccounts.items.find(serviceAccount => serviceAccount.metadata.name === 'pipeline');
12261219
if (!pipelineServiceAccount) {
12271220
return;
12281221
}
12291222

1230-
const secrets = await k8sApi.listNamespacedSecret(`${username}-dev`);
1231-
let pipelineTokenSecret = secrets?.body.items.find((secret) => secret.metadata.name === `pipeline-secret-${username}-dev`);
1223+
const secrets = await k8sApi.listNamespacedSecret({ namespace: `${username}-dev` });
1224+
let pipelineTokenSecret = secrets?.items.find((secret) => secret.metadata.name === `pipeline-secret-${username}-dev`);
12321225
if (!pipelineTokenSecret) {
12331226
pipelineTokenSecret = await Cluster.installPipelineSecretToken(k8sApi, pipelineServiceAccount, username);
12341227
if (!pipelineTokenSecret) {

src/webview/cluster/clusterViewLoader.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,8 @@ async function clusterEditorMessageListener (event: any ): Promise<any> {
116116
const oauthInfo = await sandboxAPI.getOauthServerInfo(signupStatus.apiEndpoint);
117117
const makeCoreV1ApiClient = ((proxy: string, username: string, accessToken: string): CoreV1Api => {
118118
const kcu = Cluster.prepareSSOInKubeConfig(proxy, username, accessToken);
119-
const apiClient = new CoreV1Api(proxy);
120-
apiClient.setDefaultAuthentication(kcu);
121-
return apiClient;
122-
});
119+
return kcu.makeApiClient(CoreV1Api);
120+
});
123121
const pipelineAccountToken = await Cluster.getPipelineServiceAccountToken(
124122
makeCoreV1ApiClient(signupStatus.proxyURL, signupStatus.compliantUsername,
125123
(sessionCheck as any).idToken),

0 commit comments

Comments
 (0)