Skip to content

Commit 881c540

Browse files
authored
direct: Pass changed fields into update mask for apps instead of wildcard (#4963)
## Changes Pass changed fields into update mask for apps instead of wildcard ## Why Apps Update API does not support "*" for update mask yet. ## Tests Existing (Cloud) tests pass ``` DATABRICKS_BUNDLE_ENGINE=direct go test ./acceptance -v -run TestAccept/bundle/run/app-with-job === RUN TestAccept ... --- PASS: TestAccept (32.48s) --- SKIP: TestAccept/bundle/run_as (0.00s) --- PASS: TestAccept/bundle/run/app-with-job (0.00s) --- PASS: TestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=direct (294.22s) --- PASS: TestAccept/bundle/run/app-with-job/DATABRICKS_BUNDLE_ENGINE=terraform (299.11s) ```
1 parent ef63c88 commit 881c540

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
### Bundles
1313
* Added support for lifecycle.started option for apps ([#4672](https://github.com/databricks/cli/pull/4672))
1414
* engine/direct: Fix permissions for resources.models ([#4941](https://github.com/databricks/cli/pull/4941))
15+
* direct: Pass changed fields into update mask for apps instead of wildcard ([#4963](https://github.com/databricks/cli/pull/4963))
1516

1617
### Dependency updates
1718

acceptance/bundle/apps/compute_size/out.update.direct.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Deployment complete!
77

88
>>> [CLI] apps get app-[UNIQUE_NAME]
99
{
10-
"compute_size": "LARGE"
10+
"compute_size": "MEDIUM"
1111
}

acceptance/bundle/resources/apps/update/out.requests.direct.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"description": "MY_APP_DESCRIPTION",
1616
"name": "myappname"
1717
},
18-
"update_mask": "*"
18+
"update_mask": "description"
1919
},
2020
"method": "POST",
2121
"path": "/api/2.0/apps/myappname/update"

bundle/direct/dresources/app.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"slices"
8+
"strings"
79
"time"
810

911
"github.com/databricks/cli/bundle/appdeploy"
@@ -162,13 +164,19 @@ func (r *ResourceApp) DoCreate(ctx context.Context, config *AppState) (string, *
162164
}
163165

164166
func (r *ResourceApp) DoUpdate(ctx context.Context, id string, config *AppState, entry *PlanEntry) (*AppRemote, error) {
165-
// Use "*" to update all App API fields. Deploy-only fields (source_code_path, config,
167+
// Deploy-only fields (source_code_path, config,
166168
// git_source, lifecycle) are not part of apps.App and thus excluded from the request body.
167169
if hasAppChanges(entry) {
170+
fieldPaths := collectUpdatePathsWithPrefix(entry.Changes, "")
171+
slices.Sort(fieldPaths)
172+
for i, fieldPath := range fieldPaths {
173+
fieldPaths[i] = truncateAtIndex(fieldPath)
174+
}
175+
updateMask := strings.Join(fieldPaths, ",")
168176
request := apps.AsyncUpdateAppRequest{
169177
App: &config.App,
170178
AppName: id,
171-
UpdateMask: "*",
179+
UpdateMask: updateMask,
172180
}
173181
updateWaiter, err := r.client.Apps.CreateUpdate(ctx, request)
174182
if err != nil {

0 commit comments

Comments
 (0)