mirror of https://github.com/databricks/cli.git
Make `file_path` and `artifact_path` fields consistent with json tag (#987)
## Changes This PR: 1. Renames `FilesPath` -> `FilePath` and `ArtifactsPath` -> `ArtifactPath` in the bundle and metadata configuration to make them consistant with the json tags. 2. Fixes development / production mode error messages to point to `file_path` and `artifact_path` ## Tests Existing unit tests. This is a strightforward renaming of the fields.
This commit is contained in:
parent
2c908f8fea
commit
0c837e5772
|
@ -160,7 +160,7 @@ func uploadArtifactFile(ctx context.Context, file string, uploadPath string, cli
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUploadBasePath(b *bundle.Bundle) (string, error) {
|
func getUploadBasePath(b *bundle.Bundle) (string, error) {
|
||||||
artifactPath := b.Config.Workspace.ArtifactsPath
|
artifactPath := b.Config.Workspace.ArtifactPath
|
||||||
if artifactPath == "" {
|
if artifactPath == "" {
|
||||||
return "", fmt.Errorf("remote artifact path not configured")
|
return "", fmt.Errorf("remote artifact path not configured")
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,12 +25,12 @@ func (m *defineDefaultWorkspacePaths) Apply(ctx context.Context, b *bundle.Bundl
|
||||||
return fmt.Errorf("unable to define default workspace paths: workspace root not defined")
|
return fmt.Errorf("unable to define default workspace paths: workspace root not defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.Config.Workspace.FilesPath == "" {
|
if b.Config.Workspace.FilePath == "" {
|
||||||
b.Config.Workspace.FilesPath = path.Join(root, "files")
|
b.Config.Workspace.FilePath = path.Join(root, "files")
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.Config.Workspace.ArtifactsPath == "" {
|
if b.Config.Workspace.ArtifactPath == "" {
|
||||||
b.Config.Workspace.ArtifactsPath = path.Join(root, "artifacts")
|
b.Config.Workspace.ArtifactPath = path.Join(root, "artifacts")
|
||||||
}
|
}
|
||||||
|
|
||||||
if b.Config.Workspace.StatePath == "" {
|
if b.Config.Workspace.StatePath == "" {
|
||||||
|
|
|
@ -21,8 +21,8 @@ func TestDefineDefaultWorkspacePaths(t *testing.T) {
|
||||||
}
|
}
|
||||||
err := mutator.DefineDefaultWorkspacePaths().Apply(context.Background(), bundle)
|
err := mutator.DefineDefaultWorkspacePaths().Apply(context.Background(), bundle)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "/files", bundle.Config.Workspace.FilesPath)
|
assert.Equal(t, "/files", bundle.Config.Workspace.FilePath)
|
||||||
assert.Equal(t, "/artifacts", bundle.Config.Workspace.ArtifactsPath)
|
assert.Equal(t, "/artifacts", bundle.Config.Workspace.ArtifactPath)
|
||||||
assert.Equal(t, "/state", bundle.Config.Workspace.StatePath)
|
assert.Equal(t, "/state", bundle.Config.Workspace.StatePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,15 +31,15 @@ func TestDefineDefaultWorkspacePathsAlreadySet(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
RootPath: "/",
|
RootPath: "/",
|
||||||
FilesPath: "/foo/bar",
|
FilePath: "/foo/bar",
|
||||||
ArtifactsPath: "/foo/bar",
|
ArtifactPath: "/foo/bar",
|
||||||
StatePath: "/foo/bar",
|
StatePath: "/foo/bar",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := mutator.DefineDefaultWorkspacePaths().Apply(context.Background(), bundle)
|
err := mutator.DefineDefaultWorkspacePaths().Apply(context.Background(), bundle)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.FilesPath)
|
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.FilePath)
|
||||||
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.ArtifactsPath)
|
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.ArtifactPath)
|
||||||
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.StatePath)
|
assert.Equal(t, "/foo/bar", bundle.Config.Workspace.StatePath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,11 +120,11 @@ func findIncorrectPath(b *bundle.Bundle, mode config.Mode) string {
|
||||||
if strings.Contains(b.Config.Workspace.StatePath, username) != containsExpected {
|
if strings.Contains(b.Config.Workspace.StatePath, username) != containsExpected {
|
||||||
return "state_path"
|
return "state_path"
|
||||||
}
|
}
|
||||||
if strings.Contains(b.Config.Workspace.FilesPath, username) != containsExpected {
|
if strings.Contains(b.Config.Workspace.FilePath, username) != containsExpected {
|
||||||
return "files_path"
|
return "file_path"
|
||||||
}
|
}
|
||||||
if strings.Contains(b.Config.Workspace.ArtifactsPath, username) != containsExpected {
|
if strings.Contains(b.Config.Workspace.ArtifactPath, username) != containsExpected {
|
||||||
return "artifacts_path"
|
return "artifact_path"
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
StatePath: "/Users/lennart@company.com/.bundle/x/y/state",
|
StatePath: "/Users/lennart@company.com/.bundle/x/y/state",
|
||||||
ArtifactsPath: "/Users/lennart@company.com/.bundle/x/y/artifacts",
|
ArtifactPath: "/Users/lennart@company.com/.bundle/x/y/artifacts",
|
||||||
FilesPath: "/Users/lennart@company.com/.bundle/x/y/files",
|
FilePath: "/Users/lennart@company.com/.bundle/x/y/files",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -190,8 +190,8 @@ func TestProcessTargetModeProduction(t *testing.T) {
|
||||||
require.ErrorContains(t, err, "state_path")
|
require.ErrorContains(t, err, "state_path")
|
||||||
|
|
||||||
bundle.Config.Workspace.StatePath = "/Shared/.bundle/x/y/state"
|
bundle.Config.Workspace.StatePath = "/Shared/.bundle/x/y/state"
|
||||||
bundle.Config.Workspace.ArtifactsPath = "/Shared/.bundle/x/y/artifacts"
|
bundle.Config.Workspace.ArtifactPath = "/Shared/.bundle/x/y/artifacts"
|
||||||
bundle.Config.Workspace.FilesPath = "/Shared/.bundle/x/y/files"
|
bundle.Config.Workspace.FilePath = "/Shared/.bundle/x/y/files"
|
||||||
|
|
||||||
err = validateProductionMode(context.Background(), bundle, false)
|
err = validateProductionMode(context.Background(), bundle, false)
|
||||||
require.ErrorContains(t, err, "production")
|
require.ErrorContains(t, err, "production")
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (m *trampoline) generateNotebookWrapper(ctx context.Context, b *bundle.Bund
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
remotePath := path.Join(b.Config.Workspace.FilesPath, filepath.ToSlash(internalDirRel), notebookName)
|
remotePath := path.Join(b.Config.Workspace.FilePath, filepath.ToSlash(internalDirRel), notebookName)
|
||||||
|
|
||||||
task.Task.NotebookTask = &jobs.NotebookTask{
|
task.Task.NotebookTask = &jobs.NotebookTask{
|
||||||
NotebookPath: remotePath,
|
NotebookPath: remotePath,
|
||||||
|
|
|
@ -92,7 +92,7 @@ func (m *translatePaths) rewritePath(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefix remote path with its remote root path.
|
// Prefix remote path with its remote root path.
|
||||||
remotePath := path.Join(b.Config.Workspace.FilesPath, filepath.ToSlash(localRelPath))
|
remotePath := path.Join(b.Config.Workspace.FilePath, filepath.ToSlash(localRelPath))
|
||||||
|
|
||||||
// Convert local path into workspace path via specified function.
|
// Convert local path into workspace path via specified function.
|
||||||
interp, err := fn(*p, localPath, localRelPath, filepath.ToSlash(remotePath))
|
interp, err := fn(*p, localPath, localRelPath, filepath.ToSlash(remotePath))
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestTranslatePathsSkippedWithGitSource(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -111,7 +111,7 @@ func TestTranslatePaths(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -282,7 +282,7 @@ func TestTranslatePathsInSubdirectories(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -380,7 +380,7 @@ func TestTranslatePathsOutsideBundleRoot(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -539,7 +539,7 @@ func TestJobSparkPythonTaskWithNotebookSourceError(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -574,7 +574,7 @@ func TestJobNotebookTaskWithFileSourceError(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Jobs: map[string]*resources.Job{
|
Jobs: map[string]*resources.Job{
|
||||||
|
@ -609,7 +609,7 @@ func TestPipelineNotebookLibraryWithFileSourceError(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Pipelines: map[string]*resources.Pipeline{
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
|
@ -644,7 +644,7 @@ func TestPipelineFileLibraryWithNotebookSourceError(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Path: dir,
|
Path: dir,
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/bundle",
|
FilePath: "/bundle",
|
||||||
},
|
},
|
||||||
Resources: config.Resources{
|
Resources: config.Resources{
|
||||||
Pipelines: map[string]*resources.Pipeline{
|
Pipelines: map[string]*resources.Pipeline{
|
||||||
|
|
|
@ -52,11 +52,11 @@ type Workspace struct {
|
||||||
|
|
||||||
// Remote workspace path to synchronize local files to.
|
// Remote workspace path to synchronize local files to.
|
||||||
// This defaults to "${workspace.root}/files".
|
// This defaults to "${workspace.root}/files".
|
||||||
FilesPath string `json:"file_path,omitempty"`
|
FilePath string `json:"file_path,omitempty"`
|
||||||
|
|
||||||
// Remote workspace path for build artifacts.
|
// Remote workspace path for build artifacts.
|
||||||
// This defaults to "${workspace.root}/artifacts".
|
// This defaults to "${workspace.root}/artifacts".
|
||||||
ArtifactsPath string `json:"artifact_path,omitempty"`
|
ArtifactPath string `json:"artifact_path,omitempty"`
|
||||||
|
|
||||||
// Remote workspace path for deployment state.
|
// Remote workspace path for deployment state.
|
||||||
// This defaults to "${workspace.root}/state".
|
// This defaults to "${workspace.root}/state".
|
||||||
|
|
|
@ -21,7 +21,7 @@ func getSync(ctx context.Context, b *bundle.Bundle) (*sync.Sync, error) {
|
||||||
|
|
||||||
opts := sync.SyncOptions{
|
opts := sync.SyncOptions{
|
||||||
LocalPath: b.Config.Path,
|
LocalPath: b.Config.Path,
|
||||||
RemotePath: b.Config.Workspace.FilesPath,
|
RemotePath: b.Config.Workspace.FilePath,
|
||||||
Include: includes,
|
Include: includes,
|
||||||
Exclude: b.Config.Sync.Exclude,
|
Exclude: b.Config.Sync.Exclude,
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (m *upload) Apply(ctx context.Context, b *bundle.Bundle) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdio.LogString(ctx, fmt.Sprintf("Uploaded bundle files at %s!\n", b.Config.Workspace.FilesPath))
|
cmdio.LogString(ctx, fmt.Sprintf("Uploaded bundle files at %s!\n", b.Config.Workspace.FilePath))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,6 @@ func (m *compute) Apply(_ context.Context, b *bundle.Bundle) error {
|
||||||
b.Metadata.Config.Resources.Jobs = jobsMetadata
|
b.Metadata.Config.Resources.Jobs = jobsMetadata
|
||||||
|
|
||||||
// Set file upload destination of the bundle in metadata
|
// Set file upload destination of the bundle in metadata
|
||||||
b.Metadata.Config.Workspace.FilesPath = b.Config.Workspace.FilesPath
|
b.Metadata.Config.Workspace.FilePath = b.Config.Workspace.FilePath
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ func TestComputeMetadataMutator(t *testing.T) {
|
||||||
Config: config.Root{
|
Config: config.Root{
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
RootPath: "/Users/shreyas.goenka@databricks.com",
|
RootPath: "/Users/shreyas.goenka@databricks.com",
|
||||||
ArtifactsPath: "/Users/shreyas.goenka@databricks.com/artifacts",
|
ArtifactPath: "/Users/shreyas.goenka@databricks.com/artifacts",
|
||||||
FilesPath: "/Users/shreyas.goenka@databricks.com/files",
|
FilePath: "/Users/shreyas.goenka@databricks.com/files",
|
||||||
},
|
},
|
||||||
Bundle: config.Bundle{
|
Bundle: config.Bundle{
|
||||||
Name: "my-bundle",
|
Name: "my-bundle",
|
||||||
|
@ -68,7 +68,7 @@ func TestComputeMetadataMutator(t *testing.T) {
|
||||||
Version: metadata.Version,
|
Version: metadata.Version,
|
||||||
Config: metadata.Config{
|
Config: metadata.Config{
|
||||||
Workspace: metadata.Workspace{
|
Workspace: metadata.Workspace{
|
||||||
FilesPath: "/Users/shreyas.goenka@databricks.com/files",
|
FilePath: "/Users/shreyas.goenka@databricks.com/files",
|
||||||
},
|
},
|
||||||
Bundle: metadata.Bundle{
|
Bundle: metadata.Bundle{
|
||||||
Git: config.Git{
|
Git: config.Git{
|
||||||
|
|
|
@ -11,7 +11,7 @@ type Bundle struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Workspace struct {
|
type Workspace struct {
|
||||||
FilesPath string `json:"file_path"`
|
FilePath string `json:"file_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Job struct {
|
type Job struct {
|
||||||
|
|
|
@ -30,7 +30,7 @@ func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, b *bundle.Bundle)
|
||||||
|
|
||||||
opts := sync.SyncOptions{
|
opts := sync.SyncOptions{
|
||||||
LocalPath: b.Config.Path,
|
LocalPath: b.Config.Path,
|
||||||
RemotePath: b.Config.Workspace.FilesPath,
|
RemotePath: b.Config.Workspace.FilePath,
|
||||||
Include: includes,
|
Include: includes,
|
||||||
Exclude: b.Config.Sync.Exclude,
|
Exclude: b.Config.Sync.Exclude,
|
||||||
Full: f.full,
|
Full: f.full,
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (f *syncFlags) syncOptionsFromBundle(cmd *cobra.Command, args []string, b *
|
||||||
|
|
||||||
opts := sync.SyncOptions{
|
opts := sync.SyncOptions{
|
||||||
LocalPath: b.Config.Path,
|
LocalPath: b.Config.Path,
|
||||||
RemotePath: b.Config.Workspace.FilesPath,
|
RemotePath: b.Config.Workspace.FilePath,
|
||||||
Include: includes,
|
Include: includes,
|
||||||
Exclude: b.Config.Sync.Exclude,
|
Exclude: b.Config.Sync.Exclude,
|
||||||
Full: f.full,
|
Full: f.full,
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestSyncOptionsFromBundle(t *testing.T) {
|
||||||
},
|
},
|
||||||
|
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
FilesPath: "/Users/jane@doe.com/path",
|
FilePath: "/Users/jane@doe.com/path",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ func TestAccUploadArtifactFileToCorrectRemotePath(t *testing.T) {
|
||||||
Target: "whatever",
|
Target: "whatever",
|
||||||
},
|
},
|
||||||
Workspace: config.Workspace{
|
Workspace: config.Workspace{
|
||||||
ArtifactsPath: wsDir,
|
ArtifactPath: wsDir,
|
||||||
},
|
},
|
||||||
Artifacts: config.Artifacts{
|
Artifacts: config.Artifacts{
|
||||||
"test": artifact,
|
"test": artifact,
|
||||||
|
|
|
@ -83,7 +83,7 @@ func TestAccJobsMetadataFile(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Workspace: metadata.Workspace{
|
Workspace: metadata.Workspace{
|
||||||
FilesPath: path.Join(root, "files"),
|
FilePath: path.Join(root, "files"),
|
||||||
},
|
},
|
||||||
Resources: metadata.Resources{
|
Resources: metadata.Resources{
|
||||||
Jobs: map[string]*metadata.Job{
|
Jobs: map[string]*metadata.Job{
|
||||||
|
|
Loading…
Reference in New Issue