mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-09-19 15:42:58 +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
12
config.go
12
config.go
@ -1,10 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import "net/url"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/Luzifer/rconfig"
|
|
||||||
)
|
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
// General Config
|
// General Config
|
||||||
@ -22,9 +18,3 @@ type config struct {
|
|||||||
func (c config) ParsedStorage() (*url.URL, error) {
|
func (c config) ParsedStorage() (*url.URL, error) {
|
||||||
return url.Parse(c.Storage)
|
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 New Issue
Block a user