...
1 package utils
2
3 import (
4 "fmt"
5
6 "edge-infra.dev/pkg/edge/api/graph/model"
7 )
8
9 func CreateNamespaceModel(namespaceEdgeID string, bannerEdgeID string, name string, workload model.WorkloadType) model.Namespace {
10 return model.Namespace{
11 NamespaceEdgeID: namespaceEdgeID,
12 BannerEdgeID: bannerEdgeID,
13 Name: name,
14 Workload: workload,
15 }
16 }
17
18 func ValidateNamespace(namespace *model.Namespace) error {
19 if namespace.Workload != model.WorkloadTypeTenant {
20 return fmt.Errorf("can only create a Namespace with the tenant workload type right now")
21 }
22
23
24
25 if namespace.Name == "" {
26 return fmt.Errorf("cannot create a Namespace with an empty string for a name")
27 }
28 return nil
29 }
30
View as plain text