summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/api/controllerhandler.go
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-05-12 14:28:33 -0700
committerEric Multanen <eric.w.multanen@intel.com>2020-05-12 17:04:18 -0700
commitbd3e69e7a26aaa00d3367f1eeb78e91e63ebd404 (patch)
treec3188dc4f1d5a1215d27cc73d1b2fac038f23ba8 /src/orchestrator/api/controllerhandler.go
parenteafedad99d1bc3ea0ffa2fb82bb8be6b7687e335 (diff)
Move controller module into separate package
Move the controller part of the module package into a separate controller package. Issue-ID: MULTICLOUD-1029 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: Id07c1012aeff8a72458b37d42671495510cade75
Diffstat (limited to 'src/orchestrator/api/controllerhandler.go')
-rw-r--r--src/orchestrator/api/controllerhandler.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/orchestrator/api/controllerhandler.go b/src/orchestrator/api/controllerhandler.go
index 1dad2bf8..5df691f3 100644
--- a/src/orchestrator/api/controllerhandler.go
+++ b/src/orchestrator/api/controllerhandler.go
@@ -23,7 +23,8 @@ import (
"github.com/gorilla/mux"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
- moduleLib "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module"
+ controller "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
+ mtypes "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/types"
pkgerrors "github.com/pkg/errors"
)
@@ -32,13 +33,13 @@ import (
type controllerHandler struct {
// Interface that implements controller operations
// We will set this variable with a mock interface for testing
- client moduleLib.ControllerManager
+ client controller.ControllerManager
}
// Check for valid format of input parameters
-func validateControllerInputs(c moduleLib.Controller) error {
+func validateControllerInputs(c controller.Controller) error {
// validate metadata
- err := moduleLib.IsValidMetadata(c.Metadata)
+ err := mtypes.IsValidMetadata(c.Metadata)
if err != nil {
return pkgerrors.Wrap(err, "Invalid controller metadata")
}
@@ -54,7 +55,7 @@ func validateControllerInputs(c moduleLib.Controller) error {
}
found := false
- for _, val := range moduleLib.CONTROLLER_TYPES {
+ for _, val := range controller.CONTROLLER_TYPES {
if c.Spec.Type == val {
found = true
break
@@ -64,7 +65,7 @@ func validateControllerInputs(c moduleLib.Controller) error {
return pkgerrors.Errorf("Invalid controller type: %v", c.Spec.Type)
}
- errs = validation.IsValidNumber(c.Spec.Priority, moduleLib.MinControllerPriority, moduleLib.MaxControllerPriority)
+ errs = validation.IsValidNumber(c.Spec.Priority, controller.MinControllerPriority, controller.MaxControllerPriority)
if len(errs) > 0 {
return pkgerrors.Errorf("Invalid controller priority = [%v], errors: %v", c.Spec.Priority, errs)
}
@@ -74,7 +75,7 @@ func validateControllerInputs(c moduleLib.Controller) error {
// Create handles creation of the controller entry in the database
func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request) {
- var m moduleLib.Controller
+ var m controller.Controller
err := json.NewDecoder(r.Body).Decode(&m)
switch {
@@ -109,7 +110,7 @@ func (h controllerHandler) createHandler(w http.ResponseWriter, r *http.Request)
// Put handles creation or update of the controller entry in the database
func (h controllerHandler) putHandler(w http.ResponseWriter, r *http.Request) {
- var m moduleLib.Controller
+ var m controller.Controller
vars := mux.Vars(r)
name := vars["controller-name"]