cord-776 create build / runtime containers for autmation uservices
Change-Id: I246973192adef56a250ffe93a5f65fff488840c1
diff --git a/automation/vendor/github.com/juju/schema/LICENSE b/automation/vendor/github.com/juju/schema/LICENSE
new file mode 100644
index 0000000..ade9307
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/LICENSE
@@ -0,0 +1,191 @@
+All files in this repository are licensed as follows. If you contribute
+to this repository, it is assumed that you license your contribution
+under the same license unless you state otherwise.
+
+All files Copyright (C) 2015 Canonical Ltd. unless otherwise specified in the file.
+
+This software is licensed under the LGPLv3, included below.
+
+As a special exception to the GNU Lesser General Public License version 3
+("LGPL3"), the copyright holders of this Library give you permission to
+convey to a third party a Combined Work that links statically or dynamically
+to this Library without providing any Minimal Corresponding Source or
+Minimal Application Code as set out in 4d or providing the installation
+information set out in section 4e, provided that you comply with the other
+provisions of LGPL3 and provided that you meet, for the Application the
+terms and conditions of the license(s) which apply to the Application.
+
+Except as stated in this special exception, the provisions of LGPL3 will
+continue to comply in full to this Library. If you modify this Library, you
+may apply this exception to your version of this Library, but you are not
+obliged to do so. If you do not wish to do so, delete this exception
+statement from your version. This exception does not (and cannot) modify any
+license terms which apply to the Application, with which you must still
+comply.
+
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/automation/vendor/github.com/juju/schema/README.md b/automation/vendor/github.com/juju/schema/README.md
new file mode 100644
index 0000000..78ad8a1
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/README.md
@@ -0,0 +1,5 @@
+juju/schema
+===========
+
+This package provides helpers for coercing dynamically typed data structures
+into known forms.
diff --git a/automation/vendor/github.com/juju/schema/checker.go b/automation/vendor/github.com/juju/schema/checker.go
new file mode 100644
index 0000000..8682136
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/checker.go
@@ -0,0 +1,71 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "strings"
+)
+
+// The Coerce method of the Checker interface is called recursively when
+// v is being validated. If err is nil, newv is used as the new value
+// at the recursion point. If err is non-nil, v is taken as invalid and
+// may be either ignored or error out depending on where in the schema
+// checking process the error happened. Checkers like OneOf may continue
+// with an alternative, for instance.
+type Checker interface {
+ Coerce(v interface{}, path []string) (newv interface{}, err error)
+}
+
+// Any returns a Checker that succeeds with any input value and
+// results in the value itself unprocessed.
+func Any() Checker {
+ return anyC{}
+}
+
+type anyC struct{}
+
+func (c anyC) Coerce(v interface{}, path []string) (interface{}, error) {
+ return v, nil
+}
+
+// OneOf returns a Checker that attempts to Coerce the value with each
+// of the provided checkers. The value returned by the first checker
+// that succeeds will be returned by the OneOf checker itself. If no
+// checker succeeds, OneOf will return an error on coercion.
+func OneOf(options ...Checker) Checker {
+ return oneOfC{options}
+}
+
+type oneOfC struct {
+ options []Checker
+}
+
+func (c oneOfC) Coerce(v interface{}, path []string) (interface{}, error) {
+ for _, o := range c.options {
+ newv, err := o.Coerce(v, path)
+ if err == nil {
+ return newv, nil
+ }
+ }
+ return nil, error_{"", v, path}
+}
+
+// pathAsPrefix returns a string consisting of the path elements
+// suitable for using as the prefix of an error message. If path
+// starts with a ".", the dot is omitted.
+func pathAsPrefix(path []string) string {
+ if len(path) == 0 {
+ return ""
+ }
+ var s string
+ if path[0] == "." {
+ s = strings.Join(path[1:], "")
+ } else {
+ s = strings.Join(path, "")
+ }
+ if s == "" {
+ return ""
+ }
+ return s + ": "
+}
diff --git a/automation/vendor/github.com/juju/schema/const.go b/automation/vendor/github.com/juju/schema/const.go
new file mode 100644
index 0000000..cbd03b8
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/const.go
@@ -0,0 +1,57 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "fmt"
+ "reflect"
+)
+
+// Const returns a Checker that only succeeds if the input matches
+// value exactly. The value is compared with reflect.DeepEqual.
+func Const(value interface{}) Checker {
+ return constC{value}
+}
+
+type constC struct {
+ value interface{}
+}
+
+func (c constC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if reflect.DeepEqual(v, c.value) {
+ return v, nil
+ }
+ return nil, error_{fmt.Sprintf("%#v", c.value), v, path}
+}
+
+// Nil returns a Checker that only succeeds if the input is nil. To tweak the
+// error message, valueLabel can contain a label of the value being checked to
+// be empty, e.g. "my special name". If valueLabel is "", "value" will be used
+// as a label instead.
+//
+// Example 1:
+// schema.Nil("widget").Coerce(42, nil) will return an error message
+// like `expected empty widget, got int(42)`.
+//
+// Example 2:
+// schema.Nil("").Coerce("", nil) will return an error message like
+// `expected empty value, got string("")`.
+func Nil(valueLabel string) Checker {
+ if valueLabel == "" {
+ valueLabel = "value"
+ }
+ return nilC{valueLabel}
+}
+
+type nilC struct {
+ valueLabel string
+}
+
+func (c nilC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if reflect.DeepEqual(v, nil) {
+ return v, nil
+ }
+ label := fmt.Sprintf("empty %s", c.valueLabel)
+ return nil, error_{label, v, path}
+}
diff --git a/automation/vendor/github.com/juju/schema/errors.go b/automation/vendor/github.com/juju/schema/errors.go
new file mode 100644
index 0000000..f62f58e
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/errors.go
@@ -0,0 +1,25 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "fmt"
+)
+
+type error_ struct {
+ want string
+ got interface{}
+ path []string
+}
+
+func (e error_) Error() string {
+ path := pathAsPrefix(e.path)
+ if e.want == "" {
+ return fmt.Sprintf("%sunexpected value %#v", path, e.got)
+ }
+ if e.got == nil {
+ return fmt.Sprintf("%sexpected %s, got nothing", path, e.want)
+ }
+ return fmt.Sprintf("%sexpected %s, got %T(%#v)", path, e.want, e.got, e.got)
+}
diff --git a/automation/vendor/github.com/juju/schema/fieldmap.go b/automation/vendor/github.com/juju/schema/fieldmap.go
new file mode 100644
index 0000000..765f7e3
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/fieldmap.go
@@ -0,0 +1,170 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "fmt"
+ "reflect"
+)
+
+// Omit is a marker for FieldMap and StructFieldMap defaults parameter.
+// If a field is not present in the map and defaults to Omit, the missing
+// field will be ommitted from the coerced map as well.
+var Omit omit
+
+type omit struct{}
+
+type Fields map[string]Checker
+type Defaults map[string]interface{}
+
+// FieldMap returns a Checker that accepts a map value with defined
+// string keys. Every key has an independent checker associated,
+// and processing will only succeed if all the values succeed
+// individually. If a field fails to be processed, processing stops
+// 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
+// missing field will be omitted from the coerced map.
+//
+// The coerced output value has type map[string]interface{}.
+func FieldMap(fields Fields, defaults Defaults) Checker {
+ return fieldMapC{fields, defaults, false}
+}
+
+// StrictFieldMap returns a Checker that acts as the one returned by FieldMap,
+// but the Checker returns an error if it encounters an unknown key.
+func StrictFieldMap(fields Fields, defaults Defaults) Checker {
+ return fieldMapC{fields, defaults, true}
+}
+
+type fieldMapC struct {
+ fields Fields
+ defaults Defaults
+ strict bool
+}
+
+var stringType = reflect.TypeOf("")
+
+func hasStrictStringKeys(rv reflect.Value) bool {
+ if rv.Type().Key() == stringType {
+ return true
+ }
+ if rv.Type().Key().Kind() != reflect.Interface {
+ return false
+ }
+ for _, k := range rv.MapKeys() {
+ if k.Elem().Type() != stringType {
+ return false
+ }
+ }
+ return true
+}
+
+func (c fieldMapC) Coerce(v interface{}, path []string) (interface{}, error) {
+ rv := reflect.ValueOf(v)
+ if rv.Kind() != reflect.Map {
+ return nil, error_{"map", v, path}
+ }
+ if !hasStrictStringKeys(rv) {
+ return nil, error_{"map[string]", v, path}
+ }
+
+ if c.strict {
+ for _, k := range rv.MapKeys() {
+ ks := k.String()
+ if _, ok := c.fields[ks]; !ok {
+ return nil, fmt.Errorf("%sunknown key %q (value %#v)", pathAsPrefix(path), ks, rv.MapIndex(k).Interface())
+ }
+ }
+ }
+
+ vpath := append(path, ".", "?")
+
+ out := make(map[string]interface{}, rv.Len())
+ for k, checker := range c.fields {
+ valuev := rv.MapIndex(reflect.ValueOf(k))
+ var value interface{}
+ if valuev.IsValid() {
+ value = valuev.Interface()
+ } else if dflt, ok := c.defaults[k]; ok {
+ if dflt == Omit {
+ continue
+ }
+ value = dflt
+ }
+ vpath[len(vpath)-1] = k
+ newv, err := checker.Coerce(value, vpath)
+ if err != nil {
+ return nil, err
+ }
+ out[k] = newv
+ }
+ for k, v := range c.defaults {
+ if v == Omit {
+ continue
+ }
+ if _, ok := out[k]; !ok {
+ checker, ok := c.fields[k]
+ if !ok {
+ return nil, fmt.Errorf("got default value for unknown field %q", k)
+ }
+ vpath[len(vpath)-1] = k
+ newv, err := checker.Coerce(v, vpath)
+ if err != nil {
+ return nil, err
+ }
+ out[k] = newv
+ }
+ }
+ return out, nil
+}
+
+// FieldMapSet returns a Checker that accepts a map value checked
+// against one of several FieldMap checkers. The actual checker
+// used is the first one whose checker associated with the selector
+// field processes the map correctly. If no checker processes
+// the selector value correctly, an error is returned.
+//
+// The coerced output value has type map[string]interface{}.
+func FieldMapSet(selector string, maps []Checker) Checker {
+ fmaps := make([]fieldMapC, len(maps))
+ for i, m := range maps {
+ if fmap, ok := m.(fieldMapC); ok {
+ if checker, _ := fmap.fields[selector]; checker == nil {
+ panic("FieldMapSet has a FieldMap with a missing selector")
+ }
+ fmaps[i] = fmap
+ } else {
+ panic("FieldMapSet got a non-FieldMap checker")
+ }
+ }
+ return mapSetC{selector, fmaps}
+}
+
+type mapSetC struct {
+ selector string
+ fmaps []fieldMapC
+}
+
+func (c mapSetC) Coerce(v interface{}, path []string) (interface{}, error) {
+ rv := reflect.ValueOf(v)
+ if rv.Kind() != reflect.Map {
+ return nil, error_{"map", v, path}
+ }
+
+ var selector interface{}
+ selectorv := rv.MapIndex(reflect.ValueOf(c.selector))
+ if selectorv.IsValid() {
+ selector = selectorv.Interface()
+ for _, fmap := range c.fmaps {
+ _, err := fmap.fields[c.selector].Coerce(selector, path)
+ if err != nil {
+ continue
+ }
+ return fmap.Coerce(v, path)
+ }
+ }
+ return nil, error_{"supported selector", selector, append(path, ".", c.selector)}
+}
diff --git a/automation/vendor/github.com/juju/schema/lists.go b/automation/vendor/github.com/juju/schema/lists.go
new file mode 100644
index 0000000..635425a
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/lists.go
@@ -0,0 +1,44 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "reflect"
+ "strconv"
+)
+
+// List returns a Checker that accepts a slice value with values
+// that are processed with the elem checker. If any element of the
+// provided slice value fails to be processed, processing will stop
+// and return with the obtained error.
+//
+// The coerced output value has type []interface{}.
+func List(elem Checker) Checker {
+ return listC{elem}
+}
+
+type listC struct {
+ elem Checker
+}
+
+func (c listC) Coerce(v interface{}, path []string) (interface{}, error) {
+ rv := reflect.ValueOf(v)
+ if rv.Kind() != reflect.Slice {
+ return nil, error_{"list", v, path}
+ }
+
+ path = append(path, "[", "?", "]")
+
+ l := rv.Len()
+ out := make([]interface{}, 0, l)
+ for i := 0; i != l; i++ {
+ path[len(path)-2] = strconv.Itoa(i)
+ elem, err := c.elem.Coerce(rv.Index(i).Interface(), path)
+ if err != nil {
+ return nil, err
+ }
+ out = append(out, elem)
+ }
+ return out, nil
+}
diff --git a/automation/vendor/github.com/juju/schema/maps.go b/automation/vendor/github.com/juju/schema/maps.go
new file mode 100644
index 0000000..31242a0
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/maps.go
@@ -0,0 +1,93 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "fmt"
+ "reflect"
+)
+
+// Map returns a Checker that accepts a map value. Every key and value
+// in the map are processed with the respective checker, and if any
+// value fails to be coerced, processing stops and returns with the
+// underlying error.
+//
+// The coerced output value has type map[interface{}]interface{}.
+func Map(key Checker, value Checker) Checker {
+ return mapC{key, value}
+}
+
+type mapC struct {
+ key Checker
+ value Checker
+}
+
+func (c mapC) Coerce(v interface{}, path []string) (interface{}, error) {
+ rv := reflect.ValueOf(v)
+ if rv.Kind() != reflect.Map {
+ return nil, error_{"map", v, path}
+ }
+
+ vpath := append(path, ".", "?")
+
+ l := rv.Len()
+ out := make(map[interface{}]interface{}, l)
+ keys := rv.MapKeys()
+ for i := 0; i != l; i++ {
+ k := keys[i]
+ newk, err := c.key.Coerce(k.Interface(), path)
+ if err != nil {
+ return nil, err
+ }
+ vpath[len(vpath)-1] = fmt.Sprint(k.Interface())
+ newv, err := c.value.Coerce(rv.MapIndex(k).Interface(), vpath)
+ if err != nil {
+ return nil, err
+ }
+ out[newk] = newv
+ }
+ return out, nil
+}
+
+// StringMap returns a Checker that accepts a map value. Every key in
+// the map must be a string, and every value in the map are processed
+// with the provided checker. If any value fails to be coerced,
+// processing stops and returns with the underlying error.
+//
+// The coerced output value has type map[string]interface{}.
+func StringMap(value Checker) Checker {
+ return stringMapC{value}
+}
+
+type stringMapC struct {
+ value Checker
+}
+
+func (c stringMapC) Coerce(v interface{}, path []string) (interface{}, error) {
+ rv := reflect.ValueOf(v)
+ if rv.Kind() != reflect.Map {
+ return nil, error_{"map", v, path}
+ }
+
+ vpath := append(path, ".", "?")
+ key := String()
+
+ l := rv.Len()
+ out := make(map[string]interface{}, l)
+ keys := rv.MapKeys()
+ for i := 0; i != l; i++ {
+ k := keys[i]
+ newk, err := key.Coerce(k.Interface(), path)
+ if err != nil {
+ return nil, err
+ }
+ vpath[len(vpath)-1] = fmt.Sprint(k.Interface())
+ newv, err := c.value.Coerce(rv.MapIndex(k).Interface(), vpath)
+ if err != nil {
+ return nil, err
+ }
+ out[newk.(string)] = newv
+ }
+ return out, nil
+}
diff --git a/automation/vendor/github.com/juju/schema/numeric.go b/automation/vendor/github.com/juju/schema/numeric.go
new file mode 100644
index 0000000..ec88e56
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/numeric.go
@@ -0,0 +1,197 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "reflect"
+ "strconv"
+)
+
+// Bool returns a Checker that accepts boolean values only.
+func Bool() Checker {
+ return boolC{}
+}
+
+type boolC struct{}
+
+func (c boolC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil {
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.Bool:
+ return v, nil
+ case reflect.String:
+ val, err := strconv.ParseBool(reflect.ValueOf(v).String())
+ if err == nil {
+ return val, nil
+ }
+ }
+ }
+ return nil, error_{"bool", v, path}
+}
+
+// Int returns a Checker that accepts any integer value, and returns
+// the same value consistently typed as an int64.
+func Int() Checker {
+ return intC{}
+}
+
+type intC struct{}
+
+func (c intC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"int", v, path}
+ }
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.Int:
+ case reflect.Int8:
+ case reflect.Int16:
+ case reflect.Int32:
+ case reflect.Int64:
+ case reflect.String:
+ val, err := strconv.ParseInt(reflect.ValueOf(v).String(), 0, 64)
+ if err == nil {
+ return val, nil
+ } else {
+ return nil, error_{"int", v, path}
+ }
+ default:
+ return nil, error_{"int", v, path}
+ }
+ return reflect.ValueOf(v).Int(), nil
+}
+
+// Uint returns a Checker that accepts any integer or unsigned value, and
+// returns the same value consistently typed as an uint64. If the integer
+// value is negative an error is raised.
+func Uint() Checker {
+ return uintC{}
+}
+
+type uintC struct{}
+
+func (c uintC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"uint", v, path}
+ }
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ return reflect.ValueOf(v).Uint(), nil
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ val := reflect.ValueOf(v).Int()
+ if val < 0 {
+ return nil, error_{"uint", v, path}
+ }
+ // All positive int64 values fit into uint64.
+ return uint64(val), nil
+ case reflect.String:
+ val, err := strconv.ParseUint(reflect.ValueOf(v).String(), 0, 64)
+ if err == nil {
+ return val, nil
+ } else {
+ return nil, error_{"uint", v, path}
+ }
+ default:
+ return nil, error_{"uint", v, path}
+ }
+}
+
+// ForceInt returns a Checker that accepts any integer or float value, and
+// returns the same value consistently typed as an int. This is required
+// in order to handle the interface{}/float64 type conversion performed by
+// the JSON serializer used as part of the API infrastructure.
+func ForceInt() Checker {
+ return forceIntC{}
+}
+
+type forceIntC struct{}
+
+func (c forceIntC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil {
+ switch vv := reflect.TypeOf(v); vv.Kind() {
+ case reflect.String:
+ vstr := reflect.ValueOf(v).String()
+ intValue, err := strconv.ParseInt(vstr, 0, 64)
+ if err == nil {
+ return int(intValue), nil
+ }
+ floatValue, err := strconv.ParseFloat(vstr, 64)
+ if err == nil {
+ return int(floatValue), nil
+ }
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ return int(reflect.ValueOf(v).Int()), nil
+ case reflect.Float32, reflect.Float64:
+ return int(reflect.ValueOf(v).Float()), nil
+ }
+ }
+ return nil, error_{"number", v, path}
+}
+
+// ForceUint returns a Checker that accepts any integer or float value, and
+// returns the same value consistently typed as an uint64. This is required
+// in order to handle the interface{}/float64 type conversion performed by
+// the JSON serializer used as part of the API infrastructure. If the integer
+// value is negative an error is raised.
+func ForceUint() Checker {
+ return forceUintC{}
+}
+
+type forceUintC struct{}
+
+func (c forceUintC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil {
+ switch vv := reflect.TypeOf(v); vv.Kind() {
+ case reflect.String:
+ vstr := reflect.ValueOf(v).String()
+ intValue, err := strconv.ParseUint(vstr, 0, 64)
+ if err == nil {
+ return intValue, nil
+ }
+ floatValue, err := strconv.ParseFloat(vstr, 64)
+ if err == nil {
+ if floatValue < 0 {
+ return nil, error_{"uint", v, path}
+ }
+ return uint64(floatValue), nil
+ }
+ case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
+ return reflect.ValueOf(v).Uint(), nil
+ case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+ val := reflect.ValueOf(v).Int()
+ if val < 0 {
+ return nil, error_{"uint", v, path}
+ }
+ // All positive int64 values fit into uint64.
+ return uint64(val), nil
+ case reflect.Float32, reflect.Float64:
+ val := reflect.ValueOf(v).Float()
+ if val < 0 {
+ return nil, error_{"uint", v, path}
+ }
+ return uint64(val), nil
+ }
+ }
+ return nil, error_{"uint", v, path}
+}
+
+// Float returns a Checker that accepts any float value, and returns
+// the same value consistently typed as a float64.
+func Float() Checker {
+ return floatC{}
+}
+
+type floatC struct{}
+
+func (c floatC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"float", v, path}
+ }
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.Float32:
+ case reflect.Float64:
+ default:
+ return nil, error_{"float", v, path}
+ }
+ return reflect.ValueOf(v).Float(), nil
+}
diff --git a/automation/vendor/github.com/juju/schema/size.go b/automation/vendor/github.com/juju/schema/size.go
new file mode 100644
index 0000000..1ad0caa
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/size.go
@@ -0,0 +1,42 @@
+// Copyright 2016 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "github.com/juju/utils"
+ "reflect"
+)
+
+// Size returns a Checker that accepts a string value, and returns
+// the parsed string as a size in mebibytes see: https://godoc.org/github.com/juju/utils#ParseSize
+func Size() Checker {
+ return sizeC{}
+}
+
+type sizeC struct{}
+
+// Coerce implements Checker Coerce method.
+func (c sizeC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"string", v, path}
+ }
+
+ typeOf := reflect.TypeOf(v).Kind()
+ if typeOf != reflect.String {
+ return nil, error_{"string", v, path}
+ }
+
+ value := reflect.ValueOf(v).String()
+ if value == "" {
+ return nil, error_{"empty string", v, path}
+ }
+
+ v, err := utils.ParseSize(value)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return v, nil
+}
diff --git a/automation/vendor/github.com/juju/schema/strings.go b/automation/vendor/github.com/juju/schema/strings.go
new file mode 100644
index 0000000..75f6120
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/strings.go
@@ -0,0 +1,155 @@
+// Copyright 2015 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "fmt"
+ "net/url"
+ "reflect"
+ "regexp"
+)
+
+// String returns a Checker that accepts a string value only and returns
+// it unprocessed.
+func String() Checker {
+ return stringC{}
+}
+
+type stringC struct{}
+
+func (c stringC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil && reflect.TypeOf(v).Kind() == reflect.String {
+ return reflect.ValueOf(v).String(), nil
+ }
+ return nil, error_{"string", v, path}
+}
+
+// URL returns a Checker that accepts a string value that must be parseable as a
+// URL, and returns a *net.URL.
+func URL() Checker {
+ return urlC{}
+}
+
+type urlC struct{}
+
+func (c urlC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil && reflect.TypeOf(v).Kind() == reflect.String {
+ s := reflect.ValueOf(v).String()
+ u, err := url.Parse(s)
+ if err != nil {
+ return nil, error_{"valid url", s, path}
+ }
+ return u, nil
+ }
+ return nil, error_{"url string", v, path}
+}
+
+// SimpleRegexp returns a checker that accepts a string value that is
+// a valid regular expression and returns it unprocessed.
+func SimpleRegexp() Checker {
+ return sregexpC{}
+}
+
+type sregexpC struct{}
+
+func (c sregexpC) Coerce(v interface{}, path []string) (interface{}, error) {
+ // XXX The regexp package happens to be extremely simple right now.
+ // Once exp/regexp goes mainstream, we'll have to update this
+ // logic to use a more widely accepted regexp subset.
+ if v != nil && reflect.TypeOf(v).Kind() == reflect.String {
+ s := reflect.ValueOf(v).String()
+ _, err := regexp.Compile(s)
+ if err != nil {
+ return nil, error_{"valid regexp", s, path}
+ }
+ return v, nil
+ }
+ return nil, error_{"regexp string", v, path}
+}
+
+// UUID returns a Checker that accepts a string value only and returns
+// it unprocessed.
+func UUID() Checker {
+ return uuidC{}
+}
+
+type uuidC struct{}
+
+var uuidregex = regexp.MustCompile(`[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}`)
+
+func (c uuidC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v != nil && reflect.TypeOf(v).Kind() == reflect.String {
+ uuid := reflect.ValueOf(v).String()
+ if uuidregex.MatchString(uuid) {
+ return uuid, nil
+ }
+ }
+ return nil, error_{"uuid", v, path}
+}
+
+// Stringified returns a checker that accepts a bool/int/float/string
+// value and returns its string. Other value types may be supported by
+// passing in their checkers.
+func Stringified(checkers ...Checker) Checker {
+ return stringifiedC{
+ checkers: checkers,
+ }
+}
+
+type stringifiedC struct {
+ checkers []Checker
+}
+
+func (c stringifiedC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if newStr, err := String().Coerce(v, path); err == nil {
+ return newStr, nil
+ }
+ _, err := OneOf(append(c.checkers,
+ Bool(),
+ Int(),
+ Float(),
+ String(),
+ URL(),
+ )...).Coerce(v, path)
+ if err != nil {
+ return nil, err
+ }
+ return fmt.Sprintf("%#v", v), nil
+}
+
+// NonEmptyString returns a Checker that only accepts non-empty strings. To
+// tweak the error message, valueLabel can contain a label of the value being
+// checked, e.g. "my special name". If valueLabel is "", "string" will be used
+// as a label instead.
+//
+// Example 1:
+// schema.NonEmptyString("widget").Coerce("", nil) will return an error message
+// like `expected non-empty widget, got string("")`.
+//
+// Example 2:
+// schema.NonEmptyString("").Coerce("", nil) will return an error message like
+// `expected non-empty string, got string("")`.
+func NonEmptyString(valueLabel string) Checker {
+ if valueLabel == "" {
+ valueLabel = "string"
+ }
+ return nonEmptyStringC{valueLabel}
+}
+
+type nonEmptyStringC struct {
+ valueLabel string
+}
+
+func (c nonEmptyStringC) Coerce(v interface{}, path []string) (interface{}, error) {
+ label := fmt.Sprintf("non-empty %s", c.valueLabel)
+ invalidError := error_{label, v, path}
+
+ if v == nil || reflect.TypeOf(v).Kind() != reflect.String {
+ return nil, invalidError
+ }
+ if stringValue := reflect.ValueOf(v).String(); stringValue != "" {
+ return stringValue, nil
+ }
+ return nil, invalidError
+}
diff --git a/automation/vendor/github.com/juju/schema/time.go b/automation/vendor/github.com/juju/schema/time.go
new file mode 100644
index 0000000..9521a2a
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/time.go
@@ -0,0 +1,41 @@
+// Copyright 2016 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "reflect"
+ "time"
+)
+
+// Time returns a Checker that accepts a string value, and returns
+// the parsed time.Time value. Emtpy strings are considered empty times.
+func Time() Checker {
+ return timeC{}
+}
+
+type timeC struct{}
+
+// Coerce implements Checker Coerce method.
+func (c timeC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"string or time.Time", v, path}
+ }
+ var empty time.Time
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.TypeOf(empty).Kind():
+ return v, nil
+ case reflect.String:
+ vstr := reflect.ValueOf(v).String()
+ if vstr == "" {
+ return empty, nil
+ }
+ v, err := time.Parse(time.RFC3339Nano, vstr)
+ if err != nil {
+ return nil, err
+ }
+ return v, nil
+ default:
+ return nil, error_{"string or time.Time", v, path}
+ }
+}
diff --git a/automation/vendor/github.com/juju/schema/time_duration.go b/automation/vendor/github.com/juju/schema/time_duration.go
new file mode 100644
index 0000000..71e75fe
--- /dev/null
+++ b/automation/vendor/github.com/juju/schema/time_duration.go
@@ -0,0 +1,42 @@
+// Copyright 2016 Canonical Ltd.
+// Licensed under the LGPLv3, see LICENCE file for details.
+
+package schema
+
+import (
+ "reflect"
+ "time"
+)
+
+// TimeDuration returns a Checker that accepts a string value, and returns
+// the parsed time.Duration value. Emtpy strings are considered empty time.Duration
+func TimeDuration() Checker {
+ return timeDurationC{}
+}
+
+type timeDurationC struct{}
+
+// Coerce implements Checker Coerce method.
+func (c timeDurationC) Coerce(v interface{}, path []string) (interface{}, error) {
+ if v == nil {
+ return nil, error_{"string or time.Duration", v, path}
+ }
+
+ var empty time.Duration
+ switch reflect.TypeOf(v).Kind() {
+ case reflect.TypeOf(empty).Kind():
+ return v, nil
+ case reflect.String:
+ vstr := reflect.ValueOf(v).String()
+ if vstr == "" {
+ return empty, nil
+ }
+ v, err := time.ParseDuration(vstr)
+ if err != nil {
+ return nil, err
+ }
+ return v, nil
+ default:
+ return nil, error_{"string or time.Duration", v, path}
+ }
+}