Compare commits

...

3 Commits

Author SHA1 Message Date
Shreyas Goenka b6ab3cf4ba
debug logs 2024-12-30 20:20:24 +05:30
Shreyas Goenka 1a5f35f120
fix more test 2024-12-30 19:51:39 +05:30
Shreyas Goenka 4da773984a
add debug log and fix tests 2024-12-30 19:50:47 +05:30
2 changed files with 5 additions and 2 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/dyn"
"github.com/databricks/cli/libs/dyn/dynvar"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/service/catalog"
)
@ -138,6 +139,7 @@ the artifact_path.`,
// The user needs to have either WRITE_VOLUME or ALL_PRIVILEGES to write to the volume.
canWrite := slices.Contains(allPrivileges, catalog.PrivilegeWriteVolume) || slices.Contains(allPrivileges, catalog.PrivilegeAllPrivileges)
if !canWrite {
log.Debugf(ctx, "Current privileges on Volume at artifact_path: %v", allPrivileges)
return wrapErrorMsg(fmt.Sprintf("user does not have WRITE_VOLUME grant on volume %s", volumeFullName))
}
@ -145,6 +147,7 @@ the artifact_path.`,
// We still add this explicit check out of caution incase the API behavior changes in the future.
canRead := slices.Contains(allPrivileges, catalog.PrivilegeReadVolume) || slices.Contains(allPrivileges, catalog.PrivilegeAllPrivileges)
if !canRead {
log.Debugf(ctx, "Current privileges on Volume at artifact_path: %v", allPrivileges)
return wrapErrorMsg(fmt.Sprintf("user does not have READ_VOLUME grant on volume %s", volumeFullName))
}

View File

@ -257,7 +257,7 @@ func TestUploadArtifactFileToVolumeThatDoesNotExist(t *testing.T) {
stdout, stderr, err := testcli.RequireErrorRun(t, ctx, "bundle", "deploy")
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf(`Error: volume /Volumes/main/%s/doesnotexist does not exist: Not Found
assert.Equal(t, fmt.Sprintf(`Error: volume main.%s.doesnotexist does not exist
at workspace.artifact_path
in databricks.yml:6:18
@ -293,7 +293,7 @@ func TestUploadArtifactToVolumeNotYetDeployed(t *testing.T) {
stdout, stderr, err := testcli.RequireErrorRun(t, ctx, "bundle", "deploy")
assert.Error(t, err)
assert.Equal(t, fmt.Sprintf(`Error: volume /Volumes/main/%s/my_volume does not exist: Not Found
assert.Equal(t, fmt.Sprintf(`Error: volume main.%s.my_volume does not exist
at workspace.artifact_path
resources.volumes.foo
in databricks.yml:6:18