From 1394648220cf3c92e498833f97046072379bddce Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Fri, 9 Oct 2015 16:10:16 +0200 Subject: Add CUSTODIA_REMOTE_USER and CUSTODIA_DEBUG env vars --- README | 2 +- gustodia.go | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README b/README index 336165b..282e916 100644 --- a/README +++ b/README @@ -3,7 +3,7 @@ Custodia Docker entrypoint Firt shell ---------- -$ sudo dnf install golang make python-virtualenv openssl-devel python-devel +$ sudo dnf install golang make python-virtualenv openssl-devel python-devel git libffi-devel $ make run_server Second shell diff --git a/gustodia.go b/gustodia.go index c2316c4..8a5b0de 100644 --- a/gustodia.go +++ b/gustodia.go @@ -108,15 +108,17 @@ type CustodiaClient struct { BasePath string Prefix string SecretPrefix string + RemoteUser string Secrets []*CustodiaSecret } -func NewCustodiaClient(socketpath string) *CustodiaClient { +func NewCustodiaClient(socketpath, remoteuser string) *CustodiaClient { return &CustodiaClient{ SocketPath: socketpath, BasePath: BASE_PATH, Prefix: PREFIX, SecretPrefix: SECRET_PREFIX, + RemoteUser: remoteuser, Secrets: []*CustodiaSecret{}, } } @@ -149,7 +151,9 @@ func (cc *CustodiaClient) QueryCustodia() { if err != nil { panic(err) } - req.Header.Add("REMOTE_USER", "gustodia") + if cc.RemoteUser != "" { + req.Header.Add("REMOTE_USER", cc.RemoteUser) + } resp, err := client.Do(req) if err != nil { log.Fatal(err) @@ -204,6 +208,8 @@ func (cc CustodiaClient) Debug() { } func main() { + debug := os.Getenv("CUSTODIA_DEBUG") != "" + if len(os.Args) < 2 { log.Fatalf("%s entrypoint [args]", os.Args[0]) } @@ -213,13 +219,18 @@ func main() { // default socket is in the same directory as program socketpath = path.Join(path.Dir(os.Args[0]), "server_socket") } + remoteuser := os.Getenv("CUSTODIA_REMOTE_USER") - client := NewCustodiaClient(socketpath) + client := NewCustodiaClient(socketpath, remoteuser) + if debug { + fmt.Printf("%+v\n", client) + } client.FindEnvs() client.QueryCustodia() - //client.Debug() environ := client.MakeEnv() - + if debug { + client.Debug() + } args := os.Args[1:] syscall.Exec(args[0], args, environ) -- cgit