diff --git a/cmd/flux/get_alert.go b/cmd/flux/get_alert.go index 9137e90e..9ea6c682 100644 --- a/cmd/flux/get_alert.go +++ b/cmd/flux/get_alert.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" notificationv1 "github.com/fluxcd/notification-controller/api/v1beta2" @@ -77,7 +78,8 @@ func init() { func (s alertListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string { item := s.Items[i] status, msg := statusAndMessage(item.Status.Conditions) - return append(nameColumns(&item, includeNamespace, includeKind), strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + return append(nameColumns(&item, includeNamespace, includeKind), + cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (s alertListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_helmrelease.go b/cmd/flux/get_helmrelease.go index fd709d29..d6462ddd 100644 --- a/cmd/flux/get_helmrelease.go +++ b/cmd/flux/get_helmrelease.go @@ -19,11 +19,13 @@ package main import ( "fmt" "strconv" - "strings" - helmv2 "github.com/fluxcd/helm-controller/api/v2beta1" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" + + helmv2 "github.com/fluxcd/helm-controller/api/v2beta1" ) var getHelmReleaseCmd = &cobra.Command{ @@ -75,7 +77,7 @@ func (a helmReleaseListAdapter) summariseItem(i int, includeNamespace bool, incl revision := item.Status.LastAppliedRevision status, msg := statusAndMessage(item.Status.Conditions) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a helmReleaseListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_image_repository.go b/cmd/flux/get_image_repository.go index 0f6f95a6..e160de8d 100644 --- a/cmd/flux/get_image_repository.go +++ b/cmd/flux/get_image_repository.go @@ -19,10 +19,11 @@ package main import ( "fmt" "strconv" - "strings" "time" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" imagev1 "github.com/fluxcd/image-reflector-controller/api/v1beta2" @@ -82,7 +83,7 @@ func (s imageRepositoryListAdapter) summariseItem(i int, includeNamespace bool, lastScan = item.Status.LastScanResult.ScanTime.Time.Format(time.RFC3339) } return append(nameColumns(&item, includeNamespace, includeKind), - lastScan, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + lastScan, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (s imageRepositoryListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_image_update.go b/cmd/flux/get_image_update.go index 833be4ab..62399626 100644 --- a/cmd/flux/get_image_update.go +++ b/cmd/flux/get_image_update.go @@ -19,10 +19,11 @@ package main import ( "fmt" "strconv" - "strings" "time" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1" @@ -81,7 +82,8 @@ func (s imageUpdateAutomationListAdapter) summariseItem(i int, includeNamespace if item.Status.LastAutomationRunTime != nil { lastRun = item.Status.LastAutomationRunTime.Time.Format(time.RFC3339) } - return append(nameColumns(&item, includeNamespace, includeKind), lastRun, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + return append(nameColumns(&item, includeNamespace, includeKind), lastRun, + cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (s imageUpdateAutomationListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_kustomization.go b/cmd/flux/get_kustomization.go index 517aa375..a95ec655 100644 --- a/cmd/flux/get_kustomization.go +++ b/cmd/flux/get_kustomization.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1" @@ -83,7 +84,7 @@ func (a kustomizationListAdapter) summariseItem(i int, includeNamespace bool, in revision = utils.TruncateHex(revision) msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a kustomizationListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_receiver.go b/cmd/flux/get_receiver.go index a72d0765..43f8f5a4 100644 --- a/cmd/flux/get_receiver.go +++ b/cmd/flux/get_receiver.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" notificationv1 "github.com/fluxcd/notification-controller/api/v1" @@ -74,7 +75,8 @@ func init() { func (s receiverListAdapter) summariseItem(i int, includeNamespace bool, includeKind bool) []string { item := s.Items[i] status, msg := statusAndMessage(item.Status.Conditions) - return append(nameColumns(&item, includeNamespace, includeKind), strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + return append(nameColumns(&item, includeNamespace, includeKind), + cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (s receiverListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_source_bucket.go b/cmd/flux/get_source_bucket.go index b21ee223..b7355fdb 100644 --- a/cmd/flux/get_source_bucket.go +++ b/cmd/flux/get_source_bucket.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" @@ -85,7 +86,7 @@ func (a *bucketListAdapter) summariseItem(i int, includeNamespace bool, includeK revision = utils.TruncateHex(revision) msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a bucketListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_source_chart.go b/cmd/flux/get_source_chart.go index e83839cb..b82bdd78 100644 --- a/cmd/flux/get_source_chart.go +++ b/cmd/flux/get_source_chart.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" @@ -86,7 +87,7 @@ func (a *helmChartListAdapter) summariseItem(i int, includeNamespace bool, inclu // Message may still contain reference of e.g. commit chart was build from msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a helmChartListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_source_git.go b/cmd/flux/get_source_git.go index 3c71da1c..78476de5 100644 --- a/cmd/flux/get_source_git.go +++ b/cmd/flux/get_source_git.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" sourcev1 "github.com/fluxcd/source-controller/api/v1" @@ -85,7 +86,7 @@ func (a *gitRepositoryListAdapter) summariseItem(i int, includeNamespace bool, i revision = utils.TruncateHex(revision) msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a gitRepositoryListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_source_helm.go b/cmd/flux/get_source_helm.go index 28315eb7..173a1880 100644 --- a/cmd/flux/get_source_helm.go +++ b/cmd/flux/get_source_helm.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" @@ -85,7 +86,7 @@ func (a *helmRepositoryListAdapter) summariseItem(i int, includeNamespace bool, revision = utils.TruncateHex(revision) msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a helmRepositoryListAdapter) headers(includeNamespace bool) []string { diff --git a/cmd/flux/get_source_oci.go b/cmd/flux/get_source_oci.go index 36f93fc9..e5bbe409 100644 --- a/cmd/flux/get_source_oci.go +++ b/cmd/flux/get_source_oci.go @@ -19,9 +19,10 @@ package main import ( "fmt" "strconv" - "strings" "github.com/spf13/cobra" + "golang.org/x/text/cases" + "golang.org/x/text/language" "k8s.io/apimachinery/pkg/runtime" sourcev1 "github.com/fluxcd/source-controller/api/v1beta2" @@ -85,7 +86,7 @@ func (a *ociRepositoryListAdapter) summariseItem(i int, includeNamespace bool, i revision = utils.TruncateHex(revision) msg = utils.TruncateHex(msg) return append(nameColumns(&item, includeNamespace, includeKind), - revision, strings.Title(strconv.FormatBool(item.Spec.Suspend)), status, msg) + revision, cases.Title(language.English).String(strconv.FormatBool(item.Spec.Suspend)), status, msg) } func (a ociRepositoryListAdapter) headers(includeNamespace bool) []string { diff --git a/go.mod b/go.mod index 6dd1e45d..7875f9fe 100644 --- a/go.mod +++ b/go.mod @@ -48,6 +48,7 @@ require ( github.com/theckman/yacspin v0.13.12 golang.org/x/crypto v0.14.0 golang.org/x/term v0.13.0 + golang.org/x/text v0.13.0 k8s.io/api v0.27.4 k8s.io/apiextensions-apiserver v0.27.4 k8s.io/apimachinery v0.27.4 @@ -195,7 +196,6 @@ require ( golang.org/x/oauth2 v0.13.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect