mirror of https://github.com/databricks/cli.git
Enable linter 'mirror' and autofix existing issues (#2070)
https://github.com/butuzov/mirror
This commit is contained in:
parent
39d1e8093f
commit
8e8399da83
|
@ -13,6 +13,7 @@ linters:
|
||||||
- goimports
|
- goimports
|
||||||
- testifylint
|
- testifylint
|
||||||
- intrange
|
- intrange
|
||||||
|
- mirror
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
govet:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/databricks/cli/bundle"
|
"github.com/databricks/cli/bundle"
|
||||||
"github.com/databricks/cli/libs/cmdio"
|
"github.com/databricks/cli/libs/cmdio"
|
||||||
|
@ -67,7 +68,7 @@ func (m *importResource) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagn
|
||||||
if changed && !m.opts.AutoApprove {
|
if changed && !m.opts.AutoApprove {
|
||||||
output := buf.String()
|
output := buf.String()
|
||||||
// Remove output starting from Warning until end of output
|
// Remove output starting from Warning until end of output
|
||||||
output = output[:bytes.Index([]byte(output), []byte("Warning:"))]
|
output = output[:strings.Index(output, "Warning:")]
|
||||||
cmdio.LogString(ctx, output)
|
cmdio.LogString(ctx, output)
|
||||||
|
|
||||||
if !cmdio.IsPromptSupported(ctx) {
|
if !cmdio.IsPromptSupported(ctx) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ func makeIterator(count int) listing.Iterator[*provisioning.Workspace] {
|
||||||
func makeBigOutput(count int) string {
|
func makeBigOutput(count int) string {
|
||||||
res := bytes.Buffer{}
|
res := bytes.Buffer{}
|
||||||
for _, ws := range makeWorkspaces(count) {
|
for _, ws := range makeWorkspaces(count) {
|
||||||
res.Write([]byte(fmt.Sprintf("%d %s\n", ws.WorkspaceId, ws.WorkspaceName)))
|
res.WriteString(fmt.Sprintf("%d %s\n", ws.WorkspaceId, ws.WorkspaceName))
|
||||||
}
|
}
|
||||||
return res.String()
|
return res.String()
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,7 @@ func (w *WorkspaceFilesClient) Write(ctx context.Context, name string, reader io
|
||||||
|
|
||||||
// This API returns 400 if the file already exists, when the object type is notebook
|
// This API returns 400 if the file already exists, when the object type is notebook
|
||||||
regex := regexp.MustCompile(`Path \((.*)\) already exists.`)
|
regex := regexp.MustCompile(`Path \((.*)\) already exists.`)
|
||||||
if aerr.StatusCode == http.StatusBadRequest && regex.Match([]byte(aerr.Message)) {
|
if aerr.StatusCode == http.StatusBadRequest && regex.MatchString(aerr.Message) {
|
||||||
// Parse file path from regex capture group
|
// Parse file path from regex capture group
|
||||||
matches := regex.FindStringSubmatch(aerr.Message)
|
matches := regex.FindStringSubmatch(aerr.Message)
|
||||||
if len(matches) == 2 {
|
if len(matches) == 2 {
|
||||||
|
|
Loading…
Reference in New Issue