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
24 changes: 16 additions & 8 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ linters:
- gocritic
- govet
- ineffassign
- intrange
- mirror
- perfsprint
- revive
- staticcheck
- testifylint
- unconvert
- unused
- exhaustruct
- exhaustruct_v5
- exhaustive
- copyloopvar
- forbidigo
Expand Down Expand Up @@ -101,6 +100,17 @@ linters:
- pattern: 'errors\.As\b'
msg: 'Use errors.AsType[T](err) for type-safe error unwrapping (Go 1.26+).'
analyze-types: true
recvcheck:
# recvcheck v0.3 switched its built-in exclusions from Marshal* to
# Unmarshal*. Value-receiver MarshalJSON paired with pointer-receiver
# UnmarshalJSON is the idiomatic pattern, so keep excluding both.
exclusions:
- "*.MarshalText"
- "*.MarshalJSON"
- "*.MarshalYAML"
- "*.MarshalXML"
- "*.MarshalBinary"
- "*.GobEncode"
copyloopvar:
check-alias: true
errcheck:
Expand All @@ -120,11 +130,8 @@ linters:
- "**/internal/testutil/**"
- "**/libs/testdiff/**"
- "**/libs/python/pythontest/**"
- name: context-keys-type
- name: error-return
- name: errorf
- name: range-val-in-closure
- name: waitgroup-by-value
- name: unconditional-recursion
- name: use-waitgroup-go
gocritic:
Expand Down Expand Up @@ -170,10 +177,10 @@ linters:
rules:
- path-except: bundle/direct/dresources|bundle/config/mutator/load_dbalert_files.go
linters:
- exhaustruct
- exhaustruct_v5
- path: bundle/direct/dresources/.*_test.go
linters:
- exhaustruct
- exhaustruct_v5
- text: "Use env\\.Get"
path: "_test\\.go$"
linters:
Expand All @@ -195,6 +202,7 @@ formatters:
replacement: any
gofumpt:
module-path: github.com/databricks/cli
extra-rules: true
extra:
group-params: true
exclusions:
generated: lax
1 change: 1 addition & 0 deletions .nextchanges/dependency-updates/go-1.27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Bump Go to 1.27.2. Release binaries now require macOS 13 Ventura or later. ([#7052](https://github.com/databricks/cli/pull/7052))
2 changes: 1 addition & 1 deletion acceptance/cmd/api/request-handling/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ OK: Accept header present
}

=== Malformed --json is rejected client-side with a positioned error
Error: error decoding JSON at (inline):1:9: invalid character '}' looking for beginning of object key string
Error: error decoding JSON at (inline):1:8: invalid character ',' looking for beginning of value
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (m *applySourceLinkedDeploymentPreset) Apply(ctx context.Context, b *bundle
isDatabricksWorkspace := dbr.RunsOnRuntime(ctx) && strings.HasPrefix(b.SyncRootPath, "/Workspace/")
target := b.Config.Bundle.Target

if config.IsExplicitlyEnabled((b.Config.Presets.SourceLinkedDeployment)) {
if config.IsExplicitlyEnabled(b.Config.Presets.SourceLinkedDeployment) {
if !isDatabricksWorkspace {
path := structpath.NewPath(nil, "targets", target, "presets", "source_linked_deployment")
diags = diags.Append(
Expand Down
24 changes: 10 additions & 14 deletions bundle/config/mutator/paths/job_libraries_paths_visitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ func TestVisitJobLibrariesPaths(t *testing.T) {
}

job0 := &resources.Job{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
task0,
task1,
task2,
task3,
task4,
task5,
task6,
},
Tasks: []jobs.Task{
task0,
task1,
task2,
task3,
task4,
task5,
task6,
},
}

Expand Down Expand Up @@ -91,10 +89,8 @@ func TestVisitJobLibrariesPaths_environments(t *testing.T) {
},
}
job0 := &resources.Job{
JobSettings: jobs.JobSettings{
Environments: []jobs.JobEnvironment{
environment0,
},
Environments: []jobs.JobEnvironment{
environment0,
},
}

Expand Down
56 changes: 24 additions & 32 deletions bundle/config/mutator/paths/job_paths_visitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ func TestVisitJobPaths(t *testing.T) {
}

job0 := &resources.Job{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
task0,
task1,
task2,
task3,
task4,
task5,
task6,
task7,
task8,
},
Tasks: []jobs.Task{
task0,
task1,
task2,
task3,
task4,
task5,
task6,
task7,
task8,
},
}

Expand Down Expand Up @@ -110,12 +108,10 @@ func TestVisitJobPaths_environments(t *testing.T) {
},
}
job0 := &resources.Job{
JobSettings: jobs.JobSettings{
Environments: []jobs.JobEnvironment{
environment0,
{Spec: &compute.Environment{ProjectEnvironment: "../pyproject.toml"}},
{Spec: &compute.Environment{ProjectEnvironment: "/Workspace/shared/pyproject.toml"}},
},
Environments: []jobs.JobEnvironment{
environment0,
{Spec: &compute.Environment{ProjectEnvironment: "../pyproject.toml"}},
{Spec: &compute.Environment{ProjectEnvironment: "/Workspace/shared/pyproject.toml"}},
},
}

Expand All @@ -138,15 +134,13 @@ func TestVisitJobPaths_environments(t *testing.T) {

func TestVisitJobPaths_environmentVariables(t *testing.T) {
job0 := &resources.Job{
JobSettings: jobs.JobSettings{
EnvironmentVariables: []jobs.JobEnvironmentVariables{
{
EnvironmentVariablesKey: "default",
Spec: &jobs.JobEnvironmentVariablesSpec{
Files: []string{
"./a.env",
"./b.env",
},
EnvironmentVariables: []jobs.JobEnvironmentVariables{
{
EnvironmentVariablesKey: "default",
Spec: &jobs.JobEnvironmentVariablesSpec{
Files: []string{
"./a.env",
"./b.env",
},
},
},
Expand Down Expand Up @@ -190,11 +184,9 @@ func TestVisitJobPaths_foreach(t *testing.T) {
},
}
job0 := &resources.Job{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{
task0,
task1,
},
Tasks: []jobs.Task{
task0,
task1,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
"job_run1": {RunNow: jobs.RunNow{JobId: 1234}},
},
Pipelines: map[string]*resources.Pipeline{
"pipeline1": {CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1", Continuous: true}},
"pipeline1": {CreatePipeline: pipelines.CreatePipeline{Name: "pipeline1", Continuous: true}}, //nolint:staticcheck // SA1019: pipeline continuous is deprecated in the SDK but remains a supported bundle config field
},
Experiments: map[string]*resources.MlflowExperiment{
"experiment1": {CreateExperiment: ml.CreateExperiment{Name: "/Users/lennart.kats@databricks.com/experiment1"}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func TestConfigureDashboardSerializedDashboard(t *testing.T) {
}

dash := &resources.Dashboard{
DashboardConfig: resources.DashboardConfig{DisplayName: "My Dashboard"},
FilePath: tt.filePath,
DisplayName: "My Dashboard",
FilePath: tt.filePath,
}
if tt.setSerialized {
dash.SerializedDashboard = tt.serializedDashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func TestConfigureGenieSpaceSerializedSpace(t *testing.T) {
}

gs := &resources.GenieSpace{
GenieSpaceConfig: resources.GenieSpaceConfig{Title: "My Genie Space"},
FilePath: tt.filePath,
Title: "My Genie Space",
FilePath: tt.filePath,
}
if tt.setSerialized {
gs.SerializedSpace = tt.serializedSpace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestValidateProductionPipelines(t *testing.T) {
Pipelines: map[string]*resources.Pipeline{
"pipeline": {
CreatePipeline: pipelines.CreatePipeline{
Development: true,
Development: true, //nolint:staticcheck // SA1019: pipeline development is deprecated in the SDK but remains a supported bundle config field
},
},
},
Expand Down
6 changes: 3 additions & 3 deletions bundle/config/mutator/validate_job_run_triggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ func TestValidateJobRunTriggers(t *testing.T) {
JobRuns: map[string]*resources.JobRun{
"my_run": {
Lifecycle: &resources.JobRunLifecycle{
Lifecycle: resources.Lifecycle{PreventDestroy: tt.preventDestroy},
Triggers: tt.triggers,
TriggersState: nil,
PreventDestroy: tt.preventDestroy,
Triggers: tt.triggers,
TriggersState: nil,
},
},
},
Expand Down
4 changes: 1 addition & 3 deletions bundle/config/resources/external_location_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ func TestExternalLocationResourceDescription(t *testing.T) {

func TestExternalLocationGetName(t *testing.T) {
el := &ExternalLocation{
CreateExternalLocation: catalog.CreateExternalLocation{
Name: "my_location",
},
Name: "my_location",
}

assert.Equal(t, "my_location", el.GetName())
Expand Down
9 changes: 5 additions & 4 deletions bundle/config/resources/postgres_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ func TestPostgresBranchConfigMarshalHonorsForceSendFields(t *testing.T) {
// produce the same bytes. A pointer-only marshaler would send them down two
// different code paths.
func TestPostgresBranchMarshalValueAndPointerAgree(t *testing.T) {
b := PostgresBranch{}
b.ID = "the-id"
b.BranchId = "b1"
b.Parent = "projects/p1"
b := PostgresBranch{
ID: "the-id",
BranchId: "b1",
Parent: "projects/p1",
}

byValue, err := json.Marshal(b)
require.NoError(t, err)
Expand Down
17 changes: 6 additions & 11 deletions bundle/config/resources/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,24 @@ import (

"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/experimental/mocks"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

func TestComputeVolumePath(t *testing.T) {
v := &Volume{
CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{
CatalogName: "main",
SchemaName: "myschema",
Name: "myvol",
},
CatalogName: "main",
SchemaName: "myschema",
Name: "myvol",
}
require.Equal(t, "/Volumes/main/myschema/myvol", v.ComputeVolumePath())
}

func TestComputeVolumePath_PureReferenceEmbedded(t *testing.T) {
v := &Volume{
CreateVolumeRequestContent: catalog.CreateVolumeRequestContent{
CatalogName: "main",
SchemaName: "${resources.schemas.my.name}",
Name: "myvol",
},
CatalogName: "main",
SchemaName: "${resources.schemas.my.name}",
Name: "myvol",
}
// A pure reference is embedded verbatim so it can be resolved later (plan/deploy).
require.Equal(t, "/Volumes/main/${resources.schemas.my.name}/myvol", v.ComputeVolumePath())
Expand Down
6 changes: 3 additions & 3 deletions bundle/config/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func TestInitializeVariables(t *testing.T) {

err := root.InitializeVariables([]string{"foo=123", "bar=456"})
assert.NoError(t, err)
assert.Equal(t, "123", (root.Variables["foo"].Value))
assert.Equal(t, "456", (root.Variables["bar"].Value))
assert.Equal(t, "123", root.Variables["foo"].Value)
assert.Equal(t, "456", root.Variables["bar"].Value)
}

func TestInitializeVariablesWithAnEqualSignInValue(t *testing.T) {
Expand All @@ -62,7 +62,7 @@ func TestInitializeVariablesWithAnEqualSignInValue(t *testing.T) {

err := root.InitializeVariables([]string{"foo=123=567"})
assert.NoError(t, err)
assert.Equal(t, "123=567", (root.Variables["foo"].Value))
assert.Equal(t, "123=567", root.Variables["foo"].Value)
}

func TestInitializeVariablesInvalidFormat(t *testing.T) {
Expand Down
4 changes: 1 addition & 3 deletions bundle/config/validate/job_task_cluster_spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ Specify one of the following fields: job_cluster_key, environment_key, existing_
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
job := &resources.Job{
JobSettings: jobs.JobSettings{
Tasks: []jobs.Task{tc.task},
},
Tasks: []jobs.Task{tc.task},
}

b := createBundle(map[string]*resources.Job{"job1": job})
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (w *Workspace) Config(ctx context.Context) *config.Config {
AzureClientID: w.AzureClientID,
AzureTenantID: w.AzureTenantID,
AzureEnvironment: w.AzureEnvironment,
AzureLoginAppID: w.AzureLoginAppID,
AzureLoginAppID: w.AzureLoginAppID, //nolint:staticcheck // SA1019: still accepted in bundle config; forwarded until the SDK drops the field

// Unified host
AccountID: w.AccountID,
Expand Down
2 changes: 1 addition & 1 deletion bundle/direct/bundle_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ func TestLadderBackendDefaultBeforeRemoteAddition(t *testing.T) {
adapter, err := dresources.NewAdapter(dresources.SupportedResources["clusters"], "clusters", nil)
require.NoError(t, err)

newState := &dresources.ClusterState{ClusterSpec: compute.ClusterSpec{PolicyId: "p1"}}
newState := &dresources.ClusterState{PolicyId: "p1"}
changes := deployplan.Changes{
// config-absent (Old==New==nil), present in remote: matches both rules.
"enable_elastic_disk": &deployplan.ChangeDesc{Remote: true},
Expand Down
Loading
Loading