Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ golang.org/x/crypto - https://github.com/golang/crypto
Copyright 2009 The Go Authors.
License - https://github.com/golang/crypto/blob/master/LICENSE

golang.org/x/exp - https://github.com/golang/exp
Copyright 2009 The Go Authors.
License - https://github.com/golang/exp/blob/master/LICENSE

golang.org/x/mod - https://github.com/golang/mod
Copyright 2009 The Go Authors.
License - https://github.com/golang/mod/blob/master/LICENSE
Expand Down
8 changes: 4 additions & 4 deletions bundle/config/mutator/python/python_mutator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package python
import (
"context"
"fmt"
"maps"
"os"
"os/exec"
"path/filepath"
"runtime"
"slices"
"testing"

"github.com/databricks/cli/libs/dyn/convert"

"github.com/databricks/cli/bundle/env"
"github.com/stretchr/testify/require"

"golang.org/x/exp/maps"

"github.com/databricks/cli/libs/dyn"

"github.com/databricks/cli/bundle"
Expand Down Expand Up @@ -103,7 +103,7 @@ workspace: { current_user: { userName: test }}`)

assert.NoError(t, diags.Error())

assert.ElementsMatch(t, []string{"job0", "job1"}, maps.Keys(b.Config.Resources.Jobs))
assert.ElementsMatch(t, []string{"job0", "job1"}, slices.Collect(maps.Keys(b.Config.Resources.Jobs)))

if job0, ok := b.Config.Resources.Jobs["job0"]; ok {
assert.Equal(t, "job_0", job0.Name)
Expand Down Expand Up @@ -212,7 +212,7 @@ resources:

assert.NoError(t, diag.Error())

assert.ElementsMatch(t, []string{"job0"}, maps.Keys(b.Config.Resources.Jobs))
assert.ElementsMatch(t, []string{"job0"}, slices.Collect(maps.Keys(b.Config.Resources.Jobs)))
assert.Equal(t, "job_0", b.Config.Resources.Jobs["job0"].Name)
assert.Equal(t, "my job", b.Config.Resources.Jobs["job0"].Description)

Expand Down
5 changes: 3 additions & 2 deletions bundle/config/mutator/select_default_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package mutator

import (
"context"
"maps"
"slices"
"strings"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
"golang.org/x/exp/maps"
)

type selectDefaultTarget struct{}
Expand All @@ -26,7 +27,7 @@ func (m *selectDefaultTarget) Apply(ctx context.Context, b *bundle.Bundle) diag.
}

// One target means there's only one default.
names := maps.Keys(b.Config.Targets)
names := slices.Collect(maps.Keys(b.Config.Targets))
if len(names) == 1 {
bundle.ApplyContext(ctx, b, SelectTarget(names[0]))
return nil
Expand Down
5 changes: 3 additions & 2 deletions bundle/config/mutator/select_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package mutator
import (
"context"
"fmt"
"maps"
"slices"
"strings"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/libs/diag"
"golang.org/x/exp/maps"
)

type selectTarget struct {
Expand All @@ -34,7 +35,7 @@ func (m *selectTarget) Apply(_ context.Context, b *bundle.Bundle) diag.Diagnosti
// Get specified target
target, ok := b.Config.Targets[m.name]
if !ok {
return diag.Errorf("%s: no such target. Available targets: %s", m.name, strings.Join(maps.Keys(b.Config.Targets), ", "))
return diag.Errorf("%s: no such target. Available targets: %s", m.name, strings.Join(slices.Collect(maps.Keys(b.Config.Targets)), ", "))
}

// Merge specified target into root configuration structure.
Expand Down
5 changes: 3 additions & 2 deletions bundle/deploy/terraform/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import (
"errors"
"fmt"
"io/fs"
"maps"
"os"
"os/exec"
"path/filepath"
"runtime"
"slices"
"strings"

"github.com/databricks/cli/bundle"
Expand All @@ -20,7 +22,6 @@ import (
"github.com/databricks/cli/libs/log"
"github.com/hashicorp/hc-install/product"
"github.com/hashicorp/terraform-exec/tfexec"
"golang.org/x/exp/maps"
)

func findExecPath(ctx context.Context, b *bundle.Bundle, tf *config.Terraform, installer Installer) (string, error) {
Expand Down Expand Up @@ -363,7 +364,7 @@ func Initialize(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
}

// Configure environment variables for auth for Terraform to use.
log.Debugf(ctx, "Environment variables for Terraform: %s", strings.Join(maps.Keys(environ), ", "))
log.Debugf(ctx, "Environment variables for Terraform: %s", strings.Join(slices.Collect(maps.Keys(environ)), ", "))
err = tfe.SetEnv(environ)
if err != nil {
return diag.FromErr(err)
Expand Down
7 changes: 4 additions & 3 deletions bundle/deploy/terraform/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package terraform
import (
"context"
"fmt"
"maps"
"os"
"path/filepath"
"runtime"
"slices"
"strings"
"testing"

Expand All @@ -18,7 +20,6 @@ import (
"github.com/hashicorp/hc-install/product"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/exp/maps"
)

func unsetEnv(t *testing.T, name string) {
Expand Down Expand Up @@ -208,7 +209,7 @@ func TestSetProxyEnvVars(t *testing.T) {
env = make(map[string]string, 0)
err = setProxyEnvVars(t.Context(), env, b)
require.NoError(t, err)
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, maps.Keys(env))
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, slices.Collect(maps.Keys(env)))

// Upper case set.
clearEnv()
Expand All @@ -218,7 +219,7 @@ func TestSetProxyEnvVars(t *testing.T) {
env = make(map[string]string, 0)
err = setProxyEnvVars(t.Context(), env, b)
require.NoError(t, err)
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, maps.Keys(env))
assert.ElementsMatch(t, []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}, slices.Collect(maps.Keys(env)))
}

func TestSetUserAgentExtra_Python(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions bundle/internal/tf/codegen/generator/util.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package generator

import (
"maps"
"slices"

"golang.org/x/exp/maps"
)

// sortKeys returns a sorted copy of the keys in the specified map.
func sortKeys[M ~map[K]V, K string, V any](m M) []K {
keys := maps.Keys(m)
keys := slices.Collect(maps.Keys(m))
slices.Sort(keys)
return keys
}
1 change: 0 additions & 1 deletion bundle/internal/tf/codegen/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/hashicorp/terraform-json v0.27.2
github.com/iancoleman/strcase v0.3.0
github.com/zclconf/go-cty v1.16.4
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6
)

require (
Expand Down
2 changes: 0 additions & 2 deletions bundle/internal/tf/codegen/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ github.com/zclconf/go-cty v1.16.4 h1:QGXaag7/7dCzb+odlGrgr+YmYZFaOCMW6DEpS+UD1eE
github.com/zclconf/go-cty v1.16.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 h1:zfMcR1Cs4KNuomFFgGefv5N0czO2XZpUbxGUy8i8ug0=
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
Expand Down
8 changes: 5 additions & 3 deletions bundle/run/job_args.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package run

import (
"maps"
"slices"

"github.com/databricks/cli/bundle/config/resources"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

type jobParameterArgs struct {
Expand Down Expand Up @@ -63,7 +65,7 @@ func (a jobTaskNotebookParamArgs) CompleteArgs(args []string, toComplete string)
maps.Copy(parameters, nt.BaseParameters)
}
}
return genericCompleteKeyValueArgs(args, toComplete, maps.Keys(parameters))
return genericCompleteKeyValueArgs(args, toComplete, slices.Collect(maps.Keys(parameters)))
}

type jobTaskJarParamArgs struct {
Expand Down Expand Up @@ -163,7 +165,7 @@ func (r *jobRunner) posArgsHandler() argsHandler {
}

// Cannot handle positional arguments if we have more than one task type.
keys := maps.Keys(seen)
keys := slices.Collect(maps.Keys(seen))
if len(keys) != 1 {
return nopArgsHandler{}
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/bundle/generate/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"errors"
"fmt"
"io"
"maps"
"os"
"path"
"path/filepath"
"slices"
"strings"
"time"

Expand All @@ -33,7 +35,6 @@ import (
"github.com/databricks/databricks-sdk-go/service/workspace"
"github.com/spf13/cobra"
"go.yaml.in/yaml/v3"
"golang.org/x/exp/maps"
)

type dashboard struct {
Expand Down Expand Up @@ -459,7 +460,7 @@ func dashboardResourceCompletion(cmd *cobra.Command, args []string, toComplete s
return nil, cobra.ShellCompDirectiveNoFileComp
}

return maps.Keys(resources.Completions(b, filterDashboards)), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(resources.Completions(b, filterDashboards))), cobra.ShellCompDirectiveNoFileComp
}

func NewGenerateDashboardCommand() *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions cmd/bundle/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"context"
"errors"
"fmt"
"maps"
"slices"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/resources"
Expand All @@ -14,7 +16,6 @@ import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"

"github.com/pkg/browser"
)
Expand Down Expand Up @@ -113,7 +114,7 @@ Use after deployment to quickly navigate to your resources in the workspace.`,

if len(args) == 0 {
completions := resources.Completions(b)
return maps.Keys(completions), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(completions)), cobra.ShellCompDirectiveNoFileComp
} else {
return nil, cobra.ShellCompDirectiveNoFileComp
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/bundle/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"os"
"slices"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/env"
Expand All @@ -22,7 +24,6 @@ import (
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

func promptRunArgument(ctx context.Context, b *bundle.Bundle) (string, error) {
Expand Down Expand Up @@ -239,7 +240,7 @@ Example usage:

if len(args) == 0 {
completions := resources.Completions(b, run.IsRunnable)
return maps.Keys(completions), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(completions)), cobra.ShellCompDirectiveNoFileComp
} else {
// If we know the resource to run, we can complete additional positional arguments.
runner, err := keyToRunner(b, args[0])
Expand Down
5 changes: 3 additions & 2 deletions cmd/pipelines/dry_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package pipelines
import (
"encoding/json"
"fmt"
"maps"
"slices"

"github.com/databricks/cli/bundle/resources"
"github.com/databricks/cli/bundle/run"
Expand All @@ -14,7 +16,6 @@ import (
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

func dryRunCommand() *cobra.Command {
Expand Down Expand Up @@ -115,7 +116,7 @@ If there is only one pipeline in the project, KEY is optional and the pipeline w

if len(args) == 0 {
completions := resources.Completions(b, run.IsRunnable)
return maps.Keys(completions), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(completions)), cobra.ShellCompDirectiveNoFileComp
} else {
// If we know the resource to run, we can complete additional positional arguments.
runner, err := keyToRunner(b, args[0])
Expand Down
5 changes: 3 additions & 2 deletions cmd/pipelines/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package pipelines
import (
"context"
"errors"
"maps"
"slices"

"github.com/databricks/cli/bundle"

Expand All @@ -15,7 +17,6 @@ import (
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"

"github.com/pkg/browser"
)
Expand Down Expand Up @@ -98,7 +99,7 @@ If there is only one pipeline in the project, KEY is optional and the pipeline w

if len(args) == 0 {
completions := resources.Completions(b)
return maps.Keys(completions), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(completions)), cobra.ShellCompDirectiveNoFileComp
} else {
return nil, cobra.ShellCompDirectiveNoFileComp
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/pipelines/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"slices"
"strings"
"time"

Expand All @@ -24,7 +26,6 @@ import (
"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/service/pipelines"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)

type PipelineUpdateData struct {
Expand Down Expand Up @@ -357,7 +358,7 @@ Refreshes all tables in the pipeline unless otherwise specified.`,

if len(args) == 0 {
completions := bundleresources.Completions(b, isPipeline)
return maps.Keys(completions), cobra.ShellCompDirectiveNoFileComp
return slices.Collect(maps.Keys(completions)), cobra.ShellCompDirectiveNoFileComp
} else {
// If we know the resource to run, we can complete additional positional arguments.
runner, err := keyToRunner(b, args[0])
Expand Down
Loading
Loading