diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index f2e569c609c..b7372336591 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,3 +8,6 @@ ### Bundles * The error reported when a direct-only resource (catalogs, external locations, vector search endpoints) is used with the terraform engine now also suggests setting `bundle.engine: direct` in `databricks.yml`, in addition to the `DATABRICKS_BUNDLE_ENGINE` environment variable ([#5295](https://github.com/databricks/cli/pull/5295)). + +### Dependency updates +* Bump Go toolchain to 1.26.3 ([#5302](https://github.com/databricks/cli/pull/5302)). diff --git a/bundle/config/resources/dashboard_test.go b/bundle/config/resources/dashboard_test.go index c010d949157..83c80b17107 100644 --- a/bundle/config/resources/dashboard_test.go +++ b/bundle/config/resources/dashboard_test.go @@ -29,8 +29,7 @@ func TestDashboardConfigIsSupersetOfSDKDashboard(t *testing.T) { // Create a map of SDK fields by name and their JSON tags sdkFields := make(map[string]string) - for i := range sdkType.NumField() { - field := sdkType.Field(i) + for field := range sdkType.Fields() { jsonTag := field.Tag.Get("json") jsonName := getJSONTagName(jsonTag) if jsonName != "" { @@ -40,8 +39,7 @@ func TestDashboardConfigIsSupersetOfSDKDashboard(t *testing.T) { // Create a map of config fields by name and their JSON tags configFields := make(map[string]string) - for i := range configType.NumField() { - field := configType.Field(i) + for field := range configType.Fields() { jsonTag := field.Tag.Get("json") jsonName := getJSONTagName(jsonTag) if jsonName != "" { diff --git a/bundle/config/resources_test.go b/bundle/config/resources_test.go index 1be4a84a1f8..a75863d70b5 100644 --- a/bundle/config/resources_test.go +++ b/bundle/config/resources_test.go @@ -53,9 +53,7 @@ import ( func TestCustomMarshallerIsImplemented(t *testing.T) { rt := reflect.TypeFor[Resources]() - for i := range rt.NumField() { - field := rt.Field(i) - + for field := range rt.Fields() { // Fields in Resources are expected be of the form map[string]*resourceStruct assert.Equal(t, reflect.Map, field.Type.Kind(), "Resource %s is not a map", field.Name) kt := field.Type.Key() @@ -95,8 +93,7 @@ func TestResourcesAllResourcesCompleteness(t *testing.T) { types = append(types, group.Description.PluralName) } - for i := range rt.NumField() { - field := rt.Field(i) + for field := range rt.Fields() { jsonTag := field.Tag.Get("json") if idx := strings.Index(jsonTag, ","); idx != -1 { @@ -112,8 +109,7 @@ func TestSupportedResources(t *testing.T) { actual := SupportedResources() typ := reflect.TypeFor[Resources]() - for i := range typ.NumField() { - field := typ.Field(i) + for field := range typ.Fields() { jsonTags := strings.Split(field.Tag.Get("json"), ",") pluralName := jsonTags[0] assert.Equal(t, actual[pluralName].PluralName, pluralName) diff --git a/bundle/deploy/terraform/tfdyn/convert_job_test.go b/bundle/deploy/terraform/tfdyn/convert_job_test.go index 1f67369e916..f7a69f77a01 100644 --- a/bundle/deploy/terraform/tfdyn/convert_job_test.go +++ b/bundle/deploy/terraform/tfdyn/convert_job_test.go @@ -296,9 +296,7 @@ func TestSupportedTypeTasksComplete(t *testing.T) { taskType := reflect.TypeFor[jobs.Task]() var tasksWithSource []string - for i := range taskType.NumField() { - field := taskType.Field(i) - + for field := range taskType.Fields() { // Skip non-task fields (like DependsOn, Libraries, etc.) if !strings.HasSuffix(field.Name, "Task") { continue @@ -351,9 +349,7 @@ func findSourceFieldsShallow(t reflect.Type) []string { var paths []string - for i := range t.NumField() { - field := t.Field(i) - + for field := range t.Fields() { // Check if this field is named "Source" if field.Name == "Source" { paths = append(paths, "") diff --git a/bundle/direct/dresources/app_test.go b/bundle/direct/dresources/app_test.go index edb99c4cffb..c7cbfacd1af 100644 --- a/bundle/direct/dresources/app_test.go +++ b/bundle/direct/dresources/app_test.go @@ -149,8 +149,7 @@ func TestAppDoUpdate_UpdateMaskHasAllFields(t *testing.T) { fields := reflect.TypeFor[apps.App]() var allFields []string - for i := range fields.NumField() { - field := fields.Field(i) + for field := range fields.Fields() { jsonTag := field.Tag.Get("json") if jsonTag == "" || jsonTag == "-" { continue diff --git a/bundle/direct/dresources/util_test.go b/bundle/direct/dresources/util_test.go index bf945aa09b5..544b3e2bde8 100644 --- a/bundle/direct/dresources/util_test.go +++ b/bundle/direct/dresources/util_test.go @@ -12,15 +12,13 @@ import ( func assertFieldsCovered(t *testing.T, sdkType, remoteType reflect.Type, skip map[string]bool) { t.Helper() remoteFields := map[string]bool{} - for i := range remoteType.NumField() { - f := remoteType.Field(i) + for f := range remoteType.Fields() { if !f.Anonymous { remoteFields[f.Name] = true } } - for i := range sdkType.NumField() { - field := sdkType.Field(i) + for field := range sdkType.Fields() { if skip[field.Name] { assert.NotContains(t, remoteFields, field.Name, "field %s is in skip list but present in %s; remove it from skip", field.Name, remoteType.Name()) continue diff --git a/bundle/docsgen/nodes_test.go b/bundle/docsgen/nodes_test.go index 028bf1eff62..227d1bc01b3 100644 --- a/bundle/docsgen/nodes_test.go +++ b/bundle/docsgen/nodes_test.go @@ -25,7 +25,7 @@ func TestBuildNodes_ChildExpansion(t *testing.T) { Items: &jsonschema.Schema{ Type: "object", Properties: map[string]*jsonschema.Schema{ - "listSub": {Reference: strPtr("#/$defs/github.com/listSub")}, + "listSub": {Reference: new("#/$defs/github.com/listSub")}, }, }, }, @@ -61,9 +61,9 @@ func TestBuildNodes_ChildExpansion(t *testing.T) { "myMap": { Type: "object", AdditionalProperties: &jsonschema.Schema{ - Reference: strPtr("#/$defs/github.com/myMap"), + Reference: new("#/$defs/github.com/myMap"), Properties: map[string]*jsonschema.Schema{ - "mapSub": {Type: "object", Reference: strPtr("#/$defs/github.com/mapSub")}, + "mapSub": {Type: "object", Reference: new("#/$defs/github.com/mapSub")}, }, }, }, @@ -73,7 +73,7 @@ func TestBuildNodes_ChildExpansion(t *testing.T) { "github.com/myMap": { Type: "object", Properties: map[string]*jsonschema.Schema{ - "mapSub": {Type: "boolean", Reference: strPtr("#/$defs/github.com/mapSub")}, + "mapSub": {Type: "boolean", Reference: new("#/$defs/github.com/mapSub")}, }, }, "github.com/mapSub": { @@ -170,7 +170,3 @@ func TestDoNotSuggestFields(t *testing.T) { assert.Len(t, nodes[0].Attributes, 1) assert.Equal(t, "nestedNotDoNotSuggestField", nodes[0].Attributes[0].Title) } - -func strPtr(s string) *string { - return &s -} diff --git a/bundle/internal/schema/parser.go b/bundle/internal/schema/parser.go index d72524dc59c..ba0c8545ce2 100644 --- a/bundle/internal/schema/parser.go +++ b/bundle/internal/schema/parser.go @@ -58,13 +58,13 @@ func (p *openapiParser) findRef(typ reflect.Type) (jsonschema.Schema, bool) { // Check for embedded Databricks Go SDK types. if typ.Kind() == reflect.Struct { - for i := range typ.NumField() { - if !typ.Field(i).Anonymous { + for field := range typ.Fields() { + if !field.Anonymous { continue } // Deference current type if it's a pointer. - ctyp := typ.Field(i).Type + ctyp := field.Type for ctyp.Kind() == reflect.Ptr { ctyp = ctyp.Elem() } diff --git a/bundle/internal/tf/codegen/go.mod b/bundle/internal/tf/codegen/go.mod index 6d3956c8ad6..776c067a604 100644 --- a/bundle/internal/tf/codegen/go.mod +++ b/bundle/internal/tf/codegen/go.mod @@ -1,8 +1,8 @@ module github.com/databricks/cli/bundle/internal/tf/codegen -go 1.25.8 +go 1.26.0 -toolchain go1.25.10 +toolchain go1.26.3 require ( github.com/hashicorp/go-version v1.9.0 diff --git a/cmd/pipelines/history_test.go b/cmd/pipelines/history_test.go index 86d6d7d9d6e..c1baec58327 100644 --- a/cmd/pipelines/history_test.go +++ b/cmd/pipelines/history_test.go @@ -24,25 +24,25 @@ func TestUpdatesBefore(t *testing.T) { }{ { name: "before 700", - timestamp: int64Ptr(700), + timestamp: new(int64(700)), expectedCount: 3, expectedFirst: 600, }, { name: "before 1000", - timestamp: int64Ptr(1000), + timestamp: new(int64(1000)), expectedCount: 5, expectedFirst: 1000, }, { name: "before 200", - timestamp: int64Ptr(200), + timestamp: new(int64(200)), expectedCount: 1, expectedFirst: 200, }, { name: "before 100", - timestamp: int64Ptr(100), + timestamp: new(int64(100)), expectedCount: 0, expectedFirst: 0, }, @@ -79,25 +79,25 @@ func TestUpdatesAfter(t *testing.T) { }{ { name: "after 500", - timestamp: int64Ptr(500), + timestamp: new(int64(500)), expectedCount: 3, expectedFirst: 1000, }, { name: "after 200", - timestamp: int64Ptr(200), + timestamp: new(int64(200)), expectedCount: 5, expectedFirst: 1000, }, { name: "after 1000", - timestamp: int64Ptr(1000), + timestamp: new(int64(1000)), expectedCount: 1, expectedFirst: 1000, }, { name: "after 1200", - timestamp: int64Ptr(1200), + timestamp: new(int64(1200)), expectedCount: 0, expectedFirst: 0, }, @@ -181,7 +181,7 @@ func TestFilterUpdates(t *testing.T) { name: "start time nil, end time set", updates: updates, startTime: nil, - endTime: int64Ptr(700), + endTime: new(int64(700)), expectedCount: 3, expectedFirst: 600, expectedLast: 200, @@ -189,7 +189,7 @@ func TestFilterUpdates(t *testing.T) { { name: "start time set, end time nil", updates: updates, - startTime: int64Ptr(500), + startTime: new(int64(500)), endTime: nil, expectedCount: 3, expectedFirst: 1000, @@ -198,8 +198,8 @@ func TestFilterUpdates(t *testing.T) { { name: "both times set within range", updates: updates, - startTime: int64Ptr(300), - endTime: int64Ptr(900), + startTime: new(int64(300)), + endTime: new(int64(900)), expectedCount: 3, expectedFirst: 800, expectedLast: 400, @@ -207,8 +207,8 @@ func TestFilterUpdates(t *testing.T) { { name: "both times set, no overlap", updates: updates, - startTime: int64Ptr(1200), - endTime: int64Ptr(1500), + startTime: new(int64(1200)), + endTime: new(int64(1500)), expectedCount: 0, expectedFirst: 0, expectedLast: 0, @@ -216,7 +216,7 @@ func TestFilterUpdates(t *testing.T) { { name: "start time after all updates", updates: updates, - startTime: int64Ptr(1200), + startTime: new(int64(1200)), endTime: nil, expectedCount: 0, expectedFirst: 0, @@ -226,7 +226,7 @@ func TestFilterUpdates(t *testing.T) { name: "end time before all updates", updates: updates, startTime: nil, - endTime: int64Ptr(100), + endTime: new(int64(100)), expectedCount: 0, expectedFirst: 0, expectedLast: 0, @@ -234,8 +234,8 @@ func TestFilterUpdates(t *testing.T) { { name: "start time after end time but within range", updates: updates, - startTime: int64Ptr(700), - endTime: int64Ptr(500), + startTime: new(int64(700)), + endTime: new(int64(500)), expectedCount: 0, expectedFirst: 0, expectedLast: 0, @@ -243,8 +243,8 @@ func TestFilterUpdates(t *testing.T) { { name: "start and end time match exact values in list", updates: updates, - startTime: int64Ptr(400), - endTime: int64Ptr(800), + startTime: new(int64(400)), + endTime: new(int64(800)), expectedCount: 3, expectedFirst: 800, expectedLast: 400, @@ -289,6 +289,3 @@ func TestFilterUpdates(t *testing.T) { }) } } - -// Helper function to create int64 pointers -func int64Ptr(v int64) *int64 { return &v } diff --git a/go.mod b/go.mod index 0bb3109463e..50c45ad551b 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ module github.com/databricks/cli -go 1.25.8 +go 1.26.0 -toolchain go1.25.10 +toolchain go1.26.3 require ( dario.cat/mergo v1.0.2 // BSD-3-Clause diff --git a/libs/apps/runlocal/spec_test.go b/libs/apps/runlocal/spec_test.go index 3b3cfde51aa..f4218c09e41 100644 --- a/libs/apps/runlocal/spec_test.go +++ b/libs/apps/runlocal/spec_test.go @@ -28,11 +28,11 @@ func TestAppSpecLoadEnvVars(t *testing.T) { EnvVars: []AppEnvVar{ { Name: "VAR1", - Value: stringPtr("value1"), + Value: new("value1"), }, { Name: "VAR2", - Value: stringPtr("value2"), + Value: new("value2"), }, }, } @@ -53,11 +53,11 @@ func TestAppSpecLoadEnvVars(t *testing.T) { EnvVars: []AppEnvVar{ { Name: "VAR1", - ValueFrom: stringPtr("VAR1"), + ValueFrom: new("VAR1"), }, { Name: "VAR2", - ValueFrom: stringPtr("VAR2"), + ValueFrom: new("VAR2"), }, }, } @@ -77,11 +77,11 @@ func TestAppSpecLoadEnvVars(t *testing.T) { EnvVars: []AppEnvVar{ { Name: "VAR1", - Value: stringPtr("value1"), + Value: new("value1"), }, { Name: "VAR2", - ValueFrom: stringPtr("VAR2"), + ValueFrom: new("VAR2"), }, }, } @@ -101,7 +101,7 @@ func TestAppSpecLoadEnvVars(t *testing.T) { EnvVars: []AppEnvVar{ { Name: "VAR1", - ValueFrom: stringPtr("VAR1"), + ValueFrom: new("VAR1"), }, }, } @@ -121,7 +121,7 @@ func TestAppSpecLoadEnvVars(t *testing.T) { EnvVars: []AppEnvVar{ { Name: "VAR1", - ValueFrom: stringPtr("MISSING_VAR"), + ValueFrom: new("MISSING_VAR"), }, }, } @@ -149,8 +149,3 @@ func TestAppSpecLoadEnvVars(t *testing.T) { }) } } - -// Helper function to create a string pointer -func stringPtr(s string) *string { - return &s -} diff --git a/libs/calladapt/validate.go b/libs/calladapt/validate.go index 8613d42d906..e33697a79f4 100644 --- a/libs/calladapt/validate.go +++ b/libs/calladapt/validate.go @@ -11,13 +11,12 @@ func EnsureNoExtraMethods(receiver any, ifaceTypes ...reflect.Type) error { allowed := make(map[string]struct{}) for _, ifaceType := range ifaceTypes { - for i := range ifaceType.NumMethod() { - allowed[ifaceType.Method(i).Name] = struct{}{} + for method := range ifaceType.Methods() { + allowed[method.Name] = struct{}{} } } - for i := range rt.NumMethod() { - m := rt.Method(i) + for m := range rt.Methods() { if _, ok := allowed[m.Name]; !ok { return fmt.Errorf("unexpected method %s on %v; only methods from %v are allowed", m.Name, rt, ifaceTypes) } diff --git a/libs/cmdio/pager_test.go b/libs/cmdio/pager_test.go index 645b26cbd04..3c76c1ee323 100644 --- a/libs/cmdio/pager_test.go +++ b/libs/cmdio/pager_test.go @@ -57,9 +57,9 @@ func printedText(t *testing.T, msg tea.Msg) string { t.Helper() rv := reflect.ValueOf(msg) require.Equal(t, reflect.Struct, rv.Kind(), "expected a struct msg, got %T", msg) - for i := range rv.NumField() { - if rv.Field(i).Kind() == reflect.String { - return rv.Field(i).String() + for _, field := range rv.Fields() { + if field.Kind() == reflect.String { + return field.String() } } t.Fatalf("no string field in %T", msg) diff --git a/libs/jsonschema/from_type.go b/libs/jsonschema/from_type.go index 356db14b6b8..8c6213b07ed 100644 --- a/libs/jsonschema/from_type.go +++ b/libs/jsonschema/from_type.go @@ -224,8 +224,8 @@ func getStructFields(typ reflect.Type) []reflect.StructField { var fields []reflect.StructField bfsQueue := list.New() - for i := range typ.NumField() { - bfsQueue.PushBack(typ.Field(i)) + for field := range typ.Fields() { + bfsQueue.PushBack(field) } for bfsQueue.Len() > 0 { front := bfsQueue.Front() @@ -246,8 +246,8 @@ func getStructFields(typ reflect.Type) []reflect.StructField { fieldType = fieldType.Elem() } - for i := range fieldType.NumField() { - bfsQueue.PushBack(fieldType.Field(i)) + for field := range fieldType.Fields() { + bfsQueue.PushBack(field) } } return fields diff --git a/libs/structs/structaccess/convert_test.go b/libs/structs/structaccess/convert_test.go index 02fcfc700ab..f4ccbef0f05 100644 --- a/libs/structs/structaccess/convert_test.go +++ b/libs/structs/structaccess/convert_test.go @@ -61,22 +61,22 @@ func TestConvertToString(t *testing.T) { // Pointers { name: "string pointer", - value: stringPtr("test"), + value: new("test"), expected: "test", }, { name: "int pointer", - value: intPtr(123), + value: new(123), expected: "123", }, { name: "float64 pointer", - value: float64Ptr(2.5), + value: new(2.5), expected: "2.5", }, { name: "bool pointer", - value: boolPtr(true), + value: new(true), expected: "true", }, { @@ -146,19 +146,3 @@ func TestConvertToString(t *testing.T) { }) } } - -func stringPtr(s string) *string { - return &s -} - -func intPtr(i int) *int { - return &i -} - -func float64Ptr(f float64) *float64 { - return &f -} - -func boolPtr(b bool) *bool { - return &b -} diff --git a/libs/structs/structaccess/typecheck.go b/libs/structs/structaccess/typecheck.go index 2fa9a1f8d44..6e7c7d90ea4 100644 --- a/libs/structs/structaccess/typecheck.go +++ b/libs/structs/structaccess/typecheck.go @@ -142,8 +142,7 @@ func FindStructFieldByKeyType(t reflect.Type, key string) (reflect.StructField, } // First pass: direct fields - for i := range t.NumField() { - sf := t.Field(i) + for sf := range t.Fields() { if sf.PkgPath != "" { // unexported continue } @@ -162,8 +161,7 @@ func FindStructFieldByKeyType(t reflect.Type, key string) (reflect.StructField, } // Second pass: search embedded anonymous structs recursively (flattening semantics) - for i := range t.NumField() { - sf := t.Field(i) + for sf := range t.Fields() { if !sf.Anonymous { continue } diff --git a/libs/structs/structwalk/walktype.go b/libs/structs/structwalk/walktype.go index 495a369d64a..cd4be28c843 100644 --- a/libs/structs/structwalk/walktype.go +++ b/libs/structs/structwalk/walktype.go @@ -104,8 +104,7 @@ func walkTypeValue(path *structpath.PatternNode, typ reflect.Type, field *reflec } func walkTypeStruct(path *structpath.PatternNode, st reflect.Type, visit VisitTypeFunc, visitedCount map[reflect.Type]int) { - for i := range st.NumField() { - sf := st.Field(i) + for sf := range st.Fields() { if sf.PkgPath != "" { continue // unexported } diff --git a/tools/go.mod b/tools/go.mod index 4b84239abcc..23a03db6721 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,8 +1,8 @@ module github.com/databricks/cli/tools -go 1.25.0 +go 1.26.0 -toolchain go1.25.10 +toolchain go1.26.3 require github.com/stretchr/testify v1.11.1 diff --git a/tools/task/go.mod b/tools/task/go.mod index 623da6fa617..cc3f0201735 100644 --- a/tools/task/go.mod +++ b/tools/task/go.mod @@ -1,8 +1,8 @@ module github.com/databricks/cli/tools/task -go 1.25.8 +go 1.26.0 -toolchain go1.25.10 +toolchain go1.26.3 require ( cel.dev/expr v0.25.1 // indirect