Skip to content

Commit ac439f8

Browse files
authored
Fix for regression deploying resources with PyPi and Maven library types (#2341)
## Changes The CheckForSameNameLibraries mutator incorrectly assumed all resource libraries define libraries as paths of the `string` type, but some libraries, such as PyPi and Maven, define them as objects. This PR addresses this issue. It was introduced in #2297. ## Tests Added regression test.
1 parent 1dadc79 commit ac439f8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

acceptance/bundle/artifacts/same_name_libraries/databricks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ resources:
3434
package_name: my_default_python
3535
libraries:
3636
- whl: ./whl1/dist/*.whl
37+
- pypi:
38+
package: test_package
3739
- task_key: task2
3840
new_cluster: ${var.cluster}
3941
python_wheel_task:

acceptance/bundle/artifacts/same_name_libraries/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Error: Duplicate local library name my_default_python-0.0.1-py3-none-any.whl
66
at resources.jobs.test.tasks[0].libraries[0].whl
77
resources.jobs.test.tasks[1].libraries[0].whl
88
in databricks.yml:36:15
9-
databricks.yml:43:15
9+
databricks.yml:45:15
1010

1111
Local library names must be unique
1212

bundle/libraries/same_name_libraries.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ func (c checkForSameNameLibraries) Apply(ctx context.Context, b *bundle.Bundle)
3131
var err error
3232
for _, pattern := range patterns {
3333
v, err = dyn.MapByPattern(v, pattern, func(p dyn.Path, lv dyn.Value) (dyn.Value, error) {
34-
libPath := lv.MustString()
34+
libFullPath, ok := lv.AsString()
35+
// If the value is not a string, skip the check because it's not whl or jar type which defines the library
36+
// as a string versus PyPi or Maven which defines the library as a map.
37+
if !ok {
38+
return v, nil
39+
}
40+
3541
// If not local library, skip the check
36-
if !IsLibraryLocal(libPath) {
42+
if !IsLibraryLocal(libFullPath) {
3743
return lv, nil
3844
}
3945

40-
libFullPath := lv.MustString()
4146
lib := filepath.Base(libFullPath)
4247
// If the same basename was seen already but full path is different
4348
// then it's a duplicate. Add the location to the location list.

0 commit comments

Comments
 (0)