@@ -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-
240205func 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-
320261func getDirectDeploymentEnv (ctx context.Context ) (bool , error ) {
321262 engine := env .Get (ctx , "DATABRICKS_BUNDLE_ENGINE" )
322263
0 commit comments