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
Commits
0a032811
Commit
0a032811
authored
6 years ago
by
Viktor Popov
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parent
8dc41770
Branches
130-implement-etcd-configuration-use
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
130-implement-etcd-configuration-use
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Dockerfile
+4
-0
4 additions, 0 deletions
Dockerfile
Makefile
+1
-0
1 addition, 0 deletions
Makefile
config/configs.go
+22
-5
22 additions, 5 deletions
config/configs.go
main.go
+11
-1
11 additions, 1 deletion
main.go
with
38 additions
and
6 deletions
Dockerfile
+
4
−
0
View file @
0a032811
...
@@ -8,6 +8,8 @@ ENV GOPATH /srv/
...
@@ -8,6 +8,8 @@ ENV GOPATH /srv/
ENV
SERVER_OUT "bin/server"
ENV
SERVER_OUT "bin/server"
ENV
SERVER_PKG_BUILD ${PKG}
ENV
SERVER_PKG_BUILD ${PKG}
ENV
PATH "$PATH:/srv/bin/"
ARG
CI_JOB_TOKEN
ARG
CI_JOB_TOKEN
ARG
CI_PROJECT_NAME
ARG
CI_PROJECT_NAME
ARG
CI_COMMIT_REF_NAME
ARG
CI_COMMIT_REF_NAME
...
@@ -24,6 +26,8 @@ RUN cd /srv/src/code.vereign.com/code/$CI_PROJECT_NAME && \
...
@@ -24,6 +26,8 @@ RUN cd /srv/src/code.vereign.com/code/$CI_PROJECT_NAME && \
git config
--global
credential.helper
"store --file /tmp/store"
&&
\
git config
--global
credential.helper
"store --file /tmp/store"
&&
\
echo
https://gitlab-ci-token:
$CI_JOB_TOKEN
@code.vereign.com
>
/tmp/store
&&
cat
/tmp/store
&&
\
echo
https://gitlab-ci-token:
$CI_JOB_TOKEN
@code.vereign.com
>
/tmp/store
&&
cat
/tmp/store
&&
\
export
PKG
=
code.vereign.com/code/
$CI_PROJECT_NAME
&&
\
export
PKG
=
code.vereign.com/code/
$CI_PROJECT_NAME
&&
\
go get
-u
github.com/ugorji/go/codec/codecgen
&&
\
echo
PATH
$PATH
&&
\
make
&&
rm
/tmp/store
make
&&
rm
/tmp/store
#FROM debian:stretch
#FROM debian:stretch
...
...
This diff is collapsed.
Click to expand it.
Makefile
+
1
−
0
View file @
0a032811
...
@@ -11,6 +11,7 @@ all: server
...
@@ -11,6 +11,7 @@ all: server
dep
:
##
Get the dependencies
dep
:
##
Get the dependencies
dep ensure
dep ensure
server
:
dep
##
Build the binary file for server
server
:
dep
##
Build the binary file for server
go generate vendor/github.com/coreos/etcd/client/keys.go
@
go build
-ldflags
=
"-X code.vereign.com/code/key-storage-agent/handler.version=
$(
VER
)
"
-i
-v
-o
$(
SERVER_OUT
)
$(
SERVER_PKG_BUILD
)
@
go build
-ldflags
=
"-X code.vereign.com/code/key-storage-agent/handler.version=
$(
VER
)
"
-i
-v
-o
$(
SERVER_OUT
)
$(
SERVER_PKG_BUILD
)
clean
:
##
Remove previous builds
clean
:
##
Remove previous builds
...
...
This diff is collapsed.
Click to expand it.
config/configs.go
+
22
−
5
View file @
0a032811
...
@@ -2,11 +2,16 @@ package config
...
@@ -2,11 +2,16 @@ package config
import
(
import
(
"log"
"log"
"os"
"path/filepath"
"strings"
"code.vereign.com/code/viam-apis/authentication"
"code.vereign.com/code/viam-apis/authentication"
"github.com/spf13/viper"
"github.com/spf13/viper"
)
)
import
_
"github.com/spf13/viper/remote"
var
SystemAuth
=
&
authentication
.
Authentication
{
var
SystemAuth
=
&
authentication
.
Authentication
{
Uuid
:
"undefined"
,
Uuid
:
"undefined"
,
Session
:
"undefined"
,
Session
:
"undefined"
,
...
@@ -27,7 +32,7 @@ var RestListenAddress string
...
@@ -27,7 +32,7 @@ var RestListenAddress string
var
DataStorageUrl
string
var
DataStorageUrl
string
var
CertDir
string
var
CertDir
string
func
SetConfigValues
()
{
func
SetConfigValues
(
configFile
,
etcdURL
string
)
{
// Set Default Values For Config Variables
// Set Default Values For Config Variables
// Vereign API Related
// Vereign API Related
...
@@ -66,10 +71,22 @@ func SetConfigValues() {
...
@@ -66,10 +71,22 @@ func SetConfigValues() {
*/
*/
// Read Config File
// Read Config File
viper
.
SetConfigName
(
"config"
)
if
configFile
!=
""
{
viper
.
AddConfigPath
(
"."
)
configName
:=
strings
.
Split
(
filepath
.
Base
(
configFile
),
"."
)[
0
]
if
err
:=
viper
.
ReadInConfig
();
err
!=
nil
{
configDir
:=
filepath
.
Dir
(
configFile
)
log
.
Printf
(
"can't read config: %s, will use default values"
,
err
)
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"
)
CertificationMethod
=
viper
.
GetString
(
"certificationMethod"
)
...
...
This diff is collapsed.
Click to expand it.
main.go
+
11
−
1
View file @
0a032811
...
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
...
@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package
main
package
main
import
(
import
(
"flag"
"log"
"log"
"code.vereign.com/code/key-storage-agent/config"
"code.vereign.com/code/key-storage-agent/config"
...
@@ -26,7 +27,16 @@ import (
...
@@ -26,7 +27,16 @@ import (
// main start a gRPC server and waits for connection
// main start a gRPC server and waits for connection
func
main
()
{
func
main
()
{
config
.
SetConfigValues
()
configFile
:=
flag
.
String
(
"config-file"
,
""
,
"path to configuration file"
)
etcdURL
:=
flag
.
String
(
"etcd-url"
,
""
,
"etcd URL"
)
flag
.
Parse
()
if
*
configFile
==
""
&&
*
etcdURL
==
""
{
log
.
Fatalln
(
"Config file path or etcd URL not specified"
)
return
}
config
.
SetConfigValues
(
*
configFile
,
*
etcdURL
)
grpcAddress
:=
config
.
GrpcListenAddress
grpcAddress
:=
config
.
GrpcListenAddress
restAddress
:=
config
.
RestListenAddress
restAddress
:=
config
.
RestListenAddress
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment