mirror of https://github.com/fluxcd/cli-utils.git
Adapt code for Go 1.24
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
parent
e4d37591ee
commit
1b2e2ef584
|
|
@ -7,9 +7,6 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/apis/actuation"
|
||||
"github.com/fluxcd/cli-utils/pkg/common"
|
||||
"github.com/fluxcd/cli-utils/pkg/object"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
|
@ -20,6 +17,10 @@ import (
|
|||
"k8s.io/cli-runtime/pkg/resource"
|
||||
clienttesting "k8s.io/client-go/testing"
|
||||
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/apis/actuation"
|
||||
"github.com/fluxcd/cli-utils/pkg/common"
|
||||
"github.com/fluxcd/cli-utils/pkg/object"
|
||||
)
|
||||
|
||||
func podStatus(info *resource.Info) actuation.ObjectStatus {
|
||||
|
|
@ -411,7 +412,7 @@ func TestReplace(t *testing.T) {
|
|||
t.Fatalf("unexpected error received: %s", err)
|
||||
}
|
||||
if diff := cmp.Diff(data, tc.data); diff != "" {
|
||||
t.Fatalf(diff)
|
||||
t.Fatal(diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ package inventory
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/apis/actuation"
|
||||
"github.com/fluxcd/cli-utils/pkg/object"
|
||||
"github.com/google/go-cmp/cmp"
|
||||
)
|
||||
|
||||
func TestBuildObjMap(t *testing.T) {
|
||||
|
|
@ -65,7 +66,7 @@ func TestBuildObjMap(t *testing.T) {
|
|||
t.Run(name, func(t *testing.T) {
|
||||
actual := buildObjMap(tc.objSet, tc.objStatus)
|
||||
if diff := cmp.Diff(actual, tc.expected); diff != "" {
|
||||
t.Errorf(diff)
|
||||
t.Error(diff)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,11 @@ import (
|
|||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
|
||||
pe "github.com/fluxcd/cli-utils/pkg/kstatus/polling/event"
|
||||
"github.com/fluxcd/cli-utils/pkg/object"
|
||||
"github.com/fluxcd/cli-utils/pkg/print/common"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
)
|
||||
|
||||
// ColumnDefinition defines the columns that should be printed.
|
||||
|
|
@ -79,7 +80,7 @@ func (t *BaseTablePrinter) PrintTable(rs ResourceStates,
|
|||
panic(err)
|
||||
}
|
||||
remainingSpace := column.Width() - written
|
||||
t.printOrDie(strings.Repeat(" ", remainingSpace))
|
||||
t.printOrDie("%s", strings.Repeat(" ", remainingSpace))
|
||||
if i == len(t.Columns)-1 {
|
||||
t.printOrDie("\n")
|
||||
linePrintCount++
|
||||
|
|
@ -105,9 +106,9 @@ func (t *BaseTablePrinter) printSubTable(resources []Resource,
|
|||
availableWidth := column.Width()
|
||||
if column.Name() == "resource" {
|
||||
if j < len(resources)-1 {
|
||||
t.printOrDie(prefix + `├─ `)
|
||||
t.printOrDie("%s", prefix+`├─ `)
|
||||
} else {
|
||||
t.printOrDie(prefix + `└─ `)
|
||||
t.printOrDie("%s", prefix+`└─ `)
|
||||
}
|
||||
availableWidth -= utf8.RuneCountInString(prefix) + 3
|
||||
}
|
||||
|
|
@ -117,7 +118,7 @@ func (t *BaseTablePrinter) printSubTable(resources []Resource,
|
|||
panic(err)
|
||||
}
|
||||
remainingSpace := availableWidth - written
|
||||
t.printOrDie(strings.Repeat(" ", remainingSpace))
|
||||
t.printOrDie("%s", strings.Repeat(" ", remainingSpace))
|
||||
if i == len(t.Columns)-1 {
|
||||
t.printOrDie("\n")
|
||||
linePrintCount++
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ import (
|
|||
"io"
|
||||
"time"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/print/common"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/utils/integer"
|
||||
|
||||
"github.com/fluxcd/cli-utils/pkg/print/common"
|
||||
)
|
||||
|
||||
// ColumnDef is an implementation of the ColumnDefinition interface.
|
||||
|
|
@ -111,7 +112,7 @@ var (
|
|||
color, setColor := common.ColorForStatus(rs.Status)
|
||||
var outputStatus string
|
||||
if setColor {
|
||||
outputStatus = common.SprintfWithColor(color, s)
|
||||
outputStatus = common.SprintfWithColor(color, "%s", s)
|
||||
} else {
|
||||
outputStatus = s
|
||||
}
|
||||
|
|
@ -160,7 +161,7 @@ var (
|
|||
if len(conditionType) > remainingWidth {
|
||||
conditionType = conditionType[:remainingWidth]
|
||||
}
|
||||
_, err := fmt.Fprint(w, common.SprintfWithColor(color, conditionType))
|
||||
_, err := fmt.Fprint(w, common.SprintfWithColor(color, "%s", conditionType))
|
||||
if err != nil {
|
||||
return realLength, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue