aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/plugins/network
diff options
context:
space:
mode:
authorRitu Sood <ritu.sood@intel.com>2019-05-14 16:36:48 +0000
committerRitu Sood <ritu.sood@intel.com>2019-05-14 16:44:47 +0000
commit9b2e8b3e41dd89bd1cb9a661a10d5d76125af5b1 (patch)
tree92dc5ba622c8e9a746a1c025c7404a513df1c444 /src/k8splugin/plugins/network
parent52853025e3b450957fa3813cb4e9861f3573510a (diff)
Change format of the network file
Format of network file is different between KUD and Plugin. Change the format to match the format in KUD Change-Id: I360741b23e91e60d790a50a7eeb213576b0508b3 Signed-off-by: Ritu Sood <ritu.sood@intel.com> Issue-ID: MULTICLOUD-304
Diffstat (limited to 'src/k8splugin/plugins/network')
-rw-r--r--src/k8splugin/plugins/network/plugin.go7
-rw-r--r--src/k8splugin/plugins/network/plugin_test.go2
-rw-r--r--src/k8splugin/plugins/network/v1/types.go23
3 files changed, 7 insertions, 25 deletions
diff --git a/src/k8splugin/plugins/network/plugin.go b/src/k8splugin/plugins/network/plugin.go
index fb163189..74ac3473 100644
--- a/src/k8splugin/plugins/network/plugin.go
+++ b/src/k8splugin/plugins/network/plugin.go
@@ -42,12 +42,7 @@ func Create(data *utils.ResourceData, client kubernetes.Interface) (string, erro
return "", pkgerrors.Wrap(err, "Decode network object error")
}
- config, err := network.DecodeConfig()
- if err != nil {
- return "", pkgerrors.Wrap(err, "Fail to decode network's configuration")
- }
-
- cniType := config["cnitype"].(string)
+ cniType := network.Spec.CniType
typePlugin, ok := utils.LoadedPlugins[cniType+"-network"]
if !ok {
return "", pkgerrors.New("No plugin for resource " + cniType + " found")
diff --git a/src/k8splugin/plugins/network/plugin_test.go b/src/k8splugin/plugins/network/plugin_test.go
index 5bf649a9..e8e113b2 100644
--- a/src/k8splugin/plugins/network/plugin_test.go
+++ b/src/k8splugin/plugins/network/plugin_test.go
@@ -71,7 +71,7 @@ func TestCreateNetwork(t *testing.T) {
input: &utils.ResourceData{
YamlFilePath: "../../mock_files/mock_yamls/service.yaml",
},
- expectedError: "Fail to decode network's configuration: Invalid configuration value",
+ expectedError: "No plugin for resource",
},
{
label: "Fail to create a network",
diff --git a/src/k8splugin/plugins/network/v1/types.go b/src/k8splugin/plugins/network/v1/types.go
index b4efa39a..96484efa 100644
--- a/src/k8splugin/plugins/network/v1/types.go
+++ b/src/k8splugin/plugins/network/v1/types.go
@@ -14,9 +14,7 @@ limitations under the License.
package v1
import (
- "encoding/json"
- pkgerrors "github.com/pkg/errors"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -33,7 +31,11 @@ type OnapNetwork struct {
// OnapNetworkSpec is the spec for OnapNetwork resource
type OnapNetworkSpec struct {
- Config string `json:"config"`
+ CniType string `json:"cnitype"`
+ Name string `json:"name"`
+ Subnet string `json:"subnet"`
+ Gateway string `json:"gateway"`
+
}
// DeepCopyObject returns a generically typed copy of an object
@@ -50,18 +52,3 @@ func (in OnapNetwork) DeepCopyObject() runtime.Object {
func (in OnapNetwork) GetObjectKind() schema.ObjectKind {
return &in.TypeMeta
}
-
-// DecodeConfig content
-func (in OnapNetwork) DecodeConfig() (map[string]interface{}, error) {
- var raw map[string]interface{}
-
- if in.Spec.Config == "" {
- return nil, pkgerrors.New("Invalid configuration value")
- }
-
- if err := json.Unmarshal([]byte(in.Spec.Config), &raw); err != nil {
- return nil, pkgerrors.Wrap(err, "JSON unmarshalling error")
- }
-
- return raw, nil
-}