pulumi/pkg/engine/config_delete.go
Matt Ellis 93ab134bbb Have the CLI keep track of the current environment
Previously, the engine was concered with maintaing information about
the currently active environment. Now, the CLI is in charge of
this. As part of this change, the engine can now assume that every
environment has a non empty name (and I've added asserts on the
entrypoints of the engine API to ensure that any consumer of the
engine passes a non empty environment name)
2017-10-02 16:57:41 -07:00

29 lines
671 B
Go

// Copyright 2017, Pulumi Corporation. All rights reserved.
package engine
import (
"github.com/pkg/errors"
"github.com/pulumi/pulumi/pkg/tokens"
"github.com/pulumi/pulumi/pkg/util/contract"
)
func (eng *Engine) DeleteConfig(envName tokens.QName, key tokens.ModuleMember) error {
contract.Require(envName != tokens.QName(""), "envName")
info, err := eng.initEnvCmdName(envName, "")
if err != nil {
return err
}
config := info.Target.Config
if config != nil {
delete(config, key)
if err = eng.Environment.SaveEnvironment(info.Target, info.Snapshot); err != nil {
return errors.Wrap(err, "could not save configuration value")
}
}
return nil
}