diff options
author | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-01-24 18:24:14 -0800 |
---|---|---|
committer | Kiran Kamineni <kiran.k.kamineni@intel.com> | 2019-01-25 11:12:28 -0800 |
commit | 5a509f45600d443c1ca087706d4609607cebe537 (patch) | |
tree | 6461382d8e9e3bb3c40dd4211be16a0ac7751160 /src/k8splugin/api | |
parent | 704d7c52983cd935b48d4eb38108c758c7b6c67d (diff) |
Add another parameter to the definition
Add a ChartName parameter to definition
This is need to explicitly specify the chart name
to be used within the tar file.
Issue-ID: MULTICLOUD-291
Change-Id: I3d6e20607b74e54801622a6c27d5674777548ee1
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/api')
-rw-r--r-- | src/k8splugin/api/defhandler.go | 6 | ||||
-rw-r--r-- | src/k8splugin/api/defhandler_test.go | 25 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/k8splugin/api/defhandler.go b/src/k8splugin/api/defhandler.go index 31b0f38f..f53acdd2 100644 --- a/src/k8splugin/api/defhandler.go +++ b/src/k8splugin/api/defhandler.go @@ -54,6 +54,12 @@ func (h rbDefinitionHandler) createHandler(w http.ResponseWriter, r *http.Reques return } + // Chart Name is required + if v.ChartName == "" { + http.Error(w, "Missing chart name in POST request", http.StatusBadRequest) + return + } + ret, err := h.client.Create(v) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/src/k8splugin/api/defhandler_test.go b/src/k8splugin/api/defhandler_test.go index fd17f50e..e638ca05 100644 --- a/src/k8splugin/api/defhandler_test.go +++ b/src/k8splugin/api/defhandler_test.go @@ -90,13 +90,15 @@ func TestRBDefCreateHandler(t *testing.T) { label: "Create without UUID", expectedCode: http.StatusCreated, reader: bytes.NewBuffer([]byte(`{ - "name":"testdomain", + "name":"testresourcebundle", + "chart-name":"testchart", "description":"test description", "service-type":"firewall" }`)), expected: rb.Definition{ UUID: "123e4567-e89b-12d3-a456-426655440000", Name: "testresourcebundle", + ChartName: "testchart", Description: "test description", ServiceType: "firewall", }, @@ -106,12 +108,33 @@ func TestRBDefCreateHandler(t *testing.T) { { UUID: "123e4567-e89b-12d3-a456-426655440000", Name: "testresourcebundle", + ChartName: "testchart", Description: "test description", ServiceType: "firewall", }, }, }, }, + { + label: "Missing Name in Request Body", + reader: bytes.NewBuffer([]byte(`{ + "chart-name":"testchart", + "description":"test description", + "service-type":"firewall" + }`)), + expectedCode: http.StatusBadRequest, + rbDefClient: &mockRBDefinition{}, + }, + { + label: "Missing Chart Name in Request Body", + reader: bytes.NewBuffer([]byte(`{ + "name":"testresourcebundle", + "description":"test description", + "service-type":"firewall" + }`)), + expectedCode: http.StatusBadRequest, + rbDefClient: &mockRBDefinition{}, + }, } for _, testCase := range testCases { |