Merge lp:~rogpeppe/juju-core/041-config-agent-version into lp:~juju/juju-core/trunk
Proposed by
Roger Peppe
Status: | Merged |
---|---|
Approved by: | Gustavo Niemeyer |
Approved revision: | 444 |
Merged at revision: | 450 |
Proposed branch: | lp:~rogpeppe/juju-core/041-config-agent-version |
Merge into: | lp:~juju/juju-core/trunk |
Diff against target: |
145 lines (+56/-5) 4 files modified
environs/config/config.go (+23/-0) environs/config/config_test.go (+27/-3) schema/schema.go (+2/-2) schema/schema_test.go (+4/-0) |
To merge this branch: | bzr merge lp:~rogpeppe/juju-core/041-config-agent-version |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
The Go Language Gophers | Pending | ||
Review via email: mp+122016@code.launchpad.net |
Description of the change
environs/config: add support for agent version.
Also adjust documentation for schema.Omit slightly
and add a test.
To post a comment you must log in.
Reviewers: mp+122016_ code.launchpad. net,
Message:
Please take a look.
Description:
environs/config: add support for agent version.
Also adjust documentation for schema.Omit slightly
and add a test.
https:/ /code.launchpad .net/~rogpeppe/ juju-core/ 041-config- agent-version/ +merge/ 122016
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6499055/
Affected files: config/ config. go config/ config_ test.go schema_ test.go
A [revision details]
M environs/
M environs/
M schema/schema.go
M schema/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>
Index: schema/schema.go interface{ }.
=== modified file 'schema/schema.go'
--- schema/schema.go 2012-07-26 18:01:24 +0000
+++ schema/schema.go 2012-08-30 09:11:09 +0000
@@ -322,8 +322,8 @@
// and returns with the underlying error.
//
// Fields in defaults will be set to the provided value if not present
-// in the coerced map. If the default value is schema.Omit, the field
-// missing field will be ommitted from the coerced map as well.
+// in the coerced map. If the default value is schema.Omit, the
+// missing field will be omitted from the coerced map.
//
// The coerced output value has type map[string]
func FieldMap(fields Fields, defaults Defaults) Checker {
Index: schema/ schema_ test.go schema_ test.go' schema_ test.go 2012-07-26 18:08:04 +0000 schema_ test.go 2012-08-30 09:11:09 +0000 map[string] interface{ }{"a": "A", "b": "B", "d": "D"}, aPath) interface{ }{"a": "A", "b": "B", "c": "C"}) map[string] interface{ }{"a": "A", "d": "D"}, aPath) interface{ }{"a": "A", "c": "C"})
=== modified file 'schema/
--- schema/
+++ schema/
@@ -285,6 +285,10 @@
out, err :=
sch.Coerce(
c.Assert(err, IsNil)
c.Assert(out, DeepEquals,
map[string]
+
+ out, err = sch.Coerce(
+ c.Assert(err, IsNil)
+ c.Assert(out, DeepEquals, map[string]
}
func (s *S) TestFieldMapDef aultInvalid( c *C) {
Index: environs/ config/ config. go config/ config. go' config/ config. go 2012-08-02 08:29:38 +0000 config/ config. go 2012-08-30 09:11:09 +0000
=== modified file 'environs/
--- environs/
+++ environs/
@@ -47,6 +47,13 @@
}
}
+ // Check that the agent version parses ok if set. version" ].(string) ; ok { -keys"] .(string)
+ if v, ok := c.m["agent-
+ if _, err := version.Parse(v); err != nil {
+ return nil, fmt.Errorf("invalid agent version in environment
configuration: %q", v)
+ }
+ }
+
// Copy unknown attributes onto the type-specific map.
for k, v := range attrs {
if _, ok := fields[k]; !ok {
@@ -76,6 +83,20 @@
return c.m["authorized
}
+// AgentVersion returns the proposed version number for the agent tools. version" ].(string)
+// It returns the zero version if unset.
+func (c *Config) AgentVersion() version.Number {
+ v, ok := c.m["agent-
+ if !ok {
+ return version.Number{}
+ }
+ n, err := version.Parse(v)
+ if err != nil {
+ panic(err) // We should have checked it earlier.
+ }
...