Example #1
0
func (s *S) TestStrictFieldMap(c *C) {
	fields := schema.Fields{
		"a": schema.Const("A"),
		"b": schema.Const("B"),
		"c": schema.Const("C"),
	}
	defaults := schema.Defaults{
		"b": schema.Omit,
		"c": "C",
	}
	sch := schema.StrictFieldMap(fields, defaults)
	assertFieldMap(c, sch)

	out, err := sch.Coerce(map[string]interface{}{"a": "A", "b": "B", "d": "D"}, aPath)
	c.Assert(out, IsNil)
	c.Assert(err, ErrorMatches, `<path>.d: expected nothing, got "D"`)
}
Example #2
0
	"launchpad.net/juju-core/schema"
	"net/url"
)

var configChecker = schema.StrictFieldMap(
	schema.Fields{
		"username":          schema.String(),
		"password":          schema.String(),
		"tenant-name":       schema.String(),
		"auth-url":          schema.String(),
		"auth-method":       schema.String(),
		"region":            schema.String(),
		"control-bucket":    schema.String(),
		"public-bucket":     schema.String(),
		"public-bucket-url": schema.String(),
	},
	schema.Defaults{
		"username":          "",
		"password":          "",
		"tenant-name":       "",
		"auth-url":          "",
		"auth-method":       string(AuthUserPass),
		"region":            "",
		"control-bucket":    "",
		"public-bucket":     "juju-dist",
		"public-bucket-url": "",
	},
)

type environConfig struct {
	*config.Config
	attrs map[string]interface{}
Example #3
0
	p := &providerInstance
	p.mu.Lock()
	defer p.mu.Unlock()
	for _, st := range p.state {
		st.mu.Lock()
		st.storageDelay = d
		st.mu.Unlock()
	}
}

var checker = schema.StrictFieldMap(
	schema.Fields{
		"state-server": schema.Bool(),
		"broken":       schema.String(),
		"secret":       schema.String(),
	},
	schema.Defaults{
		"broken": "",
		"secret": "pork",
	},
)

type environConfig struct {
	*config.Config
	attrs map[string]interface{}
}

func (c *environConfig) stateServer() bool {
	return c.attrs["state-server"].(bool)
}
Example #4
0
import (
	"fmt"
	"launchpad.net/goamz/aws"
	"launchpad.net/juju-core/environs/config"
	"launchpad.net/juju-core/schema"
)

var configChecker = schema.StrictFieldMap(
	schema.Fields{
		"access-key":           schema.String(),
		"secret-key":           schema.String(),
		"region":               schema.String(),
		"control-bucket":       schema.String(),
		"public-bucket":        schema.String(),
		"public-bucket-region": schema.String(),
	},
	schema.Defaults{
		"access-key":           "",
		"secret-key":           "",
		"region":               "us-east-1",
		"public-bucket":        "juju-dist",
		"public-bucket-region": "us-east-1",
	},
)

type environConfig struct {
	*config.Config
	attrs map[string]interface{}
}

func (c *environConfig) region() string {