disable aws pipe for now

This commit is contained in:
Frostebite 2023-07-10 20:58:09 +01:00
parent 4128a154f6
commit 3488cec531
4 changed files with 6 additions and 7 deletions

BIN
dist/index.js generated vendored

Binary file not shown.

BIN
dist/index.js.map generated vendored

Binary file not shown.

View File

@ -22,6 +22,7 @@ class Kubernetes implements ProviderInterface {
public kubeConfig!: k8s.KubeConfig; public kubeConfig!: k8s.KubeConfig;
public kubeClient!: k8s.CoreV1Api; public kubeClient!: k8s.CoreV1Api;
public kubeClientBatch!: k8s.BatchV1Api; public kubeClientBatch!: k8s.BatchV1Api;
public rbacAuthorizationV1Api!: k8s.RbacAuthorizationV1Api;
public buildGuid: string = ''; public buildGuid: string = '';
public buildParameters!: BuildParameters; public buildParameters!: BuildParameters;
public pvcName: string = ''; public pvcName: string = '';
@ -40,6 +41,7 @@ class Kubernetes implements ProviderInterface {
this.kubeConfig.loadFromDefault(); this.kubeConfig.loadFromDefault();
this.kubeClient = this.kubeConfig.makeApiClient(k8s.CoreV1Api); this.kubeClient = this.kubeConfig.makeApiClient(k8s.CoreV1Api);
this.kubeClientBatch = this.kubeConfig.makeApiClient(k8s.BatchV1Api); this.kubeClientBatch = this.kubeConfig.makeApiClient(k8s.BatchV1Api);
this.rbacAuthorizationV1Api = this.kubeConfig.makeApiClient(k8s.RbacAuthorizationV1Api);
this.namespace = 'default'; this.namespace = 'default';
CloudRunnerLogger.log('Loaded default Kubernetes configuration for this environment'); CloudRunnerLogger.log('Loaded default Kubernetes configuration for this environment');
} }
@ -245,7 +247,7 @@ class Kubernetes implements ProviderInterface {
this.containerName, this.containerName,
); );
await new Promise((promise) => setTimeout(promise, 15000)); await new Promise((promise) => setTimeout(promise, 15000));
await KubernetesRole.createRole(this.serviceAccountName, this.namespace); await KubernetesRole.createRole(this.serviceAccountName, this.namespace, this.rbacAuthorizationV1Api);
const result = await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec); const result = await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
CloudRunnerLogger.log(`Build job created`); CloudRunnerLogger.log(`Build job created`);
await new Promise((promise) => setTimeout(promise, 5000)); await new Promise((promise) => setTimeout(promise, 5000));
@ -269,7 +271,7 @@ class Kubernetes implements ProviderInterface {
try { try {
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace); await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
await this.kubeClient.deleteNamespacedPod(this.podName, this.namespace); await this.kubeClient.deleteNamespacedPod(this.podName, this.namespace);
await KubernetesRole.deleteRole(this.serviceAccountName, this.namespace); await KubernetesRole.deleteRole(this.serviceAccountName, this.namespace, this.rbacAuthorizationV1Api);
} catch (error: any) { } catch (error: any) {
CloudRunnerLogger.log(`Failed to cleanup`); CloudRunnerLogger.log(`Failed to cleanup`);
if (error.response.body.reason !== `NotFound`) { if (error.response.body.reason !== `NotFound`) {

View File

@ -1,9 +1,7 @@
import { RbacAuthorizationV1Api } from '@kubernetes/client-node'; import { RbacAuthorizationV1Api } from '@kubernetes/client-node';
class KubernetesRole { class KubernetesRole {
static async createRole(serviceAccountName: string, namespace: string) { static async createRole(serviceAccountName: string, namespace: string, rbac: RbacAuthorizationV1Api) {
const rbac = new RbacAuthorizationV1Api();
// create admin kubernetes role and role binding // create admin kubernetes role and role binding
const roleBinding = { const roleBinding = {
apiVersion: 'rbac.authorization.k8s.io/v1', apiVersion: 'rbac.authorization.k8s.io/v1',
@ -47,8 +45,7 @@ class KubernetesRole {
return { roleBindingResponse, roleResponse }; return { roleBindingResponse, roleResponse };
} }
public static async deleteRole(serviceAccountName: string, namespace: string) { public static async deleteRole(serviceAccountName: string, namespace: string, rbac: RbacAuthorizationV1Api) {
const rbac = new RbacAuthorizationV1Api();
await rbac.deleteNamespacedRoleBinding(`${serviceAccountName}-admin`, namespace); await rbac.deleteNamespacedRoleBinding(`${serviceAccountName}-admin`, namespace);
await rbac.deleteNamespacedRole(`${serviceAccountName}-admin`, namespace); await rbac.deleteNamespacedRole(`${serviceAccountName}-admin`, namespace);
} }