diff --git a/README.md b/README.md index bc6812fbf..ac7e62ebe 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ DRONE_DOCKER_ADDR="tcp://10.0.0.1:2375" # for [docker] section, 'addr' setti DRONE_AUTH_CLIENT="0123456789abcdef0123AA" # for [auth] section, 'client' setting DRONE_AUTH_SECRET="" # for [auth] section, 'secret' setting -exec bin/drone -config=drone.toml +exec ./drone -config=drone.toml ``` _NOTE: Configuration settings from environment variables override values set in the TOML file._ diff --git a/pkg/config/config.go b/pkg/config/config.go index 074b9c6d0..8f7d96343 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -66,7 +66,7 @@ type Config struct { // Load loads the configuration file and reads // parameters from environment variables. func Load(path string) (*Config, error) { - data, err := ioutil.ReadFile("drone.toml") + data, err := ioutil.ReadFile(path) if err != nil { return nil, err } @@ -85,5 +85,15 @@ func LoadBytes(data []byte) (*Config, error) { if err != nil { return nil, err } - return conf, nil + return applyDefaults(conf), nil +} + +func applyDefaults(c *Config) *Config { + // if no session token is provided we can + // instead use the client secret to sign + // our sessions and tokens. + if len(c.Session.Secret) == 0 { + c.Session.Secret = c.Auth.Secret + } + return c } diff --git a/pkg/remote/client/client.go b/pkg/remote/client/client.go index 638580b99..392c97839 100644 --- a/pkg/remote/client/client.go +++ b/pkg/remote/client/client.go @@ -5,7 +5,7 @@ import ( "net/http" "net/rpc" - "github.com/drone/drone/pkg/settings" + "github.com/drone/drone/pkg/config" common "github.com/drone/drone/pkg/types" ) @@ -17,8 +17,8 @@ type Client struct { // New returns a new, remote datastore backend that connects // via tcp and exchanges data using Go's RPC mechanism. -func New(service *settings.Service) (*Client, error) { - conn, err := net.Dial("tcp", service.Address) +func New(conf *config.Config) (*Client, error) { + conn, err := net.Dial("tcp", conf.Server.Addr) if err != nil { return nil, err }