aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg
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/pkg
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/pkg')
-rw-r--r--src/orchestrator/pkg/module/controller/controller.go (renamed from src/orchestrator/pkg/module/controller.go)7
-rw-r--r--src/orchestrator/pkg/module/controller/controller_test.go (renamed from src/orchestrator/pkg/module/controller_test.go)9
-rw-r--r--src/orchestrator/pkg/module/module.go43
-rw-r--r--src/orchestrator/pkg/module/types/types.go58
4 files changed, 70 insertions, 47 deletions
diff --git a/src/orchestrator/pkg/module/controller.go b/src/orchestrator/pkg/module/controller/controller.go
index 6827af87..c4957413 100644
--- a/src/orchestrator/pkg/module/controller.go
+++ b/src/orchestrator/pkg/module/controller/controller.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package module
+package controller
import (
"encoding/json"
@@ -22,14 +22,15 @@ import (
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
rpc "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/rpc"
+ mtypes "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/types"
pkgerrors "github.com/pkg/errors"
)
// Controller contains the parameters needed for Controllers
// It implements the interface for managing the Controllers
type Controller struct {
- Metadata Metadata `json:"metadata"`
- Spec ControllerSpec `json:"spec"`
+ Metadata mtypes.Metadata `json:"metadata"`
+ Spec ControllerSpec `json:"spec"`
}
type ControllerSpec struct {
diff --git a/src/orchestrator/pkg/module/controller_test.go b/src/orchestrator/pkg/module/controller/controller_test.go
index a13f43a5..44e7a0ca 100644
--- a/src/orchestrator/pkg/module/controller_test.go
+++ b/src/orchestrator/pkg/module/controller/controller_test.go
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package module
+package controller
import (
"reflect"
@@ -22,6 +22,7 @@ import (
"testing"
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/db"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/types"
pkgerrors "github.com/pkg/errors"
)
@@ -37,7 +38,7 @@ func TestCreateController(t *testing.T) {
{
label: "Create Controller",
inp: Controller{
- Metadata: Metadata{
+ Metadata: types.Metadata{
Name: "testController",
},
Spec: ControllerSpec{
@@ -46,7 +47,7 @@ func TestCreateController(t *testing.T) {
},
},
expected: Controller{
- Metadata: Metadata{
+ Metadata: types.Metadata{
Name: "testController",
},
Spec: ControllerSpec{
@@ -102,7 +103,7 @@ func TestGetController(t *testing.T) {
label: "Get Controller",
name: "testController",
expected: Controller{
- Metadata: Metadata{
+ Metadata: types.Metadata{
Name: "testController",
},
Spec: ControllerSpec{
diff --git a/src/orchestrator/pkg/module/module.go b/src/orchestrator/pkg/module/module.go
index 463a55b3..5ac704e6 100644
--- a/src/orchestrator/pkg/module/module.go
+++ b/src/orchestrator/pkg/module/module.go
@@ -17,8 +17,7 @@
package module
import (
- "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
- pkgerrors "github.com/pkg/errors"
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/module/controller"
)
// Client for using the services in the orchestrator
@@ -26,7 +25,7 @@ type Client struct {
Project *ProjectClient
CompositeApp *CompositeAppClient
App *AppClient
- Controller *ControllerClient
+ Controller *controller.ControllerClient
GenericPlacementIntent *GenericPlacementIntentClient
AppIntent *AppIntentClient
DeploymentIntentGroup *DeploymentIntentGroupClient
@@ -43,7 +42,7 @@ func NewClient() *Client {
c.Project = NewProjectClient()
c.CompositeApp = NewCompositeAppClient()
c.App = NewAppClient()
- c.Controller = NewControllerClient()
+ c.Controller = controller.NewControllerClient()
c.GenericPlacementIntent = NewGenericPlacementIntentClient()
c.AppIntent = NewAppIntentClient()
c.DeploymentIntentGroup = NewDeploymentIntentGroupClient()
@@ -54,39 +53,3 @@ func NewClient() *Client {
c.Instantiation = NewInstantiationClient()
return c
}
-
-// 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" yaml:"name"`
- Description string `json:"description" yaml:"-"`
- UserData1 string `json:"userData1" yaml:"-"`
- UserData2 string `json:"userData2" yaml:"-"`
-}
-
-// 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
-}
diff --git a/src/orchestrator/pkg/module/types/types.go b/src/orchestrator/pkg/module/types/types.go
new file mode 100644
index 00000000..0159444d
--- /dev/null
+++ b/src/orchestrator/pkg/module/types/types.go
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2020 Intel Corporation, Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package types
+
+import (
+ "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/validation"
+ pkgerrors "github.com/pkg/errors"
+)
+
+// 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" yaml:"name"`
+ Description string `json:"description" yaml:"-"`
+ UserData1 string `json:"userData1" yaml:"-"`
+ UserData2 string `json:"userData2" yaml:"-"`
+}
+
+// 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
+}