diff options
author | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-05-23 16:01:03 -0700 |
---|---|---|
committer | Shashank Kumar Shankar <shashank.kumar.shankar@intel.com> | 2018-05-23 16:03:24 -0700 |
commit | 18d9d994e85ef897d570081bc3a7e1da42b49c1e (patch) | |
tree | c1e05000de167c04f14fd81cc25fb8583078463d /src/dkv/api/initialise.go | |
parent | 5e6124aa915bd66734214ded0a25740b544bfa52 (diff) |
Create Token Service JSON dynamically2.0.0-ONAPbeijing2.0.0-ONAP
This patch makes sure the Token Service JSON is dynically created so that
this fits better when deployed on Kubernetes.
Change-Id: I4426f68af2a6de4d2ffe4f488d5660c47f13ccaf
Issue-ID: MUSIC-55
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Diffstat (limited to 'src/dkv/api/initialise.go')
-rw-r--r-- | src/dkv/api/initialise.go | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/dkv/api/initialise.go b/src/dkv/api/initialise.go index ac8825e..228a46f 100644 --- a/src/dkv/api/initialise.go +++ b/src/dkv/api/initialise.go @@ -18,6 +18,7 @@ package api import ( "errors" + "log" "os" ) @@ -31,6 +32,7 @@ func Initialise() error { if os.Getenv("DATASTORE") == "" { return errors.New("DATASTORE environment variable not set.") } + if os.Getenv("DATASTORE") == "consul" { Datastore = &ConsulStruct{} } else if os.Getenv("DATASTORE") == "cassandra" { @@ -38,10 +40,20 @@ func Initialise() error { } else { return errors.New("Unrecognised Datastore. Supports only consul or cassandra") } + + jsonExists, err := JsonChecker(JSONPATH) + if jsonExists == false { + log.Println("[INFO] token_service_map.json not found. Creating.") + err = JsonCreate(JSONPATH) + if err != nil { + return err + } + } + KeyValues = &KeyValuesStruct{} Directory = &DirectoryStruct{directory: ""} - err := Datastore.InitializeDatastoreClient() + err = Datastore.InitializeDatastoreClient() if err != nil { return err } |