Finish removal of pkg/settings

This commit is contained in:
Ben Schumacher 2015-05-29 23:04:41 -06:00
parent 8062df6766
commit 33666d71a0
3 changed files with 16 additions and 6 deletions

View file

@ -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_CLIENT="0123456789abcdef0123AA" # for [auth] section, 'client' setting
DRONE_AUTH_SECRET="<sha-1 hash secret>" # for [auth] section, 'secret' setting DRONE_AUTH_SECRET="<sha-1 hash 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._ _NOTE: Configuration settings from environment variables override values set in the TOML file._

View file

@ -66,7 +66,7 @@ type Config struct {
// Load loads the configuration file and reads // Load loads the configuration file and reads
// parameters from environment variables. // parameters from environment variables.
func Load(path string) (*Config, error) { func Load(path string) (*Config, error) {
data, err := ioutil.ReadFile("drone.toml") data, err := ioutil.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -85,5 +85,15 @@ func LoadBytes(data []byte) (*Config, error) {
if err != nil { if err != nil {
return nil, err 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
} }

View file

@ -5,7 +5,7 @@ import (
"net/http" "net/http"
"net/rpc" "net/rpc"
"github.com/drone/drone/pkg/settings" "github.com/drone/drone/pkg/config"
common "github.com/drone/drone/pkg/types" common "github.com/drone/drone/pkg/types"
) )
@ -17,8 +17,8 @@ type Client struct {
// New returns a new, remote datastore backend that connects // New returns a new, remote datastore backend that connects
// via tcp and exchanges data using Go's RPC mechanism. // via tcp and exchanges data using Go's RPC mechanism.
func New(service *settings.Service) (*Client, error) { func New(conf *config.Config) (*Client, error) {
conn, err := net.Dial("tcp", service.Address) conn, err := net.Dial("tcp", conf.Server.Addr)
if err != nil { if err != nil {
return nil, err return nil, err
} }