Skip to content
Open
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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ wsfix:
links:
./tools/update_github_links.py

.PHONY: deadcode
deadcode:
./tools/check_deadcode.py

# Checks other than 'fmt' and 'lint'; these are fast, so can be run first
.PHONY: checks
checks: tidy ws links
checks: tidy ws links deadcode


.PHONY: install-pythons
Expand Down
23 changes: 0 additions & 23 deletions bundle/internal/schema/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,3 @@ func getAnnotations(path string) (annotation.File, error) {
err = yaml.Unmarshal(b, &data)
return data, err
}

func DisabledTestNoDuplicatedAnnotations(t *testing.T) {
// Check for duplicated annotations in annotation files
files := []string{
"annotations_openapi_overrides.yml",
"annotations.yml",
}

annotations := map[string]string{}
for _, file := range files {
annotationsFile, err := getAnnotations(file)
assert.NoError(t, err)
for typ, props := range annotationsFile {
for prop := range props {
key := typ + "_" + prop
if prevFile, ok := annotations[key]; ok {
t.Errorf("Annotation `%s` is duplicated in %s and %s", key, prevFile, file)
}
annotations[key] = file
}
}
}
}
7 changes: 0 additions & 7 deletions bundle/libraries/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ func Upload(libs map[string][]LocationToUpdate) bundle.Mutator {
}
}

func UploadWithClient(libs map[string][]LocationToUpdate, client filer.Filer) bundle.Mutator {
return &upload{
libs: libs,
client: client,
}
}

type upload struct {
client filer.Filer
libs map[string][]LocationToUpdate
Expand Down
86 changes: 0 additions & 86 deletions cmd/bundle/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import (
"context"

"github.com/databricks/cli/bundle"
bundleenv "github.com/databricks/cli/bundle/env"
"github.com/databricks/cli/bundle/phases"
"github.com/databricks/cli/libs/diag"
"github.com/databricks/cli/libs/env"
"github.com/databricks/cli/libs/logdiag"
"github.com/spf13/cobra"
)
Expand All @@ -20,85 +16,3 @@ func configureVariables(cmd *cobra.Command, b *bundle.Bundle, variables []string
}
})
}

// getTargetFromCmd returns the target name from command flags or environment.
func getTargetFromCmd(cmd *cobra.Command) string {
// Check command line flag first
if flag := cmd.Flag("target"); flag != nil {
if value := flag.Value.String(); value != "" {
return value
}
}

// Check deprecated environment flag
if flag := cmd.Flag("environment"); flag != nil {
if value := flag.Value.String(); value != "" {
return value
}
}

// Fall back to environment variable
target, _ := bundleenv.Target(cmd.Context())
return target
}

// ReloadBundle reloads the bundle configuration without modifying the command context.
// This is useful when you need to refresh the bundle configuration after changes
// without side effects like setting values on the context.
func ReloadBundle(cmd *cobra.Command) *bundle.Bundle {
ctx := cmd.Context()

// Load the bundle configuration fresh from the filesystem
b := bundle.MustLoad(ctx)
if b == nil || logdiag.HasError(ctx) {
return b
}

// Load the target configuration
if target := getTargetFromCmd(cmd); target == "" {
phases.LoadDefaultTarget(ctx, b)
} else {
phases.LoadNamedTarget(ctx, b, target)
}

if logdiag.HasError(ctx) {
return b
}

// Configure the workspace profile if provided
configureProfile(cmd, b)

// Configure variables if provided
variables, err := cmd.Flags().GetStringSlice("var")
if err != nil {
logdiag.LogDiag(ctx, diag.FromErr(err)[0])
return b
}
configureVariables(cmd, b, variables)
return b
}

// configureProfile applies the profile flag to the bundle.
func configureProfile(cmd *cobra.Command, b *bundle.Bundle) {
profile := getProfileFromCmd(cmd)
if profile == "" {
return
}

bundle.ApplyFuncContext(cmd.Context(), b, func(ctx context.Context, b *bundle.Bundle) {
b.Config.Workspace.Profile = profile
})
}

// getProfileFromCmd returns the profile from command flags or environment.
func getProfileFromCmd(cmd *cobra.Command) string {
// Check command line flag first
if flag := cmd.Flag("profile"); flag != nil {
if value := flag.Value.String(); value != "" {
return value
}
}

// Fall back to environment variable
return env.Get(cmd.Context(), "DATABRICKS_CONFIG_PROFILE")
}
21 changes: 0 additions & 21 deletions experimental/aitools/lib/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ type InstallOptions struct {
Scope string // ScopeGlobal or ScopeProject (default: global)
}

// FetchManifest fetches the skills manifest from the skills repo.
// This is a convenience wrapper that uses the default GitHubManifestSource.
func FetchManifest(ctx context.Context) (*Manifest, error) {
src := &GitHubManifestSource{}
ref := GetSkillsRef(ctx)
return src.FetchManifest(ctx, ref)
}

func fetchSkillFile(ctx context.Context, ref, skillName, filePath string) ([]byte, error) {
url := fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/%s/%s/%s/%s",
skillsRepoOwner, skillsRepoName, ref, skillsRepoPath, skillName, filePath)
Expand Down Expand Up @@ -303,19 +295,6 @@ func InstallAllSkills(ctx context.Context) error {
return InstallSkillsForAgents(ctx, src, installed, InstallOptions{})
}

// InstallSkill installs a single skill by name for all detected agents.
func InstallSkill(ctx context.Context, skillName string) error {
installed := agents.DetectInstalled(ctx)
if len(installed) == 0 {
printNoAgentsDetected(ctx)
return nil
}

PrintInstallingFor(ctx, installed)
src := &GitHubManifestSource{}
return InstallSkillsForAgents(ctx, src, installed, InstallOptions{SpecificSkills: []string{skillName}})
}

// PrintInstallingFor prints the "Installing..." header with agent names.
func PrintInstallingFor(ctx context.Context, targetAgents []*agents.Agent) {
names := make([]string, len(targetAgents))
Expand Down
14 changes: 0 additions & 14 deletions experimental/ssh/internal/keys/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,3 @@ func putSecret(ctx context.Context, client *databricks.WorkspaceClient, scope, k
}
return nil
}

// PutSecretInScope creates the secret scope if needed and stores the secret.
// sessionID is the unique identifier for the session (cluster ID for dedicated clusters, connection name for serverless).
func PutSecretInScope(ctx context.Context, client *databricks.WorkspaceClient, sessionID, key, value string) (string, error) {
scopeName, err := CreateKeysSecretScope(ctx, client, sessionID)
if err != nil {
return "", err
}
err = putSecret(ctx, client, scopeName, key, value)
if err != nil {
return "", err
}
return scopeName, nil
}
24 changes: 0 additions & 24 deletions internal/testcli/golden.go

This file was deleted.

4 changes: 0 additions & 4 deletions internal/testutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,3 @@ func RandomName(prefix ...string) string {
out += strings.ReplaceAll(uuid.New().String(), "-", "")
return out
}

func ReplaceWindowsLineEndings(s string) string {
return strings.ReplaceAll(s, "\r\n", "\n")
}
22 changes: 0 additions & 22 deletions libs/apps/prompt/listers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,28 +88,6 @@ func ListSecretKeys(ctx context.Context, scope string) ([]ListItem, error) {
return out, nil
}

// ListSQLWarehousesItems returns SQL warehouses as ListItems (reuses same API as ListSQLWarehouses).
func ListSQLWarehousesItems(ctx context.Context) ([]ListItem, error) {
w, err := workspaceClient(ctx)
if err != nil {
return nil, err
}
iter := w.Warehouses.List(ctx, sql.ListWarehousesRequest{})
whs, err := listing.ToSlice(ctx, iter)
if err != nil {
return nil, err
}
out := make([]ListItem, 0, min(len(whs), maxListResults))
for _, wh := range whs {
label := wh.Name
if wh.State != "" {
label = fmt.Sprintf("%s (%s)", wh.Name, wh.State)
}
out = append(out, ListItem{ID: wh.Id, Label: label})
}
return capResults(out), nil
}

// ListSchemas returns UC schemas within a catalog as selectable items.
func ListSchemas(ctx context.Context, catalogName string) ([]ListItem, error) {
w, err := workspaceClient(ctx)
Expand Down
14 changes: 0 additions & 14 deletions libs/apps/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,6 @@ func promptForPagedResource(ctx context.Context, r manifest.Resource, required b
return singleValueResult(r, value), nil
}

// PromptForWarehouse shows a picker to select a SQL warehouse.
func PromptForWarehouse(ctx context.Context) (string, error) {
var items []ListItem
err := RunWithSpinnerCtx(ctx, "Fetching SQL warehouses...", func() error {
var fetchErr error
items, fetchErr = ListSQLWarehousesItems(ctx)
return fetchErr
})
if err != nil {
return "", fmt.Errorf("failed to fetch SQL warehouses: %w", err)
}
return PromptFromList(ctx, "Select SQL Warehouse", "no SQL warehouses found. Create one in your workspace first", items, true)
}

// resourceTitle returns a prompt title for a resource, including the plugin name
// for context when available (e.g. "Select SQL Warehouse for Analytics").
func resourceTitle(fallback string, r manifest.Resource) string {
Expand Down
2 changes: 0 additions & 2 deletions libs/calladapt/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ type testIface interface {
type partialType struct{}

func (*partialType) Foo() {}
func (*partialType) baz() {} //nolint:unused

type goodType struct{}

func (*goodType) Foo() {}
func (*goodType) Bar() {}
func (*goodType) baz() {} //nolint:unused

type badType struct{}

Expand Down
5 changes: 0 additions & 5 deletions libs/cmdio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ func NewIO(ctx context.Context, outputFormat flags.Output, in io.Reader, out, er
}
}

func IsInteractive(ctx context.Context) bool {
c := fromContext(ctx)
return c.capabilities.SupportsInteractive()
}

func IsPromptSupported(ctx context.Context) bool {
c := fromContext(ctx)
return c.capabilities.SupportsPrompt()
Expand Down
12 changes: 1 addition & 11 deletions libs/cmdio/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,21 +271,11 @@ func RenderIterator[T any](ctx context.Context, i listing.Iterator[T]) error {
func RenderWithTemplate(ctx context.Context, v any, headerTemplate, template string) error {
c := fromContext(ctx)
if _, ok := v.(listingInterface); ok {
panic("use RenderIteratorWithTemplate instead")
panic("listings must use RenderIterator, not RenderWithTemplate")
}
return renderWithTemplate(ctx, newRenderer(v), c.outputFormat, c.out, headerTemplate, template)
}

func RenderIteratorWithTemplate[T any](ctx context.Context, i listing.Iterator[T], headerTemplate, template string) error {
c := fromContext(ctx)
return renderWithTemplate(ctx, newIteratorRenderer(i), c.outputFormat, c.out, headerTemplate, template)
}

func RenderIteratorJson[T any](ctx context.Context, i listing.Iterator[T]) error {
c := fromContext(ctx)
return renderWithTemplate(ctx, newIteratorRenderer(i), c.outputFormat, c.out, c.headerTemplate, c.template)
}

var renderFuncMap = template.FuncMap{
// we render colored output if stdout is TTY, otherwise we render text.
// in the future we'll check if we can explicitly check for stderr being
Expand Down
4 changes: 0 additions & 4 deletions libs/dagrun/dagrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ func NewGraph() *Graph {
}
}

func (g *Graph) Size() int { return len(g.Nodes) }

func (g *Graph) AddNode(n string) {
if _, ok := g.Adj[n]; !ok {
g.Adj[n] = nil
g.Nodes = append(g.Nodes, n)
}
}

func (g *Graph) HasNode(n string) bool { _, ok := g.Adj[n]; return ok }

func (g *Graph) AddDirectedEdge(from, to, label string) {
g.AddNode(from)
g.AddNode(to)
Expand Down
4 changes: 0 additions & 4 deletions libs/databrickscfg/profile/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import "context"

var profiler int

func WithProfiler(ctx context.Context, p Profiler) context.Context {
return context.WithValue(ctx, &profiler, p)
}

func GetProfiler(ctx context.Context) Profiler {
p, ok := ctx.Value(&profiler).(Profiler)
if !ok {
Expand Down
Loading
Loading