disable aws pipe for now

pull/531/head
Frostebite 2023-07-10 20:58:09 +01:00
parent 4128a154f6
commit 3488cec531
4 changed files with 13 additions and 16 deletions

14
dist/index.js generated vendored
View File

@ -3278,6 +3278,7 @@ class Kubernetes {
this.kubeConfig.loadFromDefault();
this.kubeClient = this.kubeConfig.makeApiClient(k8s.CoreV1Api);
this.kubeClientBatch = this.kubeConfig.makeApiClient(k8s.BatchV1Api);
this.rbacAuthorizationV1Api = this.kubeConfig.makeApiClient(k8s.RbacAuthorizationV1Api);
this.namespace = 'default';
cloud_runner_logger_1.default.log('Loaded default Kubernetes configuration for this environment');
}
@ -3410,7 +3411,7 @@ class Kubernetes {
try {
const jobSpec = kubernetes_job_spec_factory_1.default.getJobSpec(commands, image, mountdir, workingdir, environment, secrets, this.buildGuid, this.buildParameters, this.secretName, this.pvcName, this.jobName, k8s, this.containerName);
await new Promise((promise) => setTimeout(promise, 15000));
await kubernetes_role_1.KubernetesRole.createRole(this.serviceAccountName, this.namespace);
await kubernetes_role_1.KubernetesRole.createRole(this.serviceAccountName, this.namespace, this.rbacAuthorizationV1Api);
const result = await this.kubeClientBatch.createNamespacedJob(this.namespace, jobSpec);
cloud_runner_logger_1.default.log(`Build job created`);
await new Promise((promise) => setTimeout(promise, 5000));
@ -3432,7 +3433,7 @@ class Kubernetes {
try {
await this.kubeClientBatch.deleteNamespacedJob(this.jobName, this.namespace);
await this.kubeClient.deleteNamespacedPod(this.podName, this.namespace);
await kubernetes_role_1.KubernetesRole.deleteRole(this.serviceAccountName, this.namespace);
await kubernetes_role_1.KubernetesRole.deleteRole(this.serviceAccountName, this.namespace, this.rbacAuthorizationV1Api);
}
catch (error) {
cloud_runner_logger_1.default.log(`Failed to cleanup`);
@ -3631,16 +3632,14 @@ exports["default"] = KubernetesPods;
/***/ }),
/***/ 88231:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
/***/ ((__unused_webpack_module, exports) => {
"use strict";
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.KubernetesRole = void 0;
const client_node_1 = __nccwpck_require__(89679);
class KubernetesRole {
static async createRole(serviceAccountName, namespace) {
const rbac = new client_node_1.RbacAuthorizationV1Api();
static async createRole(serviceAccountName, namespace, rbac) {
// create admin kubernetes role and role binding
const roleBinding = {
apiVersion: 'rbac.authorization.k8s.io/v1',
@ -3681,8 +3680,7 @@ class KubernetesRole {
const roleResponse = await rbac.createNamespacedRole(namespace, role);
return { roleBindingResponse, roleResponse };
}
static async deleteRole(serviceAccountName, namespace) {
const rbac = new client_node_1.RbacAuthorizationV1Api();
static async deleteRole(serviceAccountName, namespace, rbac) {
await rbac.deleteNamespacedRoleBinding(`${serviceAccountName}-admin`, namespace);
await rbac.deleteNamespacedRole(`${serviceAccountName}-admin`, namespace);
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

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

View File

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