27 lines
688 B
Go
27 lines
688 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) RemoveEnv(envName tokens.QName, force bool) error {
|
|
contract.Assert(envName != "")
|
|
|
|
info, err := eng.planContextFromEnvironment(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)
|
|
}
|
|
|
|
return eng.removeTarget(info.Target)
|
|
}
|