Enable linter 'mirror' and autofix existing issues (#2070)

https://github.com/butuzov/mirror
This commit is contained in:
Denis Bilenko 2025-01-03 11:13:12 +01:00 committed by GitHub
parent 39d1e8093f
commit 8e8399da83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,7 @@ linters:
- goimports
- testifylint
- intrange
- mirror
linters-settings:
govet:
enable-all: true

View File

@ -7,6 +7,7 @@ import (
"io"
"os"
"path/filepath"
"strings"
"github.com/databricks/cli/bundle"
"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 {
output := buf.String()
// 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)
if !cmdio.IsPromptSupported(ctx) {

View File

@ -74,7 +74,7 @@ func makeIterator(count int) listing.Iterator[*provisioning.Workspace] {
func makeBigOutput(count int) string {
res := bytes.Buffer{}
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()
}

View File

@ -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
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
matches := regex.FindStringSubmatch(aerr.Message)
if len(matches) == 2 {