Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1494)

Unified Diff: environs/ec2/util.go

Issue 6213050: environs: simplify EnvironProvider interface.
Patch Set: environs: simplify EnvironProvider interface. Created 12 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « environs/ec2/ec2.go ('k') | environs/interface.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: environs/ec2/util.go
=== modified file 'environs/ec2/util.go'
--- environs/ec2/util.go 2012-03-12 18:04:37 +0000
+++ environs/ec2/util.go 2012-05-17 08:58:09 +0000
@@ -1,48 +1,9 @@
package ec2
import (
- "launchpad.net/juju/go/schema"
"time"
)
-// this stuff could/should be in the schema package.
-
-// checkerFunc defines a schema.Checker using a function that
-// implements scheme.Checker.Coerce.
-type checkerFunc func(v interface{}, path []string) (newv interface{}, err error)
-
-func (f checkerFunc) Coerce(v interface{}, path []string) (newv interface{}, err error) {
- return f(v, path)
-}
-
-// combineCheckers returns a Checker that checks a value by passing it
-// through the "pipeline" defined by checkers. When the returned checker's
-// Coerce method is called on a value, the value is passed through the
-// first checker in checkers; the resulting value is used as input to the
-// next checker, and so on.
-func combineCheckers(checkers ...schema.Checker) schema.Checker {
- f := func(v interface{}, path []string) (newv interface{}, err error) {
- for _, c := range checkers {
- v, err = c.Coerce(v, path)
- if err != nil {
- return nil, err
- }
- }
- return v, nil
- }
- return checkerFunc(f)
-}
-
-// oneOf(a, b, c) is equivalent to (but less verbose than):
-// schema.OneOf(schema.Const(a), schema.Const(b), schema.Const(c))
-func oneOf(values ...interface{}) schema.Checker {
- c := make([]schema.Checker, len(values))
- for i, v := range values {
- c[i] = schema.Const(v)
- }
- return schema.OneOf(c...)
-}
-
// attemptStrategy represents a strategy for waiting for an ec2 request
// to complete successfully.
//
« no previous file with comments | « environs/ec2/ec2.go ('k') | environs/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b