Skip to content
Merged
Show file tree
Hide file tree
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 Jun 6, 2025
6750e38
addressed code comments prior to testing
alyssa-db Jun 10, 2025
359a77d
added acceptance tests
alyssa-db Jun 10, 2025
d12a848
modified acceptance test PATH to add databricks and helper tools
alyssa-db Jun 10, 2025
e3c41fc
Merge branch 'databricks:main' into install-dlt-feat
alyssa-db Jun 10, 2025
ca3d09b
made dlt path be based on executable
alyssa-db Jun 11, 2025
d168e96
added acceptance test python script, refactored install-dlt
alyssa-db Jun 12, 2025
c282769
draft acceptance test and acceptance test DLT setup
alyssa-db Jun 12, 2025
e771366
acceptance test logic
alyssa-db Jun 12, 2025
9fac6c7
Merge remote-tracking branch 'upstream/main' into install-dlt-feat
alyssa-db Jun 12, 2025
14b7d31
windows path
alyssa-db Jun 12, 2025
be032fa
trying environment variable changes'
alyssa-db Jun 13, 2025
6429b3a
test symlink
alyssa-db Jun 13, 2025
2bf67ef
Merge branch 'main' into install-dlt-feat
alyssa-db Jun 13, 2025
9bf008f
dlt init checker
alyssa-db Jun 13, 2025
8576254
erroring checks
alyssa-db Jun 13, 2025
523c76d
added line for python packages
alyssa-db Jun 13, 2025
ce1c01a
Merge branch 'main' into install-dlt-feat
alyssa-db Jun 17, 2025
cc6454b
Added json path output and refactoring
alyssa-db Jun 17, 2025
8e020dc
checking windows
alyssa-db Jun 17, 2025
12b1e64
not clean paths windows
alyssa-db Jun 18, 2025
2d8da98
error order
alyssa-db Jun 18, 2025
1da3ff0
removed json, added relative path to tests
alyssa-db Jun 18, 2025
be778d6
modified invoke statement
alyssa-db Jun 18, 2025
f9dc119
Merge branch 'main' into install-dlt-feat
alyssa-db Jun 19, 2025
fb62458
renamed dlt to pipelines
alyssa-db Jun 19, 2025
9156ad5
renamed to install-pipelines-cli
alyssa-db Jun 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions acceptance/pipelines/install-pipelines-cli/output.txt
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
25 changes: 25 additions & 0 deletions acceptance/pipelines/install-pipelines-cli/script
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
8 changes: 8 additions & 0 deletions acceptance/pipelines/install-pipelines-cli/test.toml
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 = '/'
2 changes: 2 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/databricks/cli/cmd/configure"
"github.com/databricks/cli/cmd/fs"
"github.com/databricks/cli/cmd/labs"
"github.com/databricks/cli/cmd/pipelines"
"github.com/databricks/cli/cmd/root"
"github.com/databricks/cli/cmd/selftest"
"github.com/databricks/cli/cmd/sync"
Expand Down Expand Up @@ -106,6 +107,7 @@ func New(ctx context.Context) *cobra.Command {
cli.AddCommand(sync.New())
cli.AddCommand(version.New())
cli.AddCommand(selftest.New())
cli.AddCommand(pipelines.InstallPipelinesCLI())

// Add workspace command groups, filtering out empty groups or groups with only hidden commands.
allGroups := workspace.Groups()
Expand Down
66 changes: 66 additions & 0 deletions cmd/pipelines/install_pipelines_cli.go
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
}
18 changes: 18 additions & 0 deletions cmd/pipelines/pipelines.go
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
}
18 changes: 17 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,30 @@ package main
import (
"context"
"os"
"path/filepath"
"strings"

"github.com/databricks/cli/cmd"
"github.com/databricks/cli/cmd/pipelines"
"github.com/databricks/cli/cmd/root"
"github.com/spf13/cobra"
)

// If invoked as 'pipelines' (or 'pipelines.exe' on Windows), returns pipelines-specific commands,
// otherwise returns the databricks CLI commands. This is used to allow the same
// binary to be used for both pipelines and databricks CLI commands.
func getCommand(ctx context.Context) *cobra.Command {
invokedAs := filepath.Base(os.Args[0])
Comment thread
alyssa-db marked this conversation as resolved.
if strings.HasPrefix(invokedAs, "pipelines") {
Comment thread
alyssa-db marked this conversation as resolved.
return pipelines.New()
}
return cmd.New(ctx)
}

func main() {
ctx := context.Background()
err := root.Execute(ctx, cmd.New(ctx))
command := getCommand(ctx)
err := root.Execute(ctx, command)
if err != nil {
os.Exit(1)
}
Expand Down
Loading