Skip to content

Commit

Permalink
secret management
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-dempers committed Sep 13, 2019
1 parent 96ff1cb commit 1dd2779
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ services:
- ./c#/src/:/work/
ports:
- 5000:5000
golang: #docker run -it -v ${PWD}:/go/src/work -v ${PWD}/golang/configs/:/configs -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
golang: #docker run -it -v ${PWD}:/go/src/work -v ${PWD}/golang/configs/:/configs -v ${PWD}/golang/secrets/:/secrets -p 5001:5000 -p 2345:2345 --security-opt "seccomp:unconfined" aimvector/golang:1.0.0
container_name: golang
image: aimvector/golang:1.0.0
build:
context: ./golang
target: prod
volumes:
- ./golang/configs:/configs/
- ./golang/secrets:/secrets/
- ./golang/src/:/go/src/work/
ports:
- 5001:5000
Expand Down
3 changes: 3 additions & 0 deletions golang/secrets/secret.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"api_key" : "somesecretgoeshere"
}
14 changes: 14 additions & 0 deletions golang/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

var configuration []byte
var secret []byte

func Response(ctx *fasthttp.RequestCtx) {
fmt.Fprintf(ctx, "Hello")
Expand All @@ -32,10 +33,23 @@ func ReadConfig(){

}

func ReadSecret(){
fmt.Println("reading secret...")
s, e := ioutil.ReadFile("/secrets/secret.json")
if e != nil {
fmt.Printf("Error reading secret file: %v\n", e)
os.Exit(1)
}
secret = s
fmt.Println("secret loaded!")

}

func main() {

fmt.Println("starting...")
ReadConfig()
ReadSecret()
router := fasthttprouter.New()
router.GET("/", Response)
router.GET("/status", Status)
Expand Down

0 comments on commit 1dd2779

Please sign in to comment.