Remove GetConfiguration from Engine
This commit is contained in:
parent
1e133cda59
commit
242eb929fb
3 changed files with 15 additions and 23 deletions
|
@ -6,6 +6,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/pulumi/pulumi/pkg/util/contract"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ func newConfigCmd() *cobra.Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
func listConfig(envName tokens.QName) error {
|
func listConfig(envName tokens.QName) error {
|
||||||
config, err := lumiEngine.GetConfiguration(envName)
|
config, err := getConfiguration(envName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,7 @@ func listConfig(envName tokens.QName) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfig(envName tokens.QName, key tokens.ModuleMember) error {
|
func getConfig(envName tokens.QName, key tokens.ModuleMember) error {
|
||||||
config, err := lumiEngine.GetConfiguration(envName)
|
config, err := getConfiguration(envName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -90,5 +92,14 @@ func getConfig(envName tokens.QName, key tokens.ModuleMember) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Errorf("configuration key '%v' not found for environment '%v'", key, envName)
|
return errors.Errorf("configuration key '%v' not found for environment '%v'", key, envName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getConfiguration(envName tokens.QName) (map[tokens.ModuleMember]string, error) {
|
||||||
|
target, _, _, err := lumiEngine.Environment.GetEnvironment(envName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
contract.Assert(target != nil)
|
||||||
|
return target.Config, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ func newEnvCmd() *cobra.Command {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
config, err := lumiEngine.GetConfiguration(envName)
|
config, err := getConfiguration(envName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2017, Pulumi Corporation. All rights reserved.
|
|
||||||
|
|
||||||
package engine
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/pulumi/pulumi/pkg/tokens"
|
|
||||||
"github.com/pulumi/pulumi/pkg/util/contract"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (eng *Engine) GetConfiguration(environment tokens.QName) (map[tokens.ModuleMember]string, error) {
|
|
||||||
contract.Require(environment != tokens.QName(""), "environment")
|
|
||||||
|
|
||||||
info, err := eng.planContextFromEnvironment(environment, "")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return info.Target.Config, nil
|
|
||||||
}
|
|
Loading…
Reference in a new issue