Skip to content

Commit 6b70cfd

Browse files
committed
removed app id
1 parent beb67fb commit 6b70cfd

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

bundle/config/resources/apps.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import (
1212
)
1313

1414
type App struct {
15-
// This represents the id which is the name of the app that can be used
16-
// as a reference in other resources. This value is returned by terraform.
17-
// This equals to app name and added for symmetry with other resources.
18-
ID string `json:"id,omitempty" bundle:"readonly"`
19-
2015
// SourceCodePath is a required field used by DABs to point to Databricks app source code
2116
// on local disk and to the corresponding workspace path during app deployment.
2217
SourceCodePath string `json:"source_code_path"`
@@ -56,10 +51,10 @@ func (a *App) TerraformResourceName() string {
5651
}
5752

5853
func (a *App) InitializeURL(baseURL url.URL) {
59-
if a.ID == "" {
54+
if a.Name == "" {
6055
return
6156
}
62-
baseURL.Path = fmt.Sprintf("apps/%s", a.ID)
57+
baseURL.Path = fmt.Sprintf("apps/%s", a.Name)
6358
a.URL = baseURL.String()
6459
}
6560

bundle/deploy/terraform/convert.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/databricks/cli/bundle/deploy/terraform/tfdyn"
1010
"github.com/databricks/cli/bundle/internal/tf/schema"
1111
"github.com/databricks/cli/libs/dyn"
12+
"github.com/databricks/databricks-sdk-go/service/apps"
1213
tfjson "github.com/hashicorp/terraform-json"
1314
)
1415

@@ -202,9 +203,9 @@ func TerraformToBundle(state *resourcesState, config *config.Root) error {
202203
}
203204
cur := config.Resources.Apps[resource.Name]
204205
if cur == nil {
205-
cur = &resources.App{ModifiedStatus: resources.ModifiedStatusDeleted}
206+
cur = &resources.App{ModifiedStatus: resources.ModifiedStatusDeleted, App: &apps.App{}}
206207
}
207-
cur.ID = instance.Attributes.ID
208+
cur.Name = instance.Attributes.Name
208209
config.Resources.Apps[resource.Name] = cur
209210
case "databricks_permissions":
210211
case "databricks_grants":
@@ -271,7 +272,7 @@ func TerraformToBundle(state *resourcesState, config *config.Root) error {
271272
}
272273
}
273274
for _, src := range config.Resources.Apps {
274-
if src.ModifiedStatus == "" && src.ID == "" {
275+
if src.ModifiedStatus == "" && src.Name == "" {
275276
src.ModifiedStatus = resources.ModifiedStatusCreated
276277
}
277278
}

bundle/deploy/terraform/convert_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ func TestTerraformToBundleEmptyLocalResources(t *testing.T) {
700700
Mode: "managed",
701701
Name: "test_app",
702702
Instances: []stateResourceInstance{
703-
{Attributes: stateInstanceAttributes{ID: "1"}},
703+
{Attributes: stateInstanceAttributes{Name: "app1"}},
704704
},
705705
},
706706
},
@@ -741,7 +741,7 @@ func TestTerraformToBundleEmptyLocalResources(t *testing.T) {
741741
assert.Equal(t, "1", config.Resources.Dashboards["test_dashboard"].ID)
742742
assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Dashboards["test_dashboard"].ModifiedStatus)
743743

744-
assert.Equal(t, "1", config.Resources.Apps["test_app"].ID)
744+
assert.Equal(t, "app1", config.Resources.Apps["test_app"].Name)
745745
assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Apps["test_app"].ModifiedStatus)
746746

747747
AssertFullResourceCoverage(t, &config)
@@ -830,7 +830,7 @@ func TestTerraformToBundleEmptyRemoteResources(t *testing.T) {
830830
Apps: map[string]*resources.App{
831831
"test_app": {
832832
App: &apps.App{
833-
Name: "test_app",
833+
Description: "test_app",
834834
},
835835
},
836836
},
@@ -875,7 +875,7 @@ func TestTerraformToBundleEmptyRemoteResources(t *testing.T) {
875875
assert.Equal(t, "", config.Resources.Dashboards["test_dashboard"].ID)
876876
assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Dashboards["test_dashboard"].ModifiedStatus)
877877

878-
assert.Equal(t, "", config.Resources.Apps["test_app"].ID)
878+
assert.Equal(t, "", config.Resources.Apps["test_app"].Name)
879879
assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Apps["test_app"].ModifiedStatus)
880880

881881
AssertFullResourceCoverage(t, &config)
@@ -1019,12 +1019,12 @@ func TestTerraformToBundleModifiedResources(t *testing.T) {
10191019
Apps: map[string]*resources.App{
10201020
"test_app": {
10211021
App: &apps.App{
1022-
Name: "test_app",
1022+
Description: "test_app",
10231023
},
10241024
},
10251025
"test_app_new": {
10261026
App: &apps.App{
1027-
Name: "test_app_new",
1027+
Description: "test_app_new",
10281028
},
10291029
},
10301030
},
@@ -1213,15 +1213,15 @@ func TestTerraformToBundleModifiedResources(t *testing.T) {
12131213
Mode: "managed",
12141214
Name: "test_app",
12151215
Instances: []stateResourceInstance{
1216-
{Attributes: stateInstanceAttributes{ID: "1"}},
1216+
{Attributes: stateInstanceAttributes{Name: "app1"}},
12171217
},
12181218
},
12191219
{
12201220
Type: "databricks_app",
12211221
Mode: "managed",
12221222
Name: "test_app_old",
12231223
Instances: []stateResourceInstance{
1224-
{Attributes: stateInstanceAttributes{ID: "2"}},
1224+
{Attributes: stateInstanceAttributes{Name: "app2"}},
12251225
},
12261226
},
12271227
},
@@ -1306,11 +1306,11 @@ func TestTerraformToBundleModifiedResources(t *testing.T) {
13061306
assert.Equal(t, "", config.Resources.Dashboards["test_dashboard_new"].ID)
13071307
assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Dashboards["test_dashboard_new"].ModifiedStatus)
13081308

1309-
assert.Equal(t, "1", config.Resources.Apps["test_app"].ID)
1309+
assert.Equal(t, "app1", config.Resources.Apps["test_app"].Name)
13101310
assert.Equal(t, "", config.Resources.Apps["test_app"].ModifiedStatus)
1311-
assert.Equal(t, "2", config.Resources.Apps["test_app_old"].ID)
1311+
assert.Equal(t, "app2", config.Resources.Apps["test_app_old"].Name)
13121312
assert.Equal(t, resources.ModifiedStatusDeleted, config.Resources.Apps["test_app_old"].ModifiedStatus)
1313-
assert.Equal(t, "", config.Resources.Apps["test_app_new"].ID)
1313+
assert.Equal(t, "", config.Resources.Apps["test_app_new"].Name)
13141314
assert.Equal(t, resources.ModifiedStatusCreated, config.Resources.Apps["test_app_new"].ModifiedStatus)
13151315

13161316
AssertFullResourceCoverage(t, &config)

bundle/deploy/terraform/util.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type stateResourceInstance struct {
3434

3535
type stateInstanceAttributes struct {
3636
ID string `json:"id"`
37+
Name string `json:"name,omitempty"`
3738
ETag string `json:"etag,omitempty"`
3839
}
3940

bundle/deploy/terraform/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestParseResourcesStateWithExistingStateFile(t *testing.T) {
9797
Type: "databricks_pipeline",
9898
Name: "test_pipeline",
9999
Instances: []stateResourceInstance{
100-
{Attributes: stateInstanceAttributes{ID: "123"}},
100+
{Attributes: stateInstanceAttributes{ID: "123", Name: "test_pipeline"}},
101101
},
102102
},
103103
},

0 commit comments

Comments
 (0)