Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
key-storage-agent
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
key-storage-agent
Merge requests
!43
130-implement-etcd-configuration-use
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
130-implement-etcd-configuration-use
130-implement-etcd-configuration-use
into
master
Overview
2
Commits
1
Pipelines
0
Changes
4
Merged
Viktor Popov
requested to merge
130-implement-etcd-configuration-use
into
master
5 years ago
Overview
2
Commits
1
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
0a032811
1 commit,
5 years ago
4 files
+
38
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
config/configs.go
+
22
−
5
Options
@@ -2,11 +2,16 @@ package config
import
(
"log"
"os"
"path/filepath"
"strings"
"code.vereign.com/code/viam-apis/authentication"
"github.com/spf13/viper"
)
import
_
"github.com/spf13/viper/remote"
var
SystemAuth
=
&
authentication
.
Authentication
{
Uuid
:
"undefined"
,
Session
:
"undefined"
,
@@ -27,7 +32,7 @@ var RestListenAddress string
var
DataStorageUrl
string
var
CertDir
string
func
SetConfigValues
()
{
func
SetConfigValues
(
configFile
,
etcdURL
string
)
{
// Set Default Values For Config Variables
// Vereign API Related
@@ -66,10 +71,22 @@ func SetConfigValues() {
*/
// Read Config File
viper
.
SetConfigName
(
"config"
)
viper
.
AddConfigPath
(
"."
)
if
err
:=
viper
.
ReadInConfig
();
err
!=
nil
{
log
.
Printf
(
"can't read config: %s, will use default values"
,
err
)
if
configFile
!=
""
{
configName
:=
strings
.
Split
(
filepath
.
Base
(
configFile
),
"."
)[
0
]
configDir
:=
filepath
.
Dir
(
configFile
)
viper
.
SetConfigName
(
configName
)
viper
.
AddConfigPath
(
configDir
)
if
err
:=
viper
.
ReadInConfig
();
err
!=
nil
{
log
.
Printf
(
"can't read config: %v, will use default values"
,
err
)
}
}
else
{
log
.
Printf
(
"requesting config at "
+
etcdURL
,
"/"
+
os
.
Getenv
(
"ENV_NAME"
)
+
"/"
+
os
.
Getenv
(
"CI_PROJECT_NAME"
)
+
".json"
)
viper
.
AddRemoteProvider
(
"etcd"
,
etcdURL
,
"/"
+
os
.
Getenv
(
"ENV_NAME"
)
+
"/"
+
os
.
Getenv
(
"CI_PROJECT_NAME"
)
+
".json"
)
viper
.
SetConfigType
(
"json"
)
if
err
:=
viper
.
ReadRemoteConfig
();
err
!=
nil
{
log
.
Printf
(
"can't read config: %v, will use default values"
,
err
)
}
}
CertificationMethod
=
viper
.
GetString
(
"certificationMethod"
)
Loading