summaryrefslogtreecommitdiffstats
path: root/src/ncm/pkg/module/module_definitions.go
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-03-19 16:07:43 -0700
committerRitu Sood <Ritu.Sood@intel.com>2020-04-10 20:36:32 +0000
commit335c7cca38eb804c2977e4dd9af9efa0ea7ef82b (patch)
tree1e1adfa51e7dfaa9d8b57c7d5890537674e4f341 /src/ncm/pkg/module/module_definitions.go
parent107142787e331ca565c166c72ae5605621d2d2ee (diff)
APIs for network, workload and interface intents
Includes network controller intent and underlying network workload intent and workload interface intent APIs. Issue-ID: MULTICLOUD-1029 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: I9bb34e42785b16f39af81335b1f94dd5bb15d931
Diffstat (limited to 'src/ncm/pkg/module/module_definitions.go')
-rw-r--r--src/ncm/pkg/module/module_definitions.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ncm/pkg/module/module_definitions.go b/src/ncm/pkg/module/module_definitions.go
index 1e839014..729a9dbd 100644
--- a/src/ncm/pkg/module/module_definitions.go
+++ b/src/ncm/pkg/module/module_definitions.go
@@ -32,6 +32,9 @@ const CNI_TYPE_OVN4NFV string = "ovn4nfv"
var CNI_TYPES = [...]string{CNI_TYPE_OVN4NFV}
// It implements the interface for managing the ClusterProviders
+const MAX_DESCRIPTION_LEN int = 1024
+const MAX_USERDATA_LEN int = 4096
+
type Metadata struct {
Name string `json:"name"`
Description string `json:"description"`
@@ -65,6 +68,31 @@ type Vlan struct {
NodeLabelList []string `json:"nodeLabelList"`
}
+// Check for valid format Metadata
+func IsValidMetadata(metadata Metadata) error {
+ errs := validation.IsValidName(metadata.Name)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata name=[%v], errors: %v", metadata.Name, errs)
+ }
+
+ errs = validation.IsValidString(metadata.Description, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.Description, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData1, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData1, errs)
+ }
+
+ errs = validation.IsValidString(metadata.UserData2, 0, MAX_DESCRIPTION_LEN, validation.VALID_ANY_STR)
+ if len(errs) > 0 {
+ return pkgerrors.Errorf("Invalid Metadata description=[%v], errors: %v", metadata.UserData2, errs)
+ }
+
+ return nil
+}
+
// Check for valid format of an Ipv4Subnet
func ValidateSubnet(sub Ipv4Subnet) error {
// verify subnet is in valid cidr format