pulumi/pkg/engine/env_remove.go
Matt Ellis 865422567c Alow multiple instances of engine.Engine
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.
2017-08-24 18:09:37 -07:00

25 lines
577 B
Go

package engine
import (
"github.com/pkg/errors"
"github.com/pulumi/pulumi-fabric/pkg/util/contract"
)
func (eng *Engine) RemoveEnv(envName string, force bool) error {
contract.Assert(envName != "")
info, err := eng.initEnvCmd(envName, "")
if err != nil {
return err
}
// Don't remove environments that still have resources.
if !force && info.Snapshot != nil && len(info.Snapshot.Resources) > 0 {
return errors.Errorf(
"'%v' still has resources; removal rejected; pass --force to override", info.Target.Name)
}
eng.removeTarget(info.Target)
return nil
}