aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/infra
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-04-16 10:44:06 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-04-22 23:30:24 -0700
commit0b59486c82a9786c85438f6352636b19b83e1021 (patch)
tree06af2aa3929357f9cc4e328cd09c7fce554cbf43 /src/orchestrator/pkg/infra
parent9e086eb494441de0967b84d0f04d3b4dc7e753c2 (diff)
Controller API support
Add controller API support as baseline for adding gRPC framework. Issue-ID: MULTICLOUD-1019 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: Ifd522a0eefbb8e54be45cc62003d3809283c9bfe
Diffstat (limited to 'src/orchestrator/pkg/infra')
-rw-r--r--src/orchestrator/pkg/infra/validation/validation.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/orchestrator/pkg/infra/validation/validation.go b/src/orchestrator/pkg/infra/validation/validation.go
index 448ea5de..c43d29ec 100644
--- a/src/orchestrator/pkg/infra/validation/validation.go
+++ b/src/orchestrator/pkg/infra/validation/validation.go
@@ -23,6 +23,7 @@ import (
"io"
"net"
"regexp"
+ "strconv"
"strings"
pkgerrors "github.com/pkg/errors"
@@ -280,6 +281,28 @@ func IsValidNumber(value, min, max int) []string {
return errs
}
+func IsValidNumberStr(value string, min, max int) []string {
+ var errs []string
+
+ if min > max {
+ errs = append(errs, "invalid constraints")
+ return errs
+ }
+
+ n, err := strconv.Atoi(value)
+ if err != nil {
+ errs = append(errs, err.Error())
+ return errs
+ }
+ if n < min {
+ errs = append(errs, "value less than minimum")
+ }
+ if n > max {
+ errs = append(errs, "value greater than maximum")
+ }
+ return errs
+}
+
/*
IsValidParameterPresent method takes in a vars map and a array of string parameters
that you expect to be present in the GET request.