diff options
author | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-02-22 15:14:56 -0800 |
---|---|---|
committer | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-02-23 15:26:49 -0800 |
commit | ff8cba5a49e85fbb1d2e14f0fa0bcb5bf92caf34 (patch) | |
tree | d0eacb13eb64f3819f76e3fac13084fcf9f811dc /src/dkv/api | |
parent | 3e92cb38f9be554afccf7ac409dfbedbeec769a2 (diff) |
Update dependencies to latest
This patch updates dependency versions to latest so that
they are compatible with Go version 10 which is being
in the process of being run at the Jenkins Jobs [1].
[1] - https://gerrit.onap.org/r/#/c/32291/
It also makes a minor update to the API.
Change-Id: Ibd14652686a57c170a2fe60cf4e68b63dcac6119
Issue-ID: MUSIC-23
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Diffstat (limited to 'src/dkv/api')
-rw-r--r-- | src/dkv/api/endpointViews.go | 8 | ||||
-rw-r--r-- | src/dkv/api/endpointViews_fake.go | 4 | ||||
-rw-r--r-- | src/dkv/api/endpointViews_test.go | 2 | ||||
-rw-r--r-- | src/dkv/api/initialise.go | 16 | ||||
-rw-r--r-- | src/dkv/api/propertiesReader.go | 5 |
5 files changed, 29 insertions, 6 deletions
diff --git a/src/dkv/api/endpointViews.go b/src/dkv/api/endpointViews.go index 7d19a6a..8f77061 100644 --- a/src/dkv/api/endpointViews.go +++ b/src/dkv/api/endpointViews.go @@ -36,7 +36,8 @@ type ResponseGETSStruct struct { } type POSTBodyStruct struct { - Type *TypeStruct `json:"type"` + Domain string `json:"domain"` + Type *TypeStruct `json:"type"` } type TypeStruct struct { @@ -44,6 +45,9 @@ type TypeStruct struct { } func ValidateBody(body POSTBodyStruct) error { + if body.Domain == "" { + return errors.New("Domain not set. Please set domain in POST.") + } if body.Type == nil { return errors.New("Type not set. Recheck POST data.") } else if body.Type.FilePath == "" { @@ -88,7 +92,7 @@ func HandlePOST(w http.ResponseWriter, r *http.Request) { return } - err = KeyValues.WriteKVsToConsul() + err = KeyValues.WriteKVsToConsul(body.Domain) if err != nil { req := ResponseStringStruct{Response: string(err.Error())} diff --git a/src/dkv/api/endpointViews_fake.go b/src/dkv/api/endpointViews_fake.go index c147673..ecc6466 100644 --- a/src/dkv/api/endpointViews_fake.go +++ b/src/dkv/api/endpointViews_fake.go @@ -78,7 +78,7 @@ func (f *FakeKeyValues) ReadConfigs(body POSTBodyStruct) error { return nil } -func (f *FakeKeyValues) WriteKVsToConsul() error { +func (f *FakeKeyValues) WriteKVsToConsul(prefix string) error { return nil } @@ -91,6 +91,6 @@ func (f *FakeKeyValuesErr) ReadConfigs(body POSTBodyStruct) error { return errors.New("Internal Server Error") } -func (f *FakeKeyValuesErr) WriteKVsToConsul() error { +func (f *FakeKeyValuesErr) WriteKVsToConsul(prefix string) error { return errors.New("Internal Server Error") } diff --git a/src/dkv/api/endpointViews_test.go b/src/dkv/api/endpointViews_test.go index 1f7abf3..8e2799e 100644 --- a/src/dkv/api/endpointViews_test.go +++ b/src/dkv/api/endpointViews_test.go @@ -96,6 +96,7 @@ func TestHandlePOST(t *testing.T) { }() body := &POSTBodyStruct{ + Domain: "test", Type: &TypeStruct{ FilePath: "default", }, @@ -173,6 +174,7 @@ func TestHandlePOST_ConsulError(t *testing.T) { }() body := &POSTBodyStruct{ + Domain: "test", Type: &TypeStruct{ FilePath: "default", }, diff --git a/src/dkv/api/initialise.go b/src/dkv/api/initialise.go index f85c146..331c981 100644 --- a/src/dkv/api/initialise.go +++ b/src/dkv/api/initialise.go @@ -1,3 +1,19 @@ +/* + * Copyright 2018 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 api import ( diff --git a/src/dkv/api/propertiesReader.go b/src/dkv/api/propertiesReader.go index a1c94bb..559c0fc 100644 --- a/src/dkv/api/propertiesReader.go +++ b/src/dkv/api/propertiesReader.go @@ -27,7 +27,7 @@ import ( ) type KeyValuesInterface interface { - WriteKVsToConsul() error + WriteKVsToConsul(string) error ReadConfigs(POSTBodyStruct) error PropertiesFilesToKV(string) error ReadMultipleProperties(string) error @@ -41,8 +41,9 @@ type KeyValuesStruct struct { var KeyValues KeyValuesInterface -func (kvStruct *KeyValuesStruct) WriteKVsToConsul() error { +func (kvStruct *KeyValuesStruct) WriteKVsToConsul(prefix string) error { for key, value := range kvStruct.kvs { + key = prefix + "." + key err := Consul.RequestPUT(key, value) if err != nil { return err |