Skip to content

Commit 782e370

Browse files
committed
Return error if default exists
1 parent b384fc9 commit 782e370

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

notebooks.go

+14
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,20 @@ func (s *server) createDefaultNotebook(namespace string, notebookNames []string,
499499
var notebook newnotebookrequest
500500
notebookname := namespace + "-notebook"
501501

502+
// Check if a default notebook exists
503+
notebooks, errNotebook := s.listers.notebooks.Notebooks(namespace).List(labels.Everything())
504+
if errNotebook != nil {
505+
return notebook, errNotebook
506+
}
507+
508+
for _, notebookItem := range notebooks {
509+
if val, ok := notebookItem.Labels["notebook.statcan.gc.ca/default-notebook"]; ok {
510+
if val == "true" {
511+
return notebook, errors.New("Notebook Already Exists")
512+
}
513+
}
514+
}
515+
502516
// updates the notebook name with a trailing number to avoid duplicate values
503517
notebookname = s.enumerateNames(notebookname, notebookNames)
504518

0 commit comments

Comments
 (0)