This refactors the engine so all of the APIs on it are instance methods on the type instead of raw methods that float around and use data from a global engine. A mechcanical change as we remove the global `E` and then make anything that interacted with that in pkg/engine to be an instance method and the dealing with the fallout.
28 lines
612 B
Go
28 lines
612 B
Go
package engine
|
|
|
|
import (
|
|
"github.com/pkg/errors"
|
|
"github.com/pulumi/pulumi-fabric/pkg/resource"
|
|
"github.com/pulumi/pulumi-fabric/pkg/tokens"
|
|
)
|
|
|
|
func (eng *Engine) SetConfig(envName string, key string, value string) error {
|
|
info, err := eng.initEnvCmdName(tokens.QName(envName), "")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
config := info.Target.Config
|
|
|
|
if config == nil {
|
|
config = make(resource.ConfigMap)
|
|
info.Target.Config = config
|
|
}
|
|
|
|
config[tokens.Token(key)] = value
|
|
|
|
if !eng.saveEnv(info.Target, info.Snapshot, "", true) {
|
|
return errors.Errorf("could not save configuration value")
|
|
}
|
|
|
|
return nil
|
|
}
|