Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pod.metadata.annotations = jobAnnotations;
let c1 = new kubernetes.V1Container();
c1.name = "brigaderun";
c1.image = brigadeImage;
if (jobShell == "") {
jobShell = "/bin/sh";
}
c1.command = [jobShell, "/hook/main.sh"];
c1.imagePullPolicy = imageForcePull ? "Always" : "IfNotPresent";
c1.securityContext = new kubernetes.V1SecurityContext();
// Setup pod container resources (requests and limits).
let resourceRequirements = new kubernetes.V1ResourceRequirements();
if (resourceRequests) {
resourceRequirements.requests = {
cpu: resourceRequests.cpu,
memory: resourceRequests.memory
};
}
if (resourceLimits) {
resourceRequirements.limits = {
cpu: resourceLimits.cpu,
memory: resourceLimits.memory
};
}
c1.resources = resourceRequirements;
pod.spec = new kubernetes.V1PodSpec();
pod.spec.containers = [c1];
};
s.spec = new kubernetes.V1PersistentVolumeClaimSpec();
s.spec.accessModes = ["ReadWriteMany"];
if (
this.project.kubernetes.cacheStorageClass &&
this.project.kubernetes.cacheStorageClass.length > 0
) {
s.spec.storageClassName = this.project.kubernetes.cacheStorageClass;
} else if (
this.options.defaultCacheStorageClass &&
this.options.defaultCacheStorageClass.length > 0
) {
s.spec.storageClassName = this.options.defaultCacheStorageClass;
}
let res = new kubernetes.V1ResourceRequirements();
res.requests = { storage: this.job.cache.size };
s.spec.resources = res;
return s;
}
}
protected buildPVC(size: string): kubernetes.V1PersistentVolumeClaim {
let s = new kubernetes.V1PersistentVolumeClaim();
s.metadata = new kubernetes.V1ObjectMeta();
s.metadata.name = this.name;
s.metadata.labels = {
heritage: "brigade",
component: "buildStorage",
project: this.proj.id,
worker: this.name,
build: this.build
};
s.spec = new kubernetes.V1PersistentVolumeClaimSpec();
s.spec.accessModes = ["ReadWriteMany"];
let res = new kubernetes.V1ResourceRequirements();
res.requests = { storage: size };
s.spec.resources = res;
if (this.proj.kubernetes.buildStorageClass.length > 0) {
s.spec.storageClassName = this.proj.kubernetes.buildStorageClass;
} else if (
this.options.defaultBuildStorageClass &&
this.options.defaultBuildStorageClass.length > 0
) {
s.spec.storageClassName = this.options.defaultBuildStorageClass;
}
return s;
}
}
}
if (project.repo.token) {
spec.env.push({
name: "BRIGADE_REPO_AUTH_TOKEN",
valueFrom: {
secretKeyRef: {
key: "github.token",
name: project.id
}
}
} as kubernetes.V1EnvVar);
}
spec.resources = new kubernetes.V1ResourceRequirements();
spec.resources.limits = {};
spec.resources.requests = {};
if (project.kubernetes.vcsSidecarResourcesLimitsCPU) {
spec.resources.limits["cpu"] =
project.kubernetes.vcsSidecarResourcesLimitsCPU;
}
if (project.kubernetes.vcsSidecarResourcesLimitsMemory) {
spec.resources.limits["memory"] =
project.kubernetes.vcsSidecarResourcesLimitsMemory;
}
if (project.kubernetes.vcsSidecarResourcesRequestsCPU) {
spec.resources.requests["cpu"] =
project.kubernetes.vcsSidecarResourcesRequestsCPU;
}
if (project.kubernetes.vcsSidecarResourcesRequestsMemory) {
spec.resources.requests["memory"] =