Skip to content

Commit 79dde05

Browse files
authored
Merge pull request #271 from seans3/destroy-preview-init
Moves destroyer Initialize() to immediately before Run()
2 parents b2b8c9d + a22d0d3 commit 79dde05

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

cmd/destroy/cmddestroy.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ type DestroyRunner struct {
5555
}
5656

5757
func (r *DestroyRunner) RunE(cmd *cobra.Command, args []string) error {
58-
err := r.Destroyer.Initialize()
59-
if err != nil {
60-
return err
61-
}
62-
6358
// Retrieve the inventory object.
6459
reader, err := r.provider.ManifestReader(cmd.InOrStdin(), args)
6560
if err != nil {
@@ -76,6 +71,10 @@ func (r *DestroyRunner) RunE(cmd *cobra.Command, args []string) error {
7671

7772
// Run the destroyer. It will return a channel where we can receive updates
7873
// to keep track of progress and any issues.
74+
err = r.Destroyer.Initialize()
75+
if err != nil {
76+
return err
77+
}
7978
ch := r.Destroyer.Run(inv)
8079

8180
// The printer will print updates from the channel. It will block

cmd/preview/cmdpreview.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
8282
return err
8383
}
8484
var ch <-chan event.Event
85-
err = r.Destroyer.Initialize()
86-
if err != nil {
87-
return err
88-
}
8985

9086
drs := common.DryRunClient
9187
if r.serverSideOptions.ServerSideApply {
@@ -134,6 +130,10 @@ func (r *PreviewRunner) RunE(cmd *cobra.Command, args []string) error {
134130
if err != nil {
135131
return err
136132
}
133+
err = r.Destroyer.Initialize()
134+
if err != nil {
135+
return err
136+
}
137137
ch = r.Destroyer.Run(inv)
138138
}
139139

0 commit comments

Comments
 (0)