mirror of https://github.com/databricks/cli.git
always set description field
This commit is contained in:
parent
4b4cc42e5d
commit
7693f0add0
|
@ -12,6 +12,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func convertAppResource(ctx context.Context, vin dyn.Value) (dyn.Value, error) {
|
func convertAppResource(ctx context.Context, vin dyn.Value) (dyn.Value, error) {
|
||||||
|
// Check if the description is not set and if it's not, set it to an empty string.
|
||||||
|
if _, err := dyn.Get(vin, "description"); err != nil {
|
||||||
|
vin, err = dyn.Set(vin, "description", dyn.V(""))
|
||||||
|
if err != nil {
|
||||||
|
return vin, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Normalize the output value to the target schema.
|
// Normalize the output value to the target schema.
|
||||||
vout, diags := convert.Normalize(apps.App{}, vin)
|
vout, diags := convert.Normalize(apps.App{}, vin)
|
||||||
for _, diag := range diags {
|
for _, diag := range diags {
|
||||||
|
|
|
@ -96,3 +96,61 @@ func TestConvertApp(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, out.Permissions["app_my_app"])
|
}, out.Permissions["app_my_app"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConvertAppWithNoDescription(t *testing.T) {
|
||||||
|
src := resources.App{
|
||||||
|
SourceCodePath: "./app",
|
||||||
|
Config: map[string]any{
|
||||||
|
"command": []string{"python", "app.py"},
|
||||||
|
},
|
||||||
|
App: &apps.App{
|
||||||
|
Name: "app_id",
|
||||||
|
Resources: []apps.AppResource{
|
||||||
|
{
|
||||||
|
Name: "job1",
|
||||||
|
Job: &apps.AppResourceJob{
|
||||||
|
Id: "1234",
|
||||||
|
Permission: "CAN_MANAGE_RUN",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "sql1",
|
||||||
|
SqlWarehouse: &apps.AppResourceSqlWarehouse{
|
||||||
|
Id: "5678",
|
||||||
|
Permission: "CAN_USE",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
vin, err := convert.FromTyped(src, dyn.NilValue)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
out := schema.NewResources()
|
||||||
|
err = appConverter{}.Convert(ctx, "my_app", vin, out)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
app := out.App["my_app"]
|
||||||
|
assert.Equal(t, map[string]any{
|
||||||
|
"name": "app_id",
|
||||||
|
"description": "", // Due to Apps API always returning a description field, we set it in the output as well to avoid permanent TF drift
|
||||||
|
"resources": []any{
|
||||||
|
map[string]any{
|
||||||
|
"name": "job1",
|
||||||
|
"job": map[string]any{
|
||||||
|
"id": "1234",
|
||||||
|
"permission": "CAN_MANAGE_RUN",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
map[string]any{
|
||||||
|
"name": "sql1",
|
||||||
|
"sql_warehouse": map[string]any{
|
||||||
|
"id": "5678",
|
||||||
|
"permission": "CAN_USE",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, app)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue