cord-776 create build / runtime containers for autmation uservices
Change-Id: I246973192adef56a250ffe93a5f65fff488840c1
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}
+ }
+}