Skip to content

Commit

Permalink
Update apps path translation
Browse files Browse the repository at this point in the history
  • Loading branch information
pietern committed Jan 13, 2025
1 parent 7a633ec commit 9ce30f3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bundle/config/mutator/translate_paths_apps.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package mutator

import (
"context"
"fmt"

"github.com/databricks/cli/libs/dyn"
)

func (t *translateContext) applyAppsTranslations(v dyn.Value) (dyn.Value, error) {
func (t *translateContext) applyAppsTranslations(ctx context.Context, v dyn.Value) (dyn.Value, error) {
// Convert the `source_code_path` field to a remote absolute path.
// We use this path for app deployment to point to the source code.
pattern := dyn.NewPattern(
Expand All @@ -16,13 +17,17 @@ func (t *translateContext) applyAppsTranslations(v dyn.Value) (dyn.Value, error)
dyn.Key("source_code_path"),
)

opts := translateOptions{
Mode: TranslateModeDirectory,
}

return dyn.MapByPattern(v, pattern, func(p dyn.Path, v dyn.Value) (dyn.Value, error) {
key := p[2].Key()
dir, err := v.Location().Directory()
if err != nil {
return dyn.InvalidValue, fmt.Errorf("unable to determine directory for app %s: %w", key, err)
}

return t.rewriteRelativeTo(p, v, t.translateDirectoryPath, dir, "")
return t.rewriteValue(ctx, p, v, dir, opts)
})
}

0 comments on commit 9ce30f3

Please sign in to comment.