Skip to content

Commit 5d8ef27

Browse files
committed
clean up guess
1 parent b6d6951 commit 5d8ef27

File tree

2 files changed

+0
-63
lines changed

2 files changed

+0
-63
lines changed

bundle/statemgmt/state_pull.go

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -202,41 +202,6 @@ func PullResourcesState(ctx context.Context, b *bundle.Bundle) context.Context {
202202
return ctx
203203
}
204204

205-
// Guess engine based on local state alone and set it on context User-Agent as engine/direct or engine/terraform
206-
// This guess might be overriden later when we pull remote state.
207-
func GuessEngine(ctx context.Context, b *bundle.Bundle) context.Context {
208-
states := readLocalStates(ctx, b)
209-
210-
if logdiag.HasError(ctx) {
211-
log.Warnf(ctx, "Error reading state")
212-
return ctx
213-
}
214-
215-
winner := states[1]
216-
var isDirect bool
217-
218-
if winner == nil {
219-
// no local or remote state; set b.DirectDeployment based on env vars
220-
var err error
221-
isDirect, err = getDirectDeploymentEnv(ctx)
222-
if err != nil {
223-
logdiag.LogError(ctx, err)
224-
return ctx
225-
}
226-
} else {
227-
isDirect = winner.isDirect
228-
}
229-
230-
engine := "direct"
231-
232-
if !isDirect {
233-
engine = "terraform"
234-
}
235-
236-
log.Warnf(ctx, "Setting engine=%v", engine)
237-
return useragent.InContext(ctx, "engine", engine)
238-
}
239-
240205
func readStates(ctx context.Context, b *bundle.Bundle) []*state {
241206
remotePathDirect, localPathDirect := b.StateFilenameDirect(ctx)
242207
remotePathTerraform, localPathTerraform := b.StateFilenameTerraform(ctx)
@@ -293,30 +258,6 @@ func sortStates(states []*state) {
293258
})
294259
}
295260

296-
func readLocalStates(ctx context.Context, b *bundle.Bundle) []*state {
297-
_, localPathDirect := b.StateFilenameDirect(ctx)
298-
_, localPathTerraform := b.StateFilenameTerraform(ctx)
299-
300-
var wg sync.WaitGroup
301-
var directLocalState, terraformLocalState *state
302-
303-
wg.Go(func() {
304-
directLocalState = localRead(ctx, localPathDirect, true)
305-
})
306-
307-
wg.Go(func() {
308-
terraformLocalState = localRead(ctx, localPathTerraform, false)
309-
})
310-
311-
wg.Wait()
312-
313-
// find highest serial across all state files
314-
// sorting is stable, so initial setting represents preference:
315-
states := []*state{terraformLocalState, directLocalState}
316-
sortStates(states)
317-
return states
318-
}
319-
320261
func getDirectDeploymentEnv(ctx context.Context) (bool, error) {
321262
engine := env.Get(ctx, "DATABRICKS_BUNDLE_ENGINE")
322263

cmd/root/bundle.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/databricks/cli/bundle"
77
"github.com/databricks/cli/bundle/env"
88
"github.com/databricks/cli/bundle/phases"
9-
"github.com/databricks/cli/bundle/statemgmt"
109
"github.com/databricks/cli/libs/cmdctx"
1110
envlib "github.com/databricks/cli/libs/env"
1211
"github.com/databricks/cli/libs/logdiag"
@@ -119,9 +118,6 @@ func MustConfigureBundle(cmd *cobra.Command) *bundle.Bundle {
119118
configureBundle(cmd, b)
120119
}
121120

122-
ctx := statemgmt.GuessEngine(cmd.Context(), b)
123-
cmd.SetContext(ctx)
124-
125121
return b
126122
}
127123

0 commit comments

Comments
 (0)