Liniting and test fixing
This commit is contained in:
parent
0d9043f6a2
commit
155c035e34
|
@ -64,7 +64,10 @@ func (s *localStack) Rename(ctx context.Context, newName tokens.QName) (backend.
|
|||
return backend.RenameStack(ctx, s, newName)
|
||||
}
|
||||
|
||||
func (s *localStack) Preview(ctx context.Context, op backend.UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
func (s *localStack) Preview(
|
||||
ctx context.Context,
|
||||
op backend.UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
|
||||
return backend.PreviewStack(ctx, s, op)
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,10 @@ func (s *cloudStack) Rename(ctx context.Context, newName tokens.QName) (backend.
|
|||
return backend.RenameStack(ctx, s, newName)
|
||||
}
|
||||
|
||||
func (s *cloudStack) Preview(ctx context.Context, op backend.UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
func (s *cloudStack) Preview(
|
||||
ctx context.Context,
|
||||
op backend.UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
|
||||
return backend.PreviewStack(ctx, s, op)
|
||||
}
|
||||
|
||||
|
|
|
@ -381,7 +381,10 @@ func (ms *MockStack) Backend() Backend {
|
|||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (ms *MockStack) Preview(ctx context.Context, op UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
func (ms *MockStack) Preview(
|
||||
ctx context.Context,
|
||||
op UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
|
||||
if ms.PreviewF != nil {
|
||||
return ms.PreviewF(ctx, op)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,11 @@ func RenameStack(ctx context.Context, s Stack, newName tokens.QName) (StackRefer
|
|||
}
|
||||
|
||||
// PreviewStack previews changes to this stack.
|
||||
func PreviewStack(ctx context.Context, s Stack, op UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
func PreviewStack(
|
||||
ctx context.Context,
|
||||
s Stack,
|
||||
op UpdateOperation) (deploy.Plan, engine.ResourceChanges, result.Result) {
|
||||
|
||||
return s.Backend().Preview(ctx, s, op)
|
||||
}
|
||||
|
||||
|
@ -119,7 +123,10 @@ func GetStackLogs(ctx context.Context, s Stack, cfg StackConfiguration,
|
|||
}
|
||||
|
||||
// ExportStackDeployment exports the given stack's deployment as an opaque JSON message.
|
||||
func ExportStackDeployment(ctx context.Context, s Stack) (*apitype.UntypedDeployment, error) {
|
||||
func ExportStackDeployment(
|
||||
ctx context.Context,
|
||||
s Stack) (*apitype.UntypedDeployment, error) {
|
||||
|
||||
return s.Backend().ExportDeployment(ctx, s)
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/pulumi/pulumi/pkg/v3/backend/display"
|
||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
||||
"github.com/pulumi/pulumi/pkg/v3/util"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/diag/colors"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
||||
|
@ -104,25 +105,25 @@ type planNode struct {
|
|||
func renderPlanNode(node *planNode, padding, branch string, rows *[]cmdutil.TableRow, color colors.Colorization) {
|
||||
padBranch := ""
|
||||
switch branch {
|
||||
case "├─ ":
|
||||
padBranch = "│ "
|
||||
case "└─ ":
|
||||
padBranch = " "
|
||||
case util.TBranchString:
|
||||
padBranch = util.TPaddingString
|
||||
case util.LBranchString:
|
||||
padBranch = util.LPaddingString
|
||||
}
|
||||
childPadding := padding + padBranch
|
||||
|
||||
infoBranch := " "
|
||||
infoBranch := util.LPaddingString
|
||||
if len(node.children) > 0 {
|
||||
infoBranch = "│ "
|
||||
infoBranch = util.TPaddingString
|
||||
}
|
||||
infoPadding := childPadding + infoBranch
|
||||
|
||||
*rows = append(*rows, renderResourcePlan(node.urn, node.plan, padding+branch, infoPadding, color))
|
||||
|
||||
for i, child := range node.children {
|
||||
childBranch := "├─ "
|
||||
childBranch := util.TBranchString
|
||||
if i == len(node.children)-1 {
|
||||
childBranch = "└─ "
|
||||
childBranch = util.LBranchString
|
||||
}
|
||||
renderPlanNode(child, childPadding, childBranch, rows, color)
|
||||
}
|
||||
|
@ -198,7 +199,13 @@ func renderPlan(plan deploy.Plan, showSames bool, color colors.Colorization) []c
|
|||
return rows
|
||||
}
|
||||
|
||||
func renderResourcePlan(urn resource.URN, plan *deploy.ResourcePlan, prefix, infoPrefix string, color colors.Colorization) cmdutil.TableRow {
|
||||
func renderResourcePlan(
|
||||
urn resource.URN,
|
||||
plan *deploy.ResourcePlan,
|
||||
prefix,
|
||||
infoPrefix string,
|
||||
color colors.Colorization) cmdutil.TableRow {
|
||||
|
||||
displayOp := deploy.OpSame
|
||||
if plan != nil {
|
||||
for _, op := range plan.Ops {
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"github.com/pulumi/pulumi/pkg/v3/backend/display"
|
||||
"github.com/pulumi/pulumi/pkg/v3/backend/httpstate"
|
||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
||||
"github.com/pulumi/pulumi/pkg/v3/util"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
||||
)
|
||||
|
@ -234,25 +235,25 @@ type treeNode struct {
|
|||
func renderNode(node *treeNode, padding, branch string, showURNs, showIDs bool, rows *[]cmdutil.TableRow) {
|
||||
padBranch := ""
|
||||
switch branch {
|
||||
case "├─ ":
|
||||
padBranch = "│ "
|
||||
case "└─ ":
|
||||
padBranch = " "
|
||||
case util.TBranchString:
|
||||
padBranch = util.TPaddingString
|
||||
case util.LBranchString:
|
||||
padBranch = util.LPaddingString
|
||||
}
|
||||
childPadding := padding + padBranch
|
||||
|
||||
infoBranch := " "
|
||||
infoBranch := util.LPaddingString
|
||||
if len(node.children) > 0 {
|
||||
infoBranch = "│ "
|
||||
infoBranch = util.TPaddingString
|
||||
}
|
||||
infoPadding := childPadding + infoBranch
|
||||
|
||||
*rows = append(*rows, renderResourceRow(node.res, padding+branch, infoPadding, showURNs, showIDs))
|
||||
|
||||
for i, child := range node.children {
|
||||
childBranch := "├─ "
|
||||
childBranch := util.TBranchString
|
||||
if i == len(node.children)-1 {
|
||||
childBranch = "└─ "
|
||||
childBranch = util.LBranchString
|
||||
}
|
||||
renderNode(child, childPadding, childBranch, showURNs, showIDs, rows)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,12 @@ import (
|
|||
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
||||
)
|
||||
|
||||
func Destroy(u UpdateInfo, ctx *Context, opts UpdateOptions, dryRun bool) (deploy.Plan, ResourceChanges, result.Result) {
|
||||
func Destroy(
|
||||
u UpdateInfo,
|
||||
ctx *Context,
|
||||
opts UpdateOptions,
|
||||
dryRun bool) (deploy.Plan, ResourceChanges, result.Result) {
|
||||
|
||||
contract.Require(u != nil, "u")
|
||||
contract.Require(ctx != nil, "ctx")
|
||||
|
||||
|
|
|
@ -23,7 +23,12 @@ import (
|
|||
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
||||
)
|
||||
|
||||
func Refresh(u UpdateInfo, ctx *Context, opts UpdateOptions, dryRun bool) (deploy.Plan, ResourceChanges, result.Result) {
|
||||
func Refresh(
|
||||
u UpdateInfo,
|
||||
ctx *Context,
|
||||
opts UpdateOptions,
|
||||
dryRun bool) (deploy.Plan, ResourceChanges, result.Result) {
|
||||
|
||||
contract.Require(u != nil, "u")
|
||||
contract.Require(ctx != nil, "ctx")
|
||||
|
||||
|
|
|
@ -147,7 +147,13 @@ func (m *resourceMap) mapRange(callback func(urn resource.URN, state *resource.S
|
|||
|
||||
type resourcePlans struct {
|
||||
m sync.RWMutex
|
||||
plans map[resource.URN]*ResourcePlan
|
||||
plans Plan
|
||||
}
|
||||
|
||||
func newResourcePlan() *resourcePlans {
|
||||
return &resourcePlans{
|
||||
plans: make(Plan),
|
||||
}
|
||||
}
|
||||
|
||||
func (m *resourcePlans) set(urn resource.URN, plan *ResourcePlan) {
|
||||
|
@ -378,7 +384,7 @@ func NewDeployment(ctx *plugin.Context, target *Target, prev *Snapshot, plan Pla
|
|||
providers: reg,
|
||||
goals: newGoals,
|
||||
news: newResources,
|
||||
newPlans: &resourcePlans{},
|
||||
newPlans: newResourcePlan(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,11 @@ func (ex *deploymentExecutor) retirePendingDeletes(callerCtx context.Context, op
|
|||
}
|
||||
|
||||
// import imports a list of resources into a stack.
|
||||
func (ex *deploymentExecutor) importResources(callerCtx context.Context, opts Options, preview bool) (Plan, result.Result) {
|
||||
func (ex *deploymentExecutor) importResources(
|
||||
callerCtx context.Context,
|
||||
opts Options,
|
||||
preview bool) (Plan, result.Result) {
|
||||
|
||||
if len(ex.deployment.imports) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ func NewImportDeployment(ctx *plugin.Context, target *Target, projectName tokens
|
|||
source: NewErrorSource(projectName),
|
||||
preview: preview,
|
||||
providers: reg,
|
||||
newPlans: newResourcePlan(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,8 @@ func (rp *ResourcePlan) checkGoal(programGoal *resource.Goal) error {
|
|||
}
|
||||
|
||||
// Check that the additionalSecretOutputs sets are identical.
|
||||
if message, changed := rp.diffPropertyKeys(rp.Goal.AdditionalSecretOutputs, programGoal.AdditionalSecretOutputs); changed {
|
||||
if message, changed := rp.diffPropertyKeys(
|
||||
rp.Goal.AdditionalSecretOutputs, programGoal.AdditionalSecretOutputs); changed {
|
||||
return fmt.Errorf("additionalSecretOutputs changed: %v", message)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,11 @@ import (
|
|||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
|
||||
)
|
||||
|
||||
func SerializeResourcePlan(plan *deploy.ResourcePlan, enc config.Encrypter, showSecrets bool) (apitype.ResourcePlanV1, error) {
|
||||
func SerializeResourcePlan(
|
||||
plan *deploy.ResourcePlan,
|
||||
enc config.Encrypter,
|
||||
showSecrets bool) (apitype.ResourcePlanV1, error) {
|
||||
|
||||
properties, err := SerializeProperties(plan.Goal.Properties, enc, showSecrets)
|
||||
if err != nil {
|
||||
return apitype.ResourcePlanV1{}, err
|
||||
|
@ -64,7 +68,11 @@ func SerializePlan(plan deploy.Plan, enc config.Encrypter, showSecrets bool) (ap
|
|||
return apitype.DeploymentPlanV1{ResourcePlans: resourcePlans}, nil
|
||||
}
|
||||
|
||||
func DeserializeResourcePlan(plan apitype.ResourcePlanV1, dec config.Decrypter, enc config.Encrypter) (*deploy.ResourcePlan, error) {
|
||||
func DeserializeResourcePlan(
|
||||
plan apitype.ResourcePlanV1,
|
||||
dec config.Decrypter,
|
||||
enc config.Encrypter) (*deploy.ResourcePlan, error) {
|
||||
|
||||
properties, err := DeserializeProperties(plan.Goal.Properties, dec, enc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
6
pkg/util/display.go
Normal file
6
pkg/util/display.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package util
|
||||
|
||||
const TBranchString = "├─ "
|
||||
const LBranchString = "└─ "
|
||||
const TPaddingString = "│ "
|
||||
const LPaddingString = " "
|
|
@ -457,8 +457,8 @@ func (v PropertyValue) DeepEquals(other PropertyValue) bool {
|
|||
return v.V == other.V
|
||||
}
|
||||
|
||||
func (m PropertyMap) ConstrainedTo(constraints PropertyMap) (*ObjectDiff, bool) {
|
||||
diff := constraints.diff(m, true, nil)
|
||||
func (props PropertyMap) ConstrainedTo(constraints PropertyMap) (*ObjectDiff, bool) {
|
||||
diff := constraints.diff(props, true, nil)
|
||||
return diff, diff == nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue