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

Unified Diff: environs/open.go

Issue 6215045: environs: add NewEnviron(kind, config) (Closed)
Patch Set: environs: add NewEnviron(kind, config) Created 12 years, 10 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/interface.go ('k') | environs/open_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: environs/open.go
=== modified file 'environs/open.go'
--- environs/open.go 2012-05-14 23:40:28 +0000
+++ environs/open.go 2012-05-17 01:43:20 +0000
@@ -2,9 +2,8 @@
import "fmt"
-// New creates a new Environ using the
-// environment configuration with the given name.
-// If name is empty, the default environment will be used.
+// Open creates a new Environ using the environment configuration with the
+// given name. If name is empty, the default environment will be used.
func (envs *Environs) Open(name string) (Environ, error) {
if name == "" {
name = envs.Default
@@ -26,3 +25,20 @@
return env, nil
}
+
+// NewEnviron creates a new Environ of the registered kind using the configuration
+// supplied.
+func NewEnviron(kind string, config map[string]interface{}) (Environ, error) {
+ p, ok := providers[kind]
+ if !ok {
+ return nil, fmt.Errorf("no registered provider for kind: %q", kind)
+ }
+ cfg, err := p.ConfigChecker().Coerce(config, nil)
+ if err != nil {
+ return nil, fmt.Errorf("error validating environment: %v", err)
+ }
+
+ // TODO(dfc) the name of the environment needs to be injected when it is
+ // created from environments.yaml
+ return p.Open("default", cfg)
+}
« no previous file with comments | « environs/interface.go ('k') | environs/open_test.go » ('j') | no next file with comments »

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