build: go 1.24
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

We were running behind and there were quite some deprecations to update.
This was mostly in the upstream copy/pasta package but seems quite
minimal.
This commit is contained in:
2025-03-16 12:04:32 +01:00
parent a2b678caf6
commit 1723025fbf
822 changed files with 25433 additions and 197407 deletions

12
vendor/github.com/docker/cli/internal/tui/chip.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
import "strconv"
func Chip(fg, bg int, content string) string {
fgAnsi := "\x1b[38;5;" + strconv.Itoa(fg) + "m"
bgAnsi := "\x1b[48;5;" + strconv.Itoa(bg) + "m"
return fgAnsi + bgAnsi + content + "\x1b[0m"
}

33
vendor/github.com/docker/cli/internal/tui/colors.go generated vendored Normal file
View File

@ -0,0 +1,33 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
import (
"github.com/morikuni/aec"
)
var (
ColorTitle = aec.NewBuilder(aec.DefaultF, aec.Bold).ANSI
ColorPrimary = aec.NewBuilder(aec.DefaultF, aec.Bold).ANSI
ColorSecondary = aec.DefaultF
ColorTertiary = aec.NewBuilder(aec.DefaultF, aec.Faint).ANSI
ColorLink = aec.NewBuilder(aec.LightCyanF, aec.Underline).ANSI
ColorWarning = aec.LightYellowF
ColorFlag = aec.NewBuilder(aec.Bold).ANSI
ColorNone = aec.ANSI(noColor{})
)
type noColor struct{}
func (a noColor) With(_ ...aec.ANSI) aec.ANSI {
return a
}
func (noColor) Apply(s string) string {
return s
}
func (noColor) String() string {
return ""
}

70
vendor/github.com/docker/cli/internal/tui/count.go generated vendored Normal file
View File

@ -0,0 +1,70 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
import (
"strings"
"github.com/mattn/go-runewidth"
)
func cleanANSI(s string) string {
for {
start := strings.Index(s, "\x1b")
if start == -1 {
return s
}
end := strings.Index(s[start:], "m")
if end == -1 {
return s
}
s = s[:start] + s[start+end+1:]
}
}
// Width returns the width of the string, ignoring ANSI escape codes.
// Not all ANSI escape codes are supported yet.
func Width(s string) int {
return runewidth.StringWidth(cleanANSI(s))
}
// Ellipsis truncates a string to a given number of runes with an ellipsis at the end.
// It tries to persist the ANSI escape sequences.
func Ellipsis(s string, length int) string {
out := make([]rune, 0, length)
ln := 0
inEscape := false
tooLong := false
for _, r := range s {
if r == '\x1b' {
out = append(out, r)
inEscape = true
continue
}
if inEscape {
out = append(out, r)
if r == 'm' {
inEscape = false
if tooLong {
break
}
}
continue
}
ln += 1
if ln == length {
tooLong = true
}
if !tooLong {
out = append(out, r)
}
}
if tooLong {
return string(out) + "…"
}
return string(out)
}

39
vendor/github.com/docker/cli/internal/tui/note.go generated vendored Normal file
View File

@ -0,0 +1,39 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
import (
"fmt"
"strings"
"github.com/morikuni/aec"
)
var InfoHeader = Str{
Plain: " Info -> ",
Fancy: aec.Bold.Apply(aec.LightCyanB.Apply(aec.BlackF.Apply("i")) + " " + aec.LightCyanF.Apply("Info → ")),
}
func (o Output) PrintNote(format string, args ...any) {
if o.isTerminal {
// TODO: Handle all flags
format = strings.ReplaceAll(format, "--platform", ColorFlag.Apply("--platform"))
}
header := o.Sprint(InfoHeader)
_, _ = fmt.Fprint(o, "\n", header)
s := fmt.Sprintf(format, args...)
for idx, line := range strings.Split(s, "\n") {
if idx > 0 {
_, _ = fmt.Fprint(o, strings.Repeat(" ", Width(header)))
}
l := line
if o.isTerminal {
l = aec.Italic.Apply(l)
}
_, _ = fmt.Fprintln(o, l)
}
}

62
vendor/github.com/docker/cli/internal/tui/output.go generated vendored Normal file
View File

@ -0,0 +1,62 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
import (
"fmt"
"github.com/docker/cli/cli/streams"
"github.com/morikuni/aec"
)
type Output struct {
*streams.Out
isTerminal bool
}
type terminalPrintable interface {
String(isTerminal bool) string
}
func NewOutput(out *streams.Out) Output {
return Output{
Out: out,
isTerminal: out.IsTerminal(),
}
}
func (o Output) Color(clr aec.ANSI) aec.ANSI {
if o.isTerminal {
return clr
}
return ColorNone
}
func (o Output) Sprint(all ...any) string {
var out []any
for _, p := range all {
if s, ok := p.(terminalPrintable); ok {
out = append(out, s.String(o.isTerminal))
} else {
out = append(out, p)
}
}
return fmt.Sprint(out...)
}
func (o Output) PrintlnWithColor(clr aec.ANSI, args ...any) {
msg := o.Sprint(args...)
if o.isTerminal {
msg = clr.Apply(msg)
}
_, _ = fmt.Fprintln(o.Out, msg)
}
func (o Output) Println(p ...any) {
_, _ = fmt.Fprintln(o.Out, o.Sprint(p...))
}
func (o Output) Print(p ...any) {
_, _ = fmt.Print(o.Out, o.Sprint(p...))
}

19
vendor/github.com/docker/cli/internal/tui/str.go generated vendored Normal file
View File

@ -0,0 +1,19 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package tui
type Str struct {
// Fancy is the fancy string representation of the string.
Fancy string
// Plain is the plain string representation of the string.
Plain string
}
func (p Str) String(isTerminal bool) string {
if isTerminal {
return p.Fancy
}
return p.Plain
}