aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2019-04-02 17:20:12 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-02 17:20:12 +0000
commit408200f3c402fa31fc465b5cd8b2ea4340048468 (patch)
tree8de5c58ed150e3f2339ad29b78c47dc847f624fe /src
parenta1e2fb3ff225509885f82311096d0353e1117877 (diff)
parentf3875e13c7a6675aa980c29580daae42a32eb97f (diff)
Merge "Make profile key explicit"
Diffstat (limited to 'src')
-rw-r--r--src/k8splugin/api/handler_test.go4
-rw-r--r--src/k8splugin/api/profilehandler.go2
-rw-r--r--src/k8splugin/api/profilehandler_test.go8
-rw-r--r--src/k8splugin/internal/app/vnfhelper.go4
-rw-r--r--src/k8splugin/internal/app/vnfhelper_test.go4
-rw-r--r--src/k8splugin/internal/rb/profile.go44
-rw-r--r--src/k8splugin/internal/rb/profile_test.go22
7 files changed, 44 insertions, 44 deletions
diff --git a/src/k8splugin/api/handler_test.go b/src/k8splugin/api/handler_test.go
index df4d03c3..cb377ea5 100644
--- a/src/k8splugin/api/handler_test.go
+++ b/src/k8splugin/api/handler_test.go
@@ -125,7 +125,7 @@ func TestCreateHandler(t *testing.T) {
mockStore: &db.MockDB{
Items: map[string]map[string][]byte{
rb.ProfileKey{RBName: "testresourcebundle", RBVersion: "v1",
- Name: "profile1"}.String(): {
+ ProfileName: "profile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"profile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -270,7 +270,7 @@ func TestCreateHandler(t *testing.T) {
mockStore: &db.MockDB{
Items: map[string]map[string][]byte{
rb.ProfileKey{RBName: "test-rbdef", RBVersion: "v1",
- Name: "profile1"}.String(): {
+ ProfileName: "profile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"profile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
diff --git a/src/k8splugin/api/profilehandler.go b/src/k8splugin/api/profilehandler.go
index 2c15a440..362289ff 100644
--- a/src/k8splugin/api/profilehandler.go
+++ b/src/k8splugin/api/profilehandler.go
@@ -49,7 +49,7 @@ func (h rbProfileHandler) createHandler(w http.ResponseWriter, r *http.Request)
}
// Name is required.
- if p.Name == "" {
+ if p.ProfileName == "" {
http.Error(w, "Missing name in POST request", http.StatusBadRequest)
return
}
diff --git a/src/k8splugin/api/profilehandler_test.go b/src/k8splugin/api/profilehandler_test.go
index 4e346862..e6a87129 100644
--- a/src/k8splugin/api/profilehandler_test.go
+++ b/src/k8splugin/api/profilehandler_test.go
@@ -92,7 +92,7 @@ func TestRBProfileCreateHandler(t *testing.T) {
expected: rb.Profile{
RBName: "testresource_bundle_definition",
RBVersion: "v1",
- Name: "profile1",
+ ProfileName: "profile1",
ReleaseName: "testprofilereleasename",
Namespace: "default",
KubernetesVersion: "1.12.3",
@@ -103,7 +103,7 @@ func TestRBProfileCreateHandler(t *testing.T) {
{
RBName: "testresource_bundle_definition",
RBVersion: "v1",
- Name: "profile1",
+ ProfileName: "profile1",
ReleaseName: "testprofilereleasename",
Namespace: "default",
KubernetesVersion: "1.12.3",
@@ -156,7 +156,7 @@ func TestRBProfileGetHandler(t *testing.T) {
expected: rb.Profile{
RBName: "testresource_bundle_definition",
RBVersion: "v1",
- Name: "profile1",
+ ProfileName: "profile1",
ReleaseName: "testprofilereleasename",
Namespace: "default",
KubernetesVersion: "1.12.3",
@@ -168,7 +168,7 @@ func TestRBProfileGetHandler(t *testing.T) {
{
RBName: "testresource_bundle_definition",
RBVersion: "v1",
- Name: "profile1",
+ ProfileName: "profile1",
ReleaseName: "testprofilereleasename",
Namespace: "default",
KubernetesVersion: "1.12.3",
diff --git a/src/k8splugin/internal/app/vnfhelper.go b/src/k8splugin/internal/app/vnfhelper.go
index 0a867090..c5783d69 100644
--- a/src/k8splugin/internal/app/vnfhelper.go
+++ b/src/k8splugin/internal/app/vnfhelper.go
@@ -47,7 +47,7 @@ func ensuresNamespace(namespace string, kubeclient kubernetes.Interface) error {
return pkgerrors.Wrap(err, "Error fetching get namespace function")
}
- ns, _ := symGetNamespaceFunc.(func(string, string, kubernetes.Interface) (string, error))(
+ ns, _ := symGetNamespaceFunc.(func(string, string, kubernetes.Interface) (string, error))(
namespace, namespace, kubeclient)
if ns == "" {
@@ -80,7 +80,7 @@ var CreateVNF = func(csarID string, cloudRegionID string, profile rb.Profile, ku
externalVNFID := generateExternalVNFID()
internalVNFID := cloudRegionID + "-" + profile.Namespace + "-" + externalVNFID
- metaMap, err := rb.NewProfileClient().Resolve(profile.RBName, profile.RBVersion, profile.Name, overrideValues)
+ metaMap, err := rb.NewProfileClient().Resolve(profile.RBName, profile.RBVersion, profile.ProfileName, overrideValues)
if err != nil {
return "", nil, pkgerrors.Wrap(err, "Error resolving helm charts")
}
diff --git a/src/k8splugin/internal/app/vnfhelper_test.go b/src/k8splugin/internal/app/vnfhelper_test.go
index 6722bfa8..7587e5d6 100644
--- a/src/k8splugin/internal/app/vnfhelper_test.go
+++ b/src/k8splugin/internal/app/vnfhelper_test.go
@@ -84,7 +84,7 @@ func TestCreateVNF(t *testing.T) {
db.DBconn = &db.MockDB{
Items: map[string]map[string][]byte{
rb.ProfileKey{RBName: "test-rbdef", RBVersion: "v1",
- Name: "profile1"}.String(): {
+ ProfileName: "profile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"profile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -194,7 +194,7 @@ func TestCreateVNF(t *testing.T) {
rb.Profile{
RBName: "test-rbdef",
RBVersion: "v1",
- Name: "profile1",
+ ProfileName: "profile1",
ReleaseName: "testprofilereleasename",
Namespace: "testnamespace",
KubernetesVersion: "1.12.3",
diff --git a/src/k8splugin/internal/rb/profile.go b/src/k8splugin/internal/rb/profile.go
index 572a175c..679815ac 100644
--- a/src/k8splugin/internal/rb/profile.go
+++ b/src/k8splugin/internal/rb/profile.go
@@ -33,7 +33,7 @@ import (
type Profile struct {
RBName string `json:"rb-name"`
RBVersion string `json:"rb-version"`
- Name string `json:"profile-name"`
+ ProfileName string `json:"profile-name"`
ReleaseName string `json:"release-name"`
Namespace string `json:"namespace"`
KubernetesVersion string `json:"kubernetes-version"`
@@ -49,9 +49,9 @@ type ProfileManager interface {
}
type ProfileKey struct {
- RBName string `json:"rb-name"`
- RBVersion string `json:"rb-version"`
- Name string `json:"profile-name"`
+ RBName string `json:"rb-name"`
+ RBVersion string `json:"rb-version"`
+ ProfileName string `json:"profile-name"`
}
// We will use json marshalling to convert to string to
@@ -88,12 +88,12 @@ func NewProfileClient() *ProfileClient {
func (v *ProfileClient) Create(p Profile) (Profile, error) {
// Name is required
- if p.Name == "" {
+ if p.ProfileName == "" {
return Profile{}, pkgerrors.New("Name is required for Resource Bundle Profile")
}
//Check if profile already exists
- _, err := v.Get(p.RBName, p.RBVersion, p.Name)
+ _, err := v.Get(p.RBName, p.RBVersion, p.ProfileName)
if err == nil {
return Profile{}, pkgerrors.New("Profile already exists for this Definition")
}
@@ -106,13 +106,13 @@ func (v *ProfileClient) Create(p Profile) (Profile, error) {
//If release-name is not provided, we store name instead
if p.ReleaseName == "" {
- p.ReleaseName = p.Name
+ p.ReleaseName = p.ProfileName
}
key := ProfileKey{
- RBName: p.RBName,
- RBVersion: p.RBVersion,
- Name: p.Name,
+ RBName: p.RBName,
+ RBVersion: p.RBVersion,
+ ProfileName: p.ProfileName,
}
err = db.DBconn.Create(v.storeName, key, v.tagMeta, p)
@@ -126,9 +126,9 @@ func (v *ProfileClient) Create(p Profile) (Profile, error) {
// Get returns the Resource Bundle Profile for corresponding ID
func (v *ProfileClient) Get(rbName, rbVersion, prName string) (Profile, error) {
key := ProfileKey{
- RBName: rbName,
- RBVersion: rbVersion,
- Name: prName,
+ RBName: rbName,
+ RBVersion: rbVersion,
+ ProfileName: prName,
}
value, err := db.DBconn.Read(v.storeName, key, v.tagMeta)
if err != nil {
@@ -151,9 +151,9 @@ func (v *ProfileClient) Get(rbName, rbVersion, prName string) (Profile, error) {
// Delete the Resource Bundle Profile from database
func (v *ProfileClient) Delete(rbName, rbVersion, prName string) error {
key := ProfileKey{
- RBName: rbName,
- RBVersion: rbVersion,
- Name: prName,
+ RBName: rbName,
+ RBVersion: rbVersion,
+ ProfileName: prName,
}
err := db.DBconn.Delete(v.storeName, key, v.tagMeta)
if err != nil {
@@ -183,9 +183,9 @@ func (v *ProfileClient) Upload(rbName, rbVersion, prName string, inp []byte) err
}
key := ProfileKey{
- RBName: rbName,
- RBVersion: rbVersion,
- Name: prName,
+ RBName: rbName,
+ RBVersion: rbVersion,
+ ProfileName: prName,
}
//Encode given byte stream to text for storage
encodedStr := base64.StdEncoding.EncodeToString(inp)
@@ -210,9 +210,9 @@ func (v *ProfileClient) Download(rbName, rbVersion, prName string) ([]byte, erro
}
key := ProfileKey{
- RBName: rbName,
- RBVersion: rbVersion,
- Name: prName,
+ RBName: rbName,
+ RBVersion: rbVersion,
+ ProfileName: prName,
}
value, err := db.DBconn.Read(v.storeName, key, v.tagContent)
if err != nil {
diff --git a/src/k8splugin/internal/rb/profile_test.go b/src/k8splugin/internal/rb/profile_test.go
index e0f43824..14d37d17 100644
--- a/src/k8splugin/internal/rb/profile_test.go
+++ b/src/k8splugin/internal/rb/profile_test.go
@@ -37,7 +37,7 @@ func TestCreateProfile(t *testing.T) {
{
label: "Create Resource Bundle Profile",
inp: Profile{
- Name: "testprofile1",
+ ProfileName: "testprofile1",
ReleaseName: "testprofilereleasename",
Namespace: "testnamespace",
KubernetesVersion: "1.12.3",
@@ -45,7 +45,7 @@ func TestCreateProfile(t *testing.T) {
RBVersion: "v1",
},
expected: Profile{
- Name: "testprofile1",
+ ProfileName: "testprofile1",
ReleaseName: "testprofilereleasename",
Namespace: "testnamespace",
KubernetesVersion: "1.12.3",
@@ -68,7 +68,7 @@ func TestCreateProfile(t *testing.T) {
{
label: "Create Resource Bundle Profile With Non-Existing Definition",
inp: Profile{
- Name: "testprofile1",
+ ProfileName: "testprofile1",
ReleaseName: "testprofilereleasename",
Namespace: "testnamespace",
KubernetesVersion: "1.12.3",
@@ -134,7 +134,7 @@ func TestGetProfile(t *testing.T) {
rbversion: "v1",
prname: "testprofile1",
expected: Profile{
- Name: "testprofile1",
+ ProfileName: "testprofile1",
ReleaseName: "testprofilereleasename",
Namespace: "testnamespace",
KubernetesVersion: "1.12.3",
@@ -144,7 +144,7 @@ func TestGetProfile(t *testing.T) {
expectedError: "",
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -264,7 +264,7 @@ func TestUploadProfile(t *testing.T) {
},
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -305,7 +305,7 @@ func TestUploadProfile(t *testing.T) {
},
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile2"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile2"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -329,7 +329,7 @@ func TestUploadProfile(t *testing.T) {
},
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -424,7 +424,7 @@ func TestDownloadProfile(t *testing.T) {
},
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile1"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -448,7 +448,7 @@ func TestDownloadProfile(t *testing.T) {
expectedError: "Invalid Profile Name provided",
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
- ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", Name: "testprofile2"}.String(): {
+ ProfileKey{RBName: "testresourcebundle", RBVersion: "v1", ProfileName: "testprofile2"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"testprofile1\"," +
"\"release-name\":\"testprofilereleasename\"," +
@@ -511,7 +511,7 @@ func TestResolveProfile(t *testing.T) {
mockdb: &db.MockDB{
Items: map[string]map[string][]byte{
ProfileKey{RBName: "testresourcebundle", RBVersion: "v1",
- Name: "profile1"}.String(): {
+ ProfileName: "profile1"}.String(): {
"metadata": []byte(
"{\"profile-name\":\"profile1\"," +
"\"release-name\":\"testprofilereleasename\"," +