From da7c7f5c28c27fa78784c1d81d209943aefe83ed Mon Sep 17 00:00:00 2001 From: rohank07 Date: Wed, 5 Oct 2022 10:50:21 -0400 Subject: [PATCH] add: empty dir --- .github/workflows/publish.yml | 2 +- notebooks.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c5152149..4bd5832b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,7 +2,7 @@ name: publish on: push: branches: - - main + - downward-api env: REGISTRY_NAME: k8scc01covidacr diff --git a/notebooks.go b/notebooks.go index b55f8e47..ec171a68 100644 --- a/notebooks.go +++ b/notebooks.go @@ -640,6 +640,22 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) { Value: req.Language, }) } + // Add empty dir on protected-b notebooks + if _, ok := notebook.GetObjectMeta().GetLabels()["notebook.statcan.gc.ca/protected-b"]; ok { + + notebook.Spec.Template.Spec.Volumes = append(notebook.Spec.Template.Spec.Volumes, corev1.Volume{ + Name: "protb-nb", + VolumeSource: corev1.VolumeSource{ + EmptyDir: &corev1.EmptyDirVolumeSource{ + Medium: corev1.StorageMediumMemory, + }, + }, + }) + notebook.Spec.Template.Spec.Containers[0].VolumeMounts = append(notebook.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ + Name: "protb-nb", + MountPath: "/etc/protb", + }) + } // Add imagePullPolicy if req.ImagePullPolicy == "Always" || req.ImagePullPolicy == "Never" || req.ImagePullPolicy == "IfNotPresent" {