Skip to content
Open
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
18 changes: 11 additions & 7 deletions experimental/ssh/internal/vscode/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,29 +214,33 @@ func validateSettings(v hujson.Value, connectionName string) *missingSettings {
func settingsMessage(connectionName string, missing *missingSettings) string {
var lines []string
if missing.portRange {
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", serverPickPortsKey, connectionName, portRange))
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", serverPickPortsKey, connectionName, portRange))
}
if missing.platform {
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", remotePlatformKey, connectionName, remotePlatform))
lines = append(lines, fmt.Sprintf(" \"%s\": {\"%s\": \"%s\"}", remotePlatformKey, connectionName, remotePlatform))
}
if missing.listenOnSocket {
lines = append(lines, fmt.Sprintf(" \"%s\": true // Global setting that affects all remote ssh connections", listenOnSocketKey))
lines = append(lines, fmt.Sprintf(" \"%s\": true // Global setting", listenOnSocketKey))
}
if len(missing.extensions) > 0 {
quoted := make([]string, len(missing.extensions))
for i, ext := range missing.extensions {
quoted[i] = fmt.Sprintf("\"%s\"", ext)
}
lines = append(lines, fmt.Sprintf(" \"%s\": [%s] // Global setting that affects all remote ssh connections", defaultExtensionsKey, strings.Join(quoted, ", ")))
lines = append(lines, fmt.Sprintf(" \"%s\": [%s] // Global setting", defaultExtensionsKey, strings.Join(quoted, ", ")))
}
return strings.Join(lines, "\n")
return " {\n" + strings.Join(lines, ",\n") + "\n }"
}

func promptUserForUpdate(ctx context.Context, ide, connectionName string, missing *missingSettings) (bool, error) {
question := fmt.Sprintf(
"The following settings will be applied to %s for '%s':\n%s\nApply these settings?",
"The following settings will be applied to %s for '%s':\n\n%s\n\nApply these settings?",
Copy link
Member

Choose a reason for hiding this comment

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

[Agent Swarm Review] [Nit]

The change from cmdio.AskYesOrNo to cmdio.Ask with manual [Y/n] handling means only exact "y" matches are accepted. strings.EqualFold(strings.TrimSpace(ans), "y") or also accepting "yes" would be more robust.

getIDE(ide).Name, connectionName, settingsMessage(connectionName, missing))
return cmdio.AskYesOrNo(ctx, question)
ans, err := cmdio.Ask(ctx, question+" [Y/n]", "y")
if err != nil {
return false, err
}
return strings.ToLower(ans) == "y", nil
}

func handleMissingFile(ctx context.Context, ide, connectionName, settingsPath string) error {
Expand Down
14 changes: 14 additions & 0 deletions libs/gorules/rule_time_now_in_testserver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package gorules
Copy link
Member

Choose a reason for hiding this comment

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

[Agent Swarm Review] [Nit]

This new gorule and the testserver timestamp changes are unrelated to the IDE settings prompt improvements. Consider splitting into a separate PR for cleaner review.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems indeed unrelated. The output changes are good though


import "github.com/quasilyte/go-ruleguard/dsl"

// NoTimeNowUnixMilliInTestServer forbids direct time.Now().UnixMilli() calls in libs/testserver.
// Use nowMilli() instead to guarantee unique, strictly increasing timestamps.
// Integer millisecond timestamps get indexed replacements in test output (e.g. [UNIX_TIME_MILLIS][0])
// and collisions between resources cause flaky tests.
func NoTimeNowUnixMilliInTestServer(m dsl.Matcher) {
m.Match(`time.Now().UnixMilli()`).
Where(m.File().PkgPath.Matches(`.*/libs/testserver`) &&
!m.File().Name.Matches(`fake_workspace\.go$`)).
Report(`Use nowMilli() instead of time.Now().UnixMilli() in testserver to ensure unique timestamps`)
}
7 changes: 3 additions & 4 deletions libs/testserver/catalogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"

"github.com/databricks/databricks-sdk-go/service/catalog"
)
Expand All @@ -29,14 +28,14 @@ func (s *FakeWorkspace) CatalogsCreate(req Request) Response {
Options: createRequest.Options,
Properties: createRequest.Properties,
FullName: createRequest.Name,
CreatedAt: time.Now().UnixMilli(),
CreatedAt: nowMilli(),
CreatedBy: s.CurrentUser().UserName,
UpdatedAt: time.Now().UnixMilli(),
UpdatedBy: s.CurrentUser().UserName,
MetastoreId: nextUUID(),
Owner: s.CurrentUser().UserName,
CatalogType: catalog.CatalogTypeManagedCatalog,
}
catalogInfo.UpdatedAt = catalogInfo.CreatedAt

s.Catalogs[createRequest.Name] = catalogInfo
return Response{
Expand Down Expand Up @@ -79,7 +78,7 @@ func (s *FakeWorkspace) CatalogsUpdate(req Request, name string) Response {
name = updateRequest.NewName
}

existing.UpdatedAt = time.Now().UnixMilli()
existing.UpdatedAt = nowMilli()
existing.UpdatedBy = s.CurrentUser().UserName

s.Catalogs[name] = existing
Expand Down
7 changes: 3 additions & 4 deletions libs/testserver/external_locations.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"

"github.com/databricks/databricks-sdk-go/service/catalog"
)
Expand Down Expand Up @@ -37,13 +36,13 @@ func (s *FakeWorkspace) ExternalLocationsCreate(req Request) Response {
Fallback: createRequest.Fallback,
EncryptionDetails: createRequest.EncryptionDetails,
FileEventQueue: createRequest.FileEventQueue,
CreatedAt: time.Now().UnixMilli(),
CreatedAt: nowMilli(),
CreatedBy: s.CurrentUser().UserName,
UpdatedAt: time.Now().UnixMilli(),
UpdatedBy: s.CurrentUser().UserName,
MetastoreId: nextUUID(),
Owner: s.CurrentUser().UserName,
}
locationInfo.UpdatedAt = locationInfo.CreatedAt

s.ExternalLocations[createRequest.Name] = locationInfo
return Response{
Expand Down Expand Up @@ -95,7 +94,7 @@ func (s *FakeWorkspace) ExternalLocationsUpdate(req Request, name string) Respon
name = updateRequest.NewName
}

existing.UpdatedAt = time.Now().UnixMilli()
existing.UpdatedAt = nowMilli()
existing.UpdatedBy = s.CurrentUser().UserName

s.ExternalLocations[name] = existing
Expand Down
3 changes: 1 addition & 2 deletions libs/testserver/pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package testserver
import (
"encoding/json"
"fmt"
"time"

"github.com/databricks/databricks-sdk-go/service/pipelines"
)
Expand Down Expand Up @@ -41,7 +40,7 @@ func (s *FakeWorkspace) PipelineCreate(req Request) Response {
pipelineId := nextUUID()
r.PipelineId = pipelineId
r.CreatorUserName = "tester@databricks.com"
r.LastModified = time.Now().UnixMilli()
r.LastModified = nowMilli()
r.Name = r.Spec.Name
r.RunAsUserName = "tester@databricks.com"
r.State = "IDLE"
Expand Down
7 changes: 3 additions & 4 deletions libs/testserver/registered_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"

"github.com/databricks/databricks-sdk-go/service/catalog"
)
Expand All @@ -30,13 +29,13 @@ func (s *FakeWorkspace) RegisteredModelsCreate(req Request) Response {
SchemaName: createRequest.SchemaName,
StorageLocation: createRequest.StorageLocation,
FullName: fullName,
CreatedAt: time.Now().UnixMilli(),
CreatedAt: nowMilli(),
CreatedBy: s.CurrentUser().UserName,
UpdatedAt: time.Now().UnixMilli(),
UpdatedBy: s.CurrentUser().UserName,
MetastoreId: nextUUID(),
Owner: s.CurrentUser().UserName,
}
registeredModel.UpdatedAt = registeredModel.CreatedAt

s.RegisteredModels[fullName] = registeredModel
return Response{
Expand Down Expand Up @@ -78,7 +77,7 @@ func (s *FakeWorkspace) RegisteredModelsUpdate(req Request, fullName string) Res
fullName = existing.CatalogName + "." + existing.SchemaName + "." + updateRequest.NewName
}

existing.UpdatedAt = time.Now().UnixMilli()
existing.UpdatedAt = nowMilli()
s.RegisteredModels[fullName] = existing
return Response{
Body: existing,
Expand Down
Loading