feat: Tested (with curl) server implementation of the secrets store.
This commit is contained in:
1 parent
9bdbc79458
commit
7b715da87f
4 files changed
+195
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
addr string
|
||||
storePath string
|
||||
ca string
|
||||
crt string
|
||||
crtKey string
|
||||
}
|
||||
|
||||
// TODO: Maybe use viper?
|
||||
func loadConfigFromEnv() *config {
|
||||
res := config{}
|
||||
if addr, ok := os.LookupEnv("SECRETS_SERVER_ADDR"); !ok || addr == "" {
|
||||
log.Fatal("SECRETS_SERVER_ADDR is required")
|
||||
} else {
|
||||
res.addr = addr
|
||||
}
|
||||
if storePath, ok := os.LookupEnv("SECRETS_SERVER_STORE_PATH"); !ok || storePath == "" {
|
||||
log.Fatal("SECRETS_SERVER_STORE_PATH is required")
|
||||
} else {
|
||||
res.storePath = storePath
|
||||
}
|
||||
if ca, ok := os.LookupEnv("SECRETS_SERVER_CA"); !ok || ca == "" {
|
||||
log.Fatal("SECRETS_SERVER_CA is required")
|
||||
} else {
|
||||
res.ca = ca
|
||||
}
|
||||
if crt, ok := os.LookupEnv("SECRETS_SERVER_CRT"); !ok || crt == "" {
|
||||
log.Fatal("SECRETS_SERVER_CRT is required")
|
||||
} else {
|
||||
res.crt = crt
|
||||
}
|
||||
if crtKey, ok := os.LookupEnv("SECRETS_SERVER_CRT_KEY"); !ok || crtKey == "" {
|
||||
log.Fatal("SECRETS_SERVER_CRT_KEY is required")
|
||||
} else {
|
||||
res.crtKey = crtKey
|
||||
}
|
||||
return &res
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.handmadecities.com/HMC/shhh/pkg/secretsserver"
|
||||
"git.handmadecities.com/HMC/shhh/pkg/secretsstore"
|
||||
)
|
||||
|
||||
func main() {
|
||||
cfg := loadConfigFromEnv()
|
||||
|
||||
store, err := secretsstore.New(cfg.storePath)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
server := secretsserver.New(store)
|
||||
log.Fatal(server.ListenAndServeTLS(cfg.addr, cfg.ca, cfg.crt, cfg.crtKey))
|
||||
}
|
||||
Reference in new issue
Block a user