1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-08 14:10:05 +00:00

Add fix for config parsing into code

This implements a comment from Luzifer/cloudkeys-go#17 in order not to
have to change the `config.go` when deploying

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2017-12-29 21:49:50 +01:00
parent b2c7ec5e07
commit cba35eff93
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 33 additions and 11 deletions

View file

@ -1,10 +1,6 @@
package main
import (
"net/url"
"github.com/Luzifer/rconfig"
)
import "net/url"
type config struct {
// General Config
@ -22,9 +18,3 @@ type config struct {
func (c config) ParsedStorage() (*url.URL, error) {
return url.Parse(c.Storage)
}
func loadConfig() *config {
cfg := &config{}
rconfig.Parse(cfg)
return cfg
}

11
config_default.go Normal file
View file

@ -0,0 +1,11 @@
// +build !appengine
package main
import "github.com/Luzifer/rconfig"
func loadConfig() *config {
cfg := &config{}
rconfig.Parse(cfg)
return cfg
}

21
config_gae.go Normal file
View file

@ -0,0 +1,21 @@
// +build appengine
package main
import (
"os"
"github.com/Luzifer/rconfig"
)
func loadConfig() *config {
cfg := &config{}
// Workaround as GAE supplies more parameters than expected.
// This removes all CLI flags for parsing and relies only on parsing
// environment variables.
os.Args = []string{os.Args[0]}
rconfig.Parse(cfg)
return cfg
}