-
Notifications
You must be signed in to change notification settings - Fork 161
New hidden install-pipelines-cli command that creates pipelines symlink to databricks
#3009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
60260b7
New hidden install-dlt command that creates symlink in same PATH as d…
alyssa-db 6750e38
addressed code comments prior to testing
alyssa-db 359a77d
added acceptance tests
alyssa-db d12a848
modified acceptance test PATH to add databricks and helper tools
alyssa-db e3c41fc
Merge branch 'databricks:main' into install-dlt-feat
alyssa-db ca3d09b
made dlt path be based on executable
alyssa-db d168e96
added acceptance test python script, refactored install-dlt
alyssa-db c282769
draft acceptance test and acceptance test DLT setup
alyssa-db e771366
acceptance test logic
alyssa-db 9fac6c7
Merge remote-tracking branch 'upstream/main' into install-dlt-feat
alyssa-db 14b7d31
windows path
alyssa-db be032fa
trying environment variable changes'
alyssa-db 6429b3a
test symlink
alyssa-db 2bf67ef
Merge branch 'main' into install-dlt-feat
alyssa-db 9bf008f
dlt init checker
alyssa-db 8576254
erroring checks
alyssa-db 523c76d
added line for python packages
alyssa-db ce1c01a
Merge branch 'main' into install-dlt-feat
alyssa-db cc6454b
Added json path output and refactoring
alyssa-db 8e020dc
checking windows
alyssa-db 12b1e64
not clean paths windows
alyssa-db 2d8da98
error order
alyssa-db 1da3ff0
removed json, added relative path to tests
alyssa-db be778d6
modified invoke statement
alyssa-db f9dc119
Merge branch 'main' into install-dlt-feat
alyssa-db fb62458
renamed dlt to pipelines
alyssa-db 9156ad5
renamed to install-pipelines-cli
alyssa-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,36 @@ | ||
|
|
||
| === install pipelines cli | ||
| >>> errcode [CLI] install-pipelines-cli -d ./subdir | ||
| pipelines successfully installed in directory "./subdir" | ||
|
|
||
| >>> errcode ./subdir/pipelines | ||
| Pipelines CLI (stub, to be filled in) | ||
|
|
||
| Usage: | ||
| pipelines [flags] | ||
|
|
||
| Flags: | ||
| -h, --help help for pipelines | ||
|
|
||
| === pipelines already installed | ||
| >>> errcode [CLI] install-pipelines-cli -d ./subdir | ||
| pipelines already installed in directory "./subdir" | ||
|
|
||
| === pipelines file exists, should not overwrite | ||
| >>> errcode [CLI] install-pipelines-cli -d ./subdir | ||
| Error: cannot install pipelines CLI: "subdir/pipelines" already exists | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === databricks executable called with alias | ||
| >>> errcode ./subdir/notdatabricks install-pipelines-cli -d ./subdir | ||
| pipelines successfully installed in directory "./subdir" | ||
|
|
||
| >>> errcode ./subdir/pipelines | ||
| Pipelines CLI (stub, to be filled in) | ||
|
|
||
| Usage: | ||
| pipelines [flags] | ||
|
|
||
| Flags: | ||
| -h, --help help for pipelines |
This file contains hidden or 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,25 @@ | ||
| tmpdir="./subdir" | ||
| pipelines="$tmpdir/pipelines" | ||
| mkdir -p $tmpdir | ||
|
|
||
| title "install pipelines cli" | ||
| trace errcode $CLI install-pipelines-cli -d $tmpdir | ||
| trace errcode $pipelines | ||
|
|
||
| title "pipelines already installed" | ||
| trace errcode $CLI install-pipelines-cli -d $tmpdir | ||
| rm -f $pipelines | ||
|
|
||
| title "pipelines file exists, should not overwrite" | ||
| touch $pipelines | ||
| trace errcode $CLI install-pipelines-cli -d $tmpdir | ||
| rm -f $pipelines | ||
|
|
||
| title "databricks executable called with alias" | ||
| cp $CLI $tmpdir/notdatabricks | ||
| trace errcode $tmpdir/notdatabricks install-pipelines-cli -d $tmpdir | ||
| trace errcode $pipelines | ||
|
|
||
| # Cleanup | ||
| rm -f $tmpdir/notdatabricks $pipelines | ||
| rm -rf $tmpdir |
This file contains hidden or 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,8 @@ | ||
| # Fix path with reverse slashes in the output for Windows. | ||
| [[Repls]] | ||
| Old = '\\\\' | ||
| New = '/' | ||
|
|
||
| [[Repls]] | ||
| Old = '\\' | ||
| New = '/' |
This file contains hidden or 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 hidden or 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,66 @@ | ||
| package pipelines | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/databricks/cli/libs/cmdio" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func installPipelinesSymlink(ctx context.Context, directory string) error { | ||
| path, err := os.Executable() | ||
| if err != nil { | ||
| return err | ||
| } | ||
| realPath, err := filepath.EvalSymlinks(path) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| dir := directory | ||
| if dir == "" { | ||
| dir = filepath.Dir(path) | ||
| } | ||
| pipelinesPath := filepath.Join(dir, "pipelines") | ||
|
|
||
| _, err = os.Lstat(pipelinesPath) | ||
| if err != nil { | ||
| if !errors.Is(err, os.ErrNotExist) { | ||
| return err | ||
| } | ||
| err = os.Symlink(realPath, pipelinesPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| cmdio.LogString(ctx, fmt.Sprintf("pipelines successfully installed in directory %q", dir)) | ||
| return nil | ||
| } | ||
|
|
||
| target, err := filepath.EvalSymlinks(pipelinesPath) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if realPath == target { | ||
| cmdio.LogString(ctx, fmt.Sprintf("pipelines already installed in directory %q", dir)) | ||
| return nil | ||
| } | ||
| return fmt.Errorf("cannot install pipelines CLI: %q already exists", pipelinesPath) | ||
| } | ||
|
|
||
| func InstallPipelinesCLI() *cobra.Command { | ||
| var directory string | ||
| cmd := &cobra.Command{ | ||
| Use: "install-pipelines-cli", | ||
| Short: "Install Pipelines CLI", | ||
| Hidden: true, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| return installPipelinesSymlink(cmd.Context(), directory) | ||
| }, | ||
| } | ||
| cmd.Flags().StringVarP(&directory, "directory", "d", "", "Directory in which to install pipelines CLI (defaults to databricks CLI's directory)") | ||
| return cmd | ||
| } |
This file contains hidden or 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,18 @@ | ||
| package pipelines | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func New() *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "pipelines", | ||
| Short: "Pipelines CLI", | ||
| Long: "Pipelines CLI (stub, to be filled in)", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| _ = cmd.Help() | ||
| }, | ||
| } | ||
|
|
||
| return cmd | ||
| } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.