Exemplo n.º 1
0
func (s *S) TestUUID(c *gc.C) {
	s.sch = schema.UUID()

	out, err := s.sch.Coerce("6216dfc3-6e82-408f-9f74-8565e63e6158", aPath)
	c.Assert(err, gc.IsNil)
	c.Assert(out, gc.Equals, "6216dfc3-6e82-408f-9f74-8565e63e6158")

	out, err = s.sch.Coerce("uuid", aPath)
	c.Assert(out, gc.IsNil)
	c.Assert(err, gc.ErrorMatches, `<path>: expected uuid, got string\(\"uuid\"\)`)

	out, err = s.sch.Coerce(nil, aPath)
	c.Assert(out, gc.IsNil)
	c.Assert(err, gc.ErrorMatches, "<path>: expected uuid, got nothing")
}
Exemplo n.º 2
0
	return New(NoDefaults, defined)
}

// Apply returns a new configuration that has the attributes of c plus attrs.
func (c *Config) Apply(attrs map[string]interface{}) (*Config, error) {
	defined := c.AllAttrs()
	for k, v := range attrs {
		defined[k] = v
	}
	return New(NoDefaults, defined)
}

var fields = schema.Fields{
	"type":                       schema.String(),
	"name":                       schema.String(),
	"uuid":                       schema.UUID(),
	"default-series":             schema.String(),
	"tools-metadata-url":         schema.String(),
	"image-metadata-url":         schema.String(),
	"image-stream":               schema.String(),
	"authorized-keys":            schema.String(),
	"authorized-keys-path":       schema.String(),
	"firewall-mode":              schema.String(),
	"agent-version":              schema.String(),
	"development":                schema.Bool(),
	"admin-secret":               schema.String(),
	"ca-cert":                    schema.String(),
	"ca-cert-path":               schema.String(),
	"ca-private-key":             schema.String(),
	"ca-private-key-path":        schema.String(),
	"ssl-hostname-verification":  schema.Bool(),