Skip to content

Commit 54e0bab

Browse files
committed
push
1 parent 1a39e26 commit 54e0bab

File tree

6 files changed

+14
-50
lines changed

6 files changed

+14
-50
lines changed

acceptance/bundle/deployment/migrate/basic/databricks.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ resources:
99
- task_key: "main"
1010
notebook_task:
1111
notebook_path: "./notebook.py"
12-
#permissions:
13-
# - level: CAN_VIEW
14-
# user_name: [email protected]
12+
#permissions:
13+
# - level: CAN_VIEW
14+
# user_name: [email protected]
1515

1616
pipelines:
1717
test_pipeline:
1818
name: "Test Migration Pipeline"
1919
libraries:
2020
- notebook:
2121
path: "./pipeline.py"
22-
#permissions:
23-
# - level: CAN_MANAGE
24-
# user_name: [email protected]
22+
#permissions:
23+
# - level: CAN_MANAGE
24+
# user_name: [email protected]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Databricks notebook source
2-
print("Hello from test migration job")
2+
print("Hello from test migration job")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# Databricks notebook source
2-
# This is a test pipeline notebook
2+
# This is a test pipeline notebook

acceptance/bundle/help/bundle-deployment-migrate/output.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ Usage:
2626
databricks bundle deployment migrate [flags]
2727

2828
Flags:
29-
--auto-approve Automatically approve the migration
30-
--force-lock Force acquisition of deployment lock.
31-
-h, --help help for migrate
29+
-h, --help help for migrate
3230

3331
Global Flags:
3432
--debug enable debug logging

acceptance/bundle/help/bundle-deployment/output.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Usage:
2121

2222
Available Commands:
2323
bind Bind bundle-defined resources to existing resources
24+
migrate Migrate from Terraform to Direct deployment
2425
unbind Unbind bundle-defined resources from its managed remote resource
2526

2627
Flags:

cmd/bundle/deployment/migrate.go

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package deployment
22

33
import (
4-
"context"
5-
"encoding/json"
64
"errors"
75
"fmt"
8-
"os"
96

10-
"github.com/databricks/cli/bundle"
117
"github.com/databricks/cli/bundle/deploy/terraform"
128
"github.com/databricks/cli/bundle/direct"
139
"github.com/databricks/cli/bundle/direct/dstate"
@@ -19,13 +15,6 @@ import (
1915
"github.com/spf13/cobra"
2016
)
2117

22-
// terraformState represents the minimal terraform state structure we need
23-
type terraformState struct {
24-
Version int `json:"version"`
25-
Serial int64 `json:"serial"`
26-
Lineage string `json:"lineage"`
27-
}
28-
2918
func newMigrateCommand() *cobra.Command {
3019
cmd := &cobra.Command{
3120
Use: "migrate",
@@ -177,37 +166,13 @@ proper state management as it may cause resource conflicts.`,
177166
Path: localDirectPath,
178167
Data: directDB,
179168
}
180-
deploymentState.Finalize()
169+
err = deploymentState.Finalize()
170+
if err != nil {
171+
return err
172+
}
181173
cmdio.LogString(ctx, fmt.Sprintf("Migrated %d resources to direct engine state file: %s", len(directDB.State), localDirectPath))
182174
return nil
183175
}
184176

185177
return cmd
186178
}
187-
188-
func readTerraformState(ctx context.Context, b *bundle.Bundle) (terraform.ExportedResourcesMap, *terraformState, error) {
189-
// Read terraform state file to get resources
190-
terraformResources, err := terraform.ParseResourcesState(ctx, b)
191-
if err != nil {
192-
return nil, nil, fmt.Errorf("failed to parse terraform state: %w", err)
193-
}
194-
195-
// Read raw terraform state file to get lineage and serial
196-
_, localTerraformPath := b.StateFilenameTerraform(ctx)
197-
stateData, err := os.ReadFile(localTerraformPath)
198-
if err != nil {
199-
return nil, nil, fmt.Errorf("failed to read terraform state file: %w", err)
200-
}
201-
202-
var tfState terraformState
203-
err = json.Unmarshal(stateData, &tfState)
204-
if err != nil {
205-
return nil, nil, fmt.Errorf("failed to parse terraform state file: %w", err)
206-
}
207-
208-
if tfState.Lineage == "" {
209-
return nil, nil, fmt.Errorf("terraform state file missing lineage")
210-
}
211-
212-
return terraformResources, &tfState, nil
213-
}

0 commit comments

Comments
 (0)