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:
parent
b2c7ec5e07
commit
cba35eff93
3 changed files with 33 additions and 11 deletions
12
config.go
12
config.go
|
@ -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
11
config_default.go
Normal 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
21
config_gae.go
Normal 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
|
||||
}
|
Loading…
Reference in a new issue