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)
|
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)
|
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)
|
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)
|
return backend.PreviewStack(ctx, s, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,7 +381,10 @@ func (ms *MockStack) Backend() Backend {
|
||||||
panic("not implemented")
|
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 {
|
if ms.PreviewF != nil {
|
||||||
return ms.PreviewF(ctx, op)
|
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.
|
// 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)
|
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.
|
// 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)
|
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/backend/display"
|
||||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
"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/diag/colors"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
"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) {
|
func renderPlanNode(node *planNode, padding, branch string, rows *[]cmdutil.TableRow, color colors.Colorization) {
|
||||||
padBranch := ""
|
padBranch := ""
|
||||||
switch branch {
|
switch branch {
|
||||||
case "├─ ":
|
case util.TBranchString:
|
||||||
padBranch = "│ "
|
padBranch = util.TPaddingString
|
||||||
case "└─ ":
|
case util.LBranchString:
|
||||||
padBranch = " "
|
padBranch = util.LPaddingString
|
||||||
}
|
}
|
||||||
childPadding := padding + padBranch
|
childPadding := padding + padBranch
|
||||||
|
|
||||||
infoBranch := " "
|
infoBranch := util.LPaddingString
|
||||||
if len(node.children) > 0 {
|
if len(node.children) > 0 {
|
||||||
infoBranch = "│ "
|
infoBranch = util.TPaddingString
|
||||||
}
|
}
|
||||||
infoPadding := childPadding + infoBranch
|
infoPadding := childPadding + infoBranch
|
||||||
|
|
||||||
*rows = append(*rows, renderResourcePlan(node.urn, node.plan, padding+branch, infoPadding, color))
|
*rows = append(*rows, renderResourcePlan(node.urn, node.plan, padding+branch, infoPadding, color))
|
||||||
|
|
||||||
for i, child := range node.children {
|
for i, child := range node.children {
|
||||||
childBranch := "├─ "
|
childBranch := util.TBranchString
|
||||||
if i == len(node.children)-1 {
|
if i == len(node.children)-1 {
|
||||||
childBranch = "└─ "
|
childBranch = util.LBranchString
|
||||||
}
|
}
|
||||||
renderPlanNode(child, childPadding, childBranch, rows, color)
|
renderPlanNode(child, childPadding, childBranch, rows, color)
|
||||||
}
|
}
|
||||||
|
@ -198,7 +199,13 @@ func renderPlan(plan deploy.Plan, showSames bool, color colors.Colorization) []c
|
||||||
return rows
|
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
|
displayOp := deploy.OpSame
|
||||||
if plan != nil {
|
if plan != nil {
|
||||||
for _, op := range plan.Ops {
|
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/display"
|
||||||
"github.com/pulumi/pulumi/pkg/v3/backend/httpstate"
|
"github.com/pulumi/pulumi/pkg/v3/backend/httpstate"
|
||||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
"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/resource"
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/cmdutil"
|
"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) {
|
func renderNode(node *treeNode, padding, branch string, showURNs, showIDs bool, rows *[]cmdutil.TableRow) {
|
||||||
padBranch := ""
|
padBranch := ""
|
||||||
switch branch {
|
switch branch {
|
||||||
case "├─ ":
|
case util.TBranchString:
|
||||||
padBranch = "│ "
|
padBranch = util.TPaddingString
|
||||||
case "└─ ":
|
case util.LBranchString:
|
||||||
padBranch = " "
|
padBranch = util.LPaddingString
|
||||||
}
|
}
|
||||||
childPadding := padding + padBranch
|
childPadding := padding + padBranch
|
||||||
|
|
||||||
infoBranch := " "
|
infoBranch := util.LPaddingString
|
||||||
if len(node.children) > 0 {
|
if len(node.children) > 0 {
|
||||||
infoBranch = "│ "
|
infoBranch = util.TPaddingString
|
||||||
}
|
}
|
||||||
infoPadding := childPadding + infoBranch
|
infoPadding := childPadding + infoBranch
|
||||||
|
|
||||||
*rows = append(*rows, renderResourceRow(node.res, padding+branch, infoPadding, showURNs, showIDs))
|
*rows = append(*rows, renderResourceRow(node.res, padding+branch, infoPadding, showURNs, showIDs))
|
||||||
|
|
||||||
for i, child := range node.children {
|
for i, child := range node.children {
|
||||||
childBranch := "├─ "
|
childBranch := util.TBranchString
|
||||||
if i == len(node.children)-1 {
|
if i == len(node.children)-1 {
|
||||||
childBranch = "└─ "
|
childBranch = util.LBranchString
|
||||||
}
|
}
|
||||||
renderNode(child, childPadding, childBranch, showURNs, showIDs, rows)
|
renderNode(child, childPadding, childBranch, showURNs, showIDs, rows)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,12 @@ import (
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
"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(u != nil, "u")
|
||||||
contract.Require(ctx != nil, "ctx")
|
contract.Require(ctx != nil, "ctx")
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,12 @@ import (
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
"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(u != nil, "u")
|
||||||
contract.Require(ctx != nil, "ctx")
|
contract.Require(ctx != nil, "ctx")
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,13 @@ func (m *resourceMap) mapRange(callback func(urn resource.URN, state *resource.S
|
||||||
|
|
||||||
type resourcePlans struct {
|
type resourcePlans struct {
|
||||||
m sync.RWMutex
|
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) {
|
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,
|
providers: reg,
|
||||||
goals: newGoals,
|
goals: newGoals,
|
||||||
news: newResources,
|
news: newResources,
|
||||||
newPlans: &resourcePlans{},
|
newPlans: newResourcePlan(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,11 @@ func (ex *deploymentExecutor) retirePendingDeletes(callerCtx context.Context, op
|
||||||
}
|
}
|
||||||
|
|
||||||
// import imports a list of resources into a stack.
|
// 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 {
|
if len(ex.deployment.imports) == 0 {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ func NewImportDeployment(ctx *plugin.Context, target *Target, projectName tokens
|
||||||
source: NewErrorSource(projectName),
|
source: NewErrorSource(projectName),
|
||||||
preview: preview,
|
preview: preview,
|
||||||
providers: reg,
|
providers: reg,
|
||||||
|
newPlans: newResourcePlan(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,8 @@ func (rp *ResourcePlan) checkGoal(programGoal *resource.Goal) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the additionalSecretOutputs sets are identical.
|
// 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)
|
return fmt.Errorf("additionalSecretOutputs changed: %v", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,11 @@ import (
|
||||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
|
"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)
|
properties, err := SerializeProperties(plan.Goal.Properties, enc, showSecrets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return apitype.ResourcePlanV1{}, err
|
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
|
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)
|
properties, err := DeserializeProperties(plan.Goal.Properties, dec, enc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
return v.V == other.V
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m PropertyMap) ConstrainedTo(constraints PropertyMap) (*ObjectDiff, bool) {
|
func (props PropertyMap) ConstrainedTo(constraints PropertyMap) (*ObjectDiff, bool) {
|
||||||
diff := constraints.diff(m, true, nil)
|
diff := constraints.diff(props, true, nil)
|
||||||
return diff, diff == nil
|
return diff, diff == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue