mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: modernize the codebase using go 1.26 (#278)
This runs: ``` go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./... ``` over the codebase, as this is using go 1.26, it can also use the new new() functionallity so AsPtr and boolPtr is are needed anymore. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -11,7 +11,7 @@ const MachinesExtensionKey = "x-machines"
|
||||
type MachinesSource []string
|
||||
|
||||
// DecodeMapstructure implements custom decoding for multiple input types
|
||||
func (m *MachinesSource) DecodeMapstructure(value interface{}) error {
|
||||
func (m *MachinesSource) DecodeMapstructure(value any) error {
|
||||
switch v := value.(type) {
|
||||
case *MachinesSource:
|
||||
// Handle case where compose-go passes a pointer to an already created instance
|
||||
@@ -38,7 +38,7 @@ func (m *MachinesSource) DecodeMapstructure(value interface{}) error {
|
||||
}
|
||||
*m = MachinesSource(machines)
|
||||
return nil
|
||||
case []interface{}:
|
||||
case []any:
|
||||
// Support interface array that may come from YAML parsing
|
||||
machineNames := make([]string, 0, len(v))
|
||||
for i, machine := range v {
|
||||
|
||||
@@ -346,9 +346,7 @@ func dockerVolumeSpecFromCompose(serviceVolume types.ServiceVolumeConfig, volume
|
||||
func mergeLabels(labels ...types.Labels) types.Labels {
|
||||
merged := types.Labels{}
|
||||
for _, l := range labels {
|
||||
for k, v := range l {
|
||||
merged[k] = v
|
||||
}
|
||||
maps.Copy(merged, l)
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
+4
-6
@@ -474,12 +474,10 @@ func toPushProgressEvent(jm jsonmessage.JSONMessage) *progress.Event {
|
||||
percent := 0
|
||||
|
||||
if jm.Progress.Total > 0 {
|
||||
percent = int(jm.Progress.Current * 100 / jm.Progress.Total)
|
||||
// Cap percent at 100 to prevent index out of bounds in progress display.
|
||||
// Docker can report Current > Total in some cases (e.g., compression).
|
||||
if percent > 100 {
|
||||
percent = 100
|
||||
}
|
||||
percent = min(
|
||||
// Cap percent at 100 to prevent index out of bounds in progress display.
|
||||
// Docker can report Current > Total in some cases (e.g., compression).
|
||||
int(jm.Progress.Current*100/jm.Progress.Total), 100)
|
||||
}
|
||||
|
||||
switch jm.Status {
|
||||
|
||||
@@ -264,7 +264,7 @@ func TestLogMerger_UnevenStreams(t *testing.T) {
|
||||
baseTime := time.Now()
|
||||
|
||||
// Stream 1 sends many entries quickly (0ms - 104ms).
|
||||
for i := 0; i < numFastEntries; i++ {
|
||||
for i := range numFastEntries {
|
||||
ch1 <- testEntry(api.LogStreamStdout, baseTime.Add(time.Duration(i)*time.Millisecond), "fast")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user