Skip to content

Commit

Permalink
Merge pull request #66 from StatCan/add-prob-volume-label
Browse files Browse the repository at this point in the history
add: prob volume label
  • Loading branch information
Jose-Matsuda authored Sep 29, 2021
2 parents e0a6302 + b4fe1fe commit 24e2ce1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions notebooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (s *server) GetNotebooks(w http.ResponseWriter, r *http.Request) {
func (s *server) handleVolume(ctx context.Context, req volumerequest, notebook *kubeflowv1.Notebook) error {
var pvc = corev1.PersistentVolumeClaim{}
if req.Type == VolumeTypeNew {
if notebook.GetObjectMeta().GetLabels()["notebook.statcan.gc.ca/protected-b"] == "true" {
if _, ok := notebook.GetObjectMeta().GetLabels()["notebook.statcan.gc.ca/protected-b"]; ok {
pvc = corev1.PersistentVolumeClaim{
ObjectMeta: v1.ObjectMeta{
Name: req.Name,
Expand Down Expand Up @@ -380,6 +380,17 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
notebook.Spec.Template.Spec.Containers[0].Resources.Limits[corev1.ResourceMemory] = req.Memory
}

// Add configuration items
if s.Config.SpawnerFormDefaults.Configurations.ReadOnly {
for _, config := range s.Config.SpawnerFormDefaults.Configurations.Value {
notebook.ObjectMeta.Labels[config] = "true"
}
} else {
for _, config := range req.Configurations {
notebook.ObjectMeta.Labels[config] = "true"
}
}

// Add workspace volume
if s.Config.SpawnerFormDefaults.WorkspaceVolume.ReadOnly {
size, err := resource.ParseQuantity(s.Config.SpawnerFormDefaults.WorkspaceVolume.Value.Size.Value)
Expand Down Expand Up @@ -482,17 +493,6 @@ func (s *server) NewNotebook(w http.ResponseWriter, r *http.Request) {
}
}

// Add configuration items
if s.Config.SpawnerFormDefaults.Configurations.ReadOnly {
for _, config := range s.Config.SpawnerFormDefaults.Configurations.Value {
notebook.ObjectMeta.Labels[config] = "true"
}
} else {
for _, config := range req.Configurations {
notebook.ObjectMeta.Labels[config] = "true"
}
}

//Add Language
//Validate that the language format is valid (language[_territory])
match, err := regexp.MatchString("^[[:alpha:]]{2}(_[[:alpha:]]{2})?$", req.Language)
Expand Down

0 comments on commit 24e2ce1

Please sign in to comment.