Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgraded Go version to 1.21 #664

Merged
merged 3 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion bundle/artifacts/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"fmt"

"slices"

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

// all is an internal proxy for producing a list of mutators for all artifacts.
Expand Down
3 changes: 2 additions & 1 deletion bundle/config/interpolation/interpolation.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"sort"
"strings"

"slices"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not formatted correctly because there's a new line before but technically it's a correct formatting still


"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config/variable"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

const Delimiter = "."
Expand Down
3 changes: 1 addition & 2 deletions bundle/config/interpolation/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package interpolation
import (
"errors"
"fmt"
"slices"
"strings"

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

// LookupFunction returns the value to rewrite a path expression to.
Expand Down
2 changes: 1 addition & 1 deletion bundle/config/mutator/process_root_includes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"

"github.com/databricks/cli/bundle"
"github.com/databricks/cli/bundle/config"
"golang.org/x/exp/slices"
)

// Get extra include paths from environment variable
Expand Down
3 changes: 2 additions & 1 deletion bundle/internal/tf/codegen/generator/util.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package generator

import (
"slices"

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

// sortKeys returns a sorted copy of the keys in the specified map.
Expand Down
3 changes: 2 additions & 1 deletion bundle/internal/tf/codegen/generator/walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"fmt"
"strings"

"slices"

tfjson "github.com/hashicorp/terraform-json"
"github.com/iancoleman/strcase"
"github.com/zclconf/go-cty/cty"
"golang.org/x/exp/slices"
)

type field struct {
Expand Down
11 changes: 6 additions & 5 deletions cmd/root/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"context"
"fmt"
"io"
"log/slog"
"os"

"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/log"
"github.com/fatih/color"
"github.com/spf13/cobra"
"golang.org/x/exp/slog"
)

const (
Expand Down Expand Up @@ -52,11 +52,12 @@ func (l *friendlyHandler) coloredLevel(rec slog.Record) string {
func (l *friendlyHandler) Handle(ctx context.Context, rec slog.Record) error {
t := fmt.Sprintf("%02d:%02d", rec.Time.Hour(), rec.Time.Minute())
attrs := ""
rec.Attrs(func(a slog.Attr) {
rec.Attrs(func(a slog.Attr) bool {
attrs += fmt.Sprintf(" %s%s%s",
color.CyanString(a.Key),
color.CyanString("="),
color.YellowString(a.Value.String()))
return true
})
msg := fmt.Sprintf("%s %s %s%s\n",
color.MagentaString(t),
Expand All @@ -76,16 +77,16 @@ type logFlags struct {
func (f *logFlags) makeLogHandler(opts slog.HandlerOptions) (slog.Handler, error) {
switch f.output {
case flags.OutputJSON:
return opts.NewJSONHandler(f.file.Writer()), nil
return slog.NewJSONHandler(f.file.Writer(), &opts), nil
case flags.OutputText:
w := f.file.Writer()
if cmdio.IsTTY(w) {
return &friendlyHandler{
Handler: opts.NewTextHandler(w),
Handler: slog.NewTextHandler(w, &opts),
w: w,
}, nil
}
return opts.NewTextHandler(w), nil
return slog.NewTextHandler(w, &opts), nil

default:
return nil, fmt.Errorf("invalid log output mode: %s", f.output)
Expand Down
3 changes: 2 additions & 1 deletion cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"os"
"strings"

"log/slog"

"github.com/databricks/cli/internal/build"
"github.com/databricks/cli/libs/cmdio"
"github.com/databricks/cli/libs/log"
"github.com/spf13/cobra"
"golang.org/x/exp/slog"
)

func New() *cobra.Command {
Expand Down
1 change: 0 additions & 1 deletion internal/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func GetEnvOrSkipTest(t *testing.T, name string) string {

// RandomName gives random name with optional prefix. e.g. qa.RandomName("tf-")
func RandomName(prefix ...string) string {
rand.Seed(time.Now().UnixNano())
randLen := 12
b := make([]byte, randLen)
for i := range b {
Expand Down
6 changes: 3 additions & 3 deletions libs/cmdio/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"fmt"
"io"
"os"
"slices"
"strings"
"time"

"github.com/briandowns/spinner"
"github.com/databricks/cli/libs/flags"
"github.com/manifoldco/promptui"
"github.com/mattn/go-isatty"
"golang.org/x/exp/slices"
)

// cmdIO is the private instance, that is not supposed to be accessed
Expand Down Expand Up @@ -140,8 +140,8 @@ func (c *cmdIO) Select(names map[string]string, label string) (id string, err er
for k, v := range names {
items = append(items, tuple{k, v})
}
slices.SortFunc(items, func(a, b tuple) bool {
return a.Name < b.Name
slices.SortFunc(items, func(a, b tuple) int {
return strings.Compare(a.Name, b.Name)
})
idx, _, err := (&promptui.Select{
Label: label,
Expand Down
2 changes: 1 addition & 1 deletion libs/filer/dbfs_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
"io/fs"
"net/http"
"path"
"slices"
"sort"
"strings"
"time"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/service/files"
"golang.org/x/exp/slices"
)

// Type that implements fs.DirEntry for DBFS.
Expand Down
2 changes: 1 addition & 1 deletion libs/filer/files_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (
"net/http"
"net/url"
"path"
"slices"
"strings"
"time"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/client"
"golang.org/x/exp/slices"
)

// Type that implements fs.FileInfo for the Files API.
Expand Down
3 changes: 1 addition & 2 deletions libs/filer/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"io/fs"
"os"
"path/filepath"

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

// LocalClient implements the [Filer] interface for the local filesystem.
Expand Down
2 changes: 1 addition & 1 deletion libs/filer/slice.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package filer

import "golang.org/x/exp/slices"
import "slices"

// sliceWithout returns a copy of the specified slice without element e, if it is present.
func sliceWithout[S []E, E comparable](s S, e E) S {
Expand Down
2 changes: 1 addition & 1 deletion libs/filer/workspace_files_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/url"
"path"
"regexp"
"slices"
"sort"
"strings"
"time"
Expand All @@ -19,7 +20,6 @@ import (
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/client"
"github.com/databricks/databricks-sdk-go/service/workspace"
"golang.org/x/exp/slices"
)

// Type that implements fs.DirEntry for WSFS.
Expand Down
2 changes: 1 addition & 1 deletion libs/flags/log_level_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package flags

import (
"fmt"
"log/slog"
"strings"

"github.com/databricks/cli/libs/log"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
"golang.org/x/exp/slog"
)

var levels = map[string]slog.Level{
Expand Down
2 changes: 1 addition & 1 deletion libs/locker/locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"fmt"
"io"
"io/fs"
"slices"
"time"

"github.com/databricks/cli/libs/filer"
"github.com/databricks/databricks-sdk-go"
"github.com/google/uuid"
"golang.org/x/exp/slices"
)

type UnlockOption int
Expand Down
2 changes: 1 addition & 1 deletion libs/log/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package log
import (
"context"

"golang.org/x/exp/slog"
"log/slog"
)

type logger int
Expand Down
2 changes: 1 addition & 1 deletion libs/log/levels.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package log

import "golang.org/x/exp/slog"
import "log/slog"

const (
LevelTrace slog.Level = -8
Expand Down
2 changes: 1 addition & 1 deletion libs/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"runtime"
"time"

"golang.org/x/exp/slog"
"log/slog"
)

// GetLogger returns either the logger configured on the context,
Expand Down
2 changes: 1 addition & 1 deletion libs/log/replace_attr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package log

import "golang.org/x/exp/slog"
import "log/slog"

type ReplaceAttrFunction func(groups []string, a slog.Attr) slog.Attr

Expand Down
2 changes: 1 addition & 1 deletion libs/log/replace_attr_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package log

import (
"log/slog"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/exp/slog"
)

func testReplaceA(groups []string, a slog.Attr) slog.Attr {
Expand Down
3 changes: 2 additions & 1 deletion libs/log/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"runtime"
"time"

"log/slog"

sdk "github.com/databricks/databricks-sdk-go/logger"
"golang.org/x/exp/slog"
)

// slogAdapter makes an slog.Logger usable with the Databricks SDK.
Expand Down
3 changes: 1 addition & 2 deletions libs/log/source.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package log

import (
"log/slog"
"path/filepath"

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

// ReplaceSourceAttr rewrites the source attribute to include only the file's basename.
Expand Down
2 changes: 1 addition & 1 deletion libs/log/source_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package log

import (
"log/slog"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/exp/slog"
)

func TestReplaceSourceAttrSourceKey(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion libs/template/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"os"
"path"
"path/filepath"
"slices"
"strings"
"text/template"

"github.com/databricks/cli/libs/filer"
"github.com/databricks/cli/libs/log"
"github.com/databricks/databricks-sdk-go/logger"
"golang.org/x/exp/slices"
)

const templateExtension = ".tmpl"
Expand Down
2 changes: 1 addition & 1 deletion libs/template/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package template
import (
"fmt"
"reflect"
"slices"

"github.com/databricks/cli/libs/jsonschema"
"golang.org/x/exp/slices"
)

type validator func(v any) error
Expand Down