Skip to content

Commit 092eddc

Browse files
committed
Address deprecation of Strings.Title
By using golang.org/x/text/cases
1 parent 9059543 commit 092eddc

File tree

19 files changed

+15958
-6
lines changed

19 files changed

+15958
-6
lines changed

cmd/crictl/sandbox.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"github.com/docker/go-units"
2929
"github.com/sirupsen/logrus"
3030
"github.com/urfave/cli/v2"
31+
"golang.org/x/text/cases"
32+
"golang.org/x/text/language"
3133

3234
errorUtils "k8s.io/apimachinery/pkg/util/errors"
3335
internalapi "k8s.io/cri-api/pkg/apis"
@@ -509,6 +511,7 @@ func ListPodSandboxes(client internalapi.RuntimeService, opts listOptions) error
509511
columnPodRuntime,
510512
})
511513
}
514+
c := cases.Title(language.Und)
512515
for _, pod := range r {
513516
if opts.quiet {
514517
fmt.Printf("%s\n", pod.Id)
@@ -564,7 +567,7 @@ func ListPodSandboxes(client internalapi.RuntimeService, opts listOptions) error
564567
}
565568
}
566569
fmt.Printf("%s: %s\n",
567-
strings.Title(strings.ToLower(columnPodRuntime)),
570+
c.String(columnPodRuntime),
568571
getSandboxesRuntimeHandler(pod))
569572

570573
fmt.Println()

cmd/crictl/templates.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,21 @@ import (
2020
"bytes"
2121
"encoding/json"
2222
"fmt"
23-
"strings"
2423
"text/template"
24+
25+
"golang.org/x/text/cases"
26+
"golang.org/x/text/language"
2527
)
2628

2729
func builtinTmplFuncs() template.FuncMap {
30+
t := cases.Title(language.Und)
31+
l := cases.Lower(language.Und)
32+
u := cases.Upper(language.Und)
2833
return template.FuncMap{
2934
"json": jsonBuiltinTmplFunc,
30-
"title": strings.Title,
31-
"lower": strings.ToLower,
32-
"upper": strings.ToUpper,
35+
"title": t.String,
36+
"lower": l.String,
37+
"upper": u.String,
3338
}
3439
}
3540

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
golang.org/x/net v0.15.0
2020
golang.org/x/sys v0.12.0
2121
golang.org/x/term v0.12.0
22+
golang.org/x/text v0.13.0
2223
gopkg.in/yaml.v3 v3.0.1
2324
k8s.io/api v0.0.0
2425
k8s.io/apimachinery v0.0.0
@@ -83,7 +84,6 @@ require (
8384
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
8485
golang.org/x/mod v0.12.0 // indirect
8586
golang.org/x/oauth2 v0.8.0 // indirect
86-
golang.org/x/text v0.13.0 // indirect
8787
golang.org/x/time v0.3.0 // indirect
8888
golang.org/x/tools v0.12.0 // indirect
8989
google.golang.org/appengine v1.6.7 // indirect

vendor/golang.org/x/text/cases/cases.go

Lines changed: 162 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)