Update dependencies to latest 39/32639/2
authorShashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Thu, 22 Feb 2018 23:14:56 +0000 (15:14 -0800)
committerShashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Fri, 23 Feb 2018 23:26:49 +0000 (15:26 -0800)
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>
.gitignore
src/dkv/Gopkg.lock
src/dkv/Gopkg.toml
src/dkv/api/endpointViews.go
src/dkv/api/endpointViews_fake.go
src/dkv/api/endpointViews_test.go
src/dkv/api/initialise.go
src/dkv/api/propertiesReader.go
swagger.json

index b23f09c..155fd31 100644 (file)
@@ -7,3 +7,5 @@ bin/
 pkg/
 target/
 src/github.com/
+.vscode
+src/golang.org/
\ No newline at end of file
index 97abfee..535922e 100644 (file)
@@ -28,8 +28,8 @@
 [[projects]]
   name = "github.com/hashicorp/consul"
   packages = ["api"]
-  revision = "48f3dd5642374d079f5a64359023fb8318eb81cc"
-  version = "v1.0.3"
+  revision = "9a494b5fb9c86180a5702e29c485df1507a47198"
+  version = "v1.0.6"
 
 [[projects]]
   branch = "master"
@@ -52,8 +52,8 @@
 [[projects]]
   name = "github.com/magiconair/properties"
   packages = ["."]
-  revision = "d419a98cdbed11a922bf76f257b7c4be79b50e73"
-  version = "v1.7.4"
+  revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6"
+  version = "v1.7.6"
 
 [[projects]]
   branch = "master"
@@ -76,6 +76,6 @@
 [solve-meta]
   analyzer-name = "dep"
   analyzer-version = 1
-  inputs-digest = "da4b4bdf45858b18ffddcdd32894f4af272104c2501a5334bf1d01abfa6d9a23"
+  inputs-digest = "000a855a3e5fca6c1f7b134951013777f7decbbde7be20af1e262da6005e874a"
   solver-name = "gps-cdcl"
   solver-version = 1
index 3f608e7..064b88e 100644 (file)
 #   unused-packages = true
 
 
+[[constraint]]
+  name = "github.com/gorilla/handlers"
+  version = "1.3.0"
+
 [[constraint]]
   name = "github.com/gorilla/mux"
   version = "1.6.1"
 
 [[constraint]]
   name = "github.com/hashicorp/consul"
-  version = "1.0.3"
+  version = "1.0.6"
 
 [[constraint]]
   name = "github.com/magiconair/properties"
-  version = "1.7.4"
+  version = "1.7.6"
+
+[[constraint]]
+  name = "github.com/stretchr/testify"
+  version = "1.2.1"
 
 [prune]
   go-tests = true
index 7d19a6a..8f77061 100644 (file)
@@ -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())}
index c147673..ecc6466 100644 (file)
@@ -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")
 }
index 1f7abf3..8e2799e 100644 (file)
@@ -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",
                },
index f85c146..331c981 100644 (file)
@@ -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 (
index a1c94bb..559c0fc 100644 (file)
@@ -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
index bb76c41..4430574 100644 (file)
@@ -90,6 +90,8 @@ definitions:
   LoadRequest:
     type: "object"
     properties:
+      domain:
+        type: "string"
       type:
         $ref: "#/definitions/Type"
   Type: