As explained in pulumi/pulumi-fabric#293, we were a little ad-hoc in how configuration was "applied" to resource providers. In fact, config wasn't ever communicated directly to providers; instead, the resource providers would simply ask the engine to read random heap locations (via tokens). Now that we're on a plan where configuration gets handed to the program at startup, and that's that, and where generally speaking resource providers never communicate directly with the language runtime, we need to take a different approach. As such, the resource provider interface now offers a Configure RPC method that the resource planning engine will invoke at the right times with the right subset of configuration variables filtered to just that provider's package. This fixes pulumi/pulumi#293.
27 lines
589 B
Go
27 lines
589 B
Go
// Copyright 2017, Pulumi Corporation. All rights reserved.
|
|
|
|
package engine
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/pulumi/pulumi-fabric/pkg/tokens"
|
|
)
|
|
|
|
func (eng *Engine) GetConfig(envName string, key tokens.ModuleMember) error {
|
|
info, err := eng.initEnvCmdName(tokens.QName(envName), "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
config := info.Target.Config
|
|
if config != nil {
|
|
if v, has := config[key]; has {
|
|
fmt.Fprintf(eng.Stdout, "%v\n", v)
|
|
return nil
|
|
}
|
|
}
|
|
|
|
return errors.Errorf("configuration key '%v' not found for environment '%v'", key, info.Target.Name)
|
|
}
|