-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'databricks/main' into template
- Loading branch information
Showing
26 changed files
with
272 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package artifacts | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path/filepath" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/databricks/cli/bundle" | ||
"github.com/databricks/cli/bundle/config" | ||
"github.com/databricks/databricks-sdk-go/service/compute" | ||
"github.com/databricks/databricks-sdk-go/service/workspace" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func touchEmptyFile(t *testing.T, path string) { | ||
err := os.MkdirAll(filepath.Dir(path), 0700) | ||
require.NoError(t, err) | ||
f, err := os.Create(path) | ||
require.NoError(t, err) | ||
f.Close() | ||
} | ||
|
||
type MockWorkspaceService struct { | ||
} | ||
|
||
// Delete implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) Delete(ctx context.Context, request workspace.Delete) error { | ||
panic("unimplemented") | ||
} | ||
|
||
// Export implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) Export(ctx context.Context, request workspace.ExportRequest) (*workspace.ExportResponse, error) { | ||
panic("unimplemented") | ||
} | ||
|
||
// GetStatus implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) GetStatus(ctx context.Context, request workspace.GetStatusRequest) (*workspace.ObjectInfo, error) { | ||
panic("unimplemented") | ||
} | ||
|
||
// Import implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) Import(ctx context.Context, request workspace.Import) error { | ||
return nil | ||
} | ||
|
||
// List implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) List(ctx context.Context, request workspace.ListWorkspaceRequest) (*workspace.ListResponse, error) { | ||
panic("unimplemented") | ||
} | ||
|
||
// Mkdirs implements workspace.WorkspaceService. | ||
func (MockWorkspaceService) Mkdirs(ctx context.Context, request workspace.Mkdirs) error { | ||
return nil | ||
} | ||
|
||
func TestUploadArtifactFileToCorrectRemotePath(t *testing.T) { | ||
dir := t.TempDir() | ||
whlPath := filepath.Join(dir, "dist", "test.whl") | ||
touchEmptyFile(t, whlPath) | ||
b := &bundle.Bundle{ | ||
Config: config.Root{ | ||
Path: dir, | ||
Bundle: config.Bundle{ | ||
Target: "whatever", | ||
}, | ||
Workspace: config.Workspace{ | ||
ArtifactsPath: "/Users/[email protected]/whatever", | ||
}, | ||
}, | ||
} | ||
|
||
b.WorkspaceClient().Workspace.WithImpl(MockWorkspaceService{}) | ||
artifact := &config.Artifact{ | ||
Files: []config.ArtifactFile{ | ||
{ | ||
Source: whlPath, | ||
Libraries: []*compute.Library{ | ||
{Whl: "dist\\test.whl"}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
err := uploadArtifact(context.Background(), artifact, b) | ||
require.NoError(t, err) | ||
require.Regexp(t, regexp.MustCompile("/Users/[email protected]/whatever/.internal/[a-z0-9]+/test.whl"), artifact.Files[0].RemotePath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package schema | ||
|
||
const ProviderVersion = "1.23.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package schema | ||
|
||
type Providers struct { | ||
Databricks *Config `json:"databricks,omitempty"` | ||
} | ||
|
||
func NewProviders() *Providers { | ||
return &Providers{ | ||
Databricks: &Config{}, | ||
} | ||
} | ||
|
||
type Root struct { | ||
Terraform map[string]any `json:"terraform"` | ||
|
||
Provider *Providers `json:"provider,omitempty"` | ||
Data *DataSources `json:"data,omitempty"` | ||
Resource *Resources `json:"resource,omitempty"` | ||
} | ||
|
||
func NewRoot() *Root { | ||
return &Root{ | ||
Terraform: map[string]interface{}{ | ||
"required_providers": map[string]interface{}{ | ||
"databricks": map[string]interface{}{ | ||
"source": "databricks/databricks", | ||
"version": "1.23.0", | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.