Skip to content

Commit 89506d6

Browse files
authored
Merge pull request #3340 from Ankitasw/fix-lint-issues
Fix lint errors due to golangci-lint bump
2 parents 0babdf1 + a903f9d commit 89506d6

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525
github.com/spf13/cobra v1.4.0
2626
github.com/spf13/pflag v1.0.5
2727
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
28+
golang.org/x/text v0.3.7
2829
gopkg.in/yaml.v2 v2.4.0
2930
k8s.io/api v0.23.0
3031
k8s.io/apiextensions-apiserver v0.23.0
@@ -125,7 +126,6 @@ require (
125126
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
126127
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
127128
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
128-
golang.org/x/text v0.3.7 // indirect
129129
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
130130
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
131131
google.golang.org/appengine v1.6.7 // indirect

pkg/record/recorder.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ limitations under the License.
1717
package record
1818

1919
import (
20-
"strings"
2120
"sync"
2221

22+
"golang.org/x/text/cases"
23+
"golang.org/x/text/language"
2324
corev1 "k8s.io/api/core/v1"
2425
runtime "k8s.io/apimachinery/pkg/runtime"
2526
cgrecord "k8s.io/client-go/tools/record"
@@ -44,20 +45,26 @@ func InitFromRecorder(recorder cgrecord.EventRecorder) {
4445

4546
// Event constructs an event from the given information and puts it in the queue for sending.
4647
func Event(object runtime.Object, reason, message string) {
47-
defaultRecorder.Event(object, corev1.EventTypeNormal, strings.Title(reason), message)
48+
defaultRecorder.Event(object, corev1.EventTypeNormal, title(reason), message)
4849
}
4950

5051
// Eventf is just like Event, but with Sprintf for the message field.
5152
func Eventf(object runtime.Object, reason, message string, args ...interface{}) {
52-
defaultRecorder.Eventf(object, corev1.EventTypeNormal, strings.Title(reason), message, args...)
53+
defaultRecorder.Eventf(object, corev1.EventTypeNormal, title(reason), message, args...)
5354
}
5455

5556
// Warn constructs a warning event from the given information and puts it in the queue for sending.
5657
func Warn(object runtime.Object, reason, message string) {
57-
defaultRecorder.Event(object, corev1.EventTypeWarning, strings.Title(reason), message)
58+
defaultRecorder.Event(object, corev1.EventTypeWarning, title(reason), message)
5859
}
5960

6061
// Warnf is just like Event, but with Sprintf for the message field.
6162
func Warnf(object runtime.Object, reason, message string, args ...interface{}) {
62-
defaultRecorder.Eventf(object, corev1.EventTypeWarning, strings.Title(reason), message, args...)
63+
defaultRecorder.Eventf(object, corev1.EventTypeWarning, title(reason), message, args...)
64+
}
65+
66+
// title returns a copy of the string s with all Unicode letters that begin words
67+
// mapped to their Unicode title case.
68+
func title(source string) string {
69+
return cases.Title(language.Und, cases.NoLower).String(source)
6370
}

test/helpers/external/cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ limitations under the License.
1717
package external
1818

1919
import (
20-
"strings"
21-
20+
"golang.org/x/text/cases"
21+
"golang.org/x/text/language"
2222
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/utils/pointer"
@@ -50,7 +50,7 @@ func generateTestClusterAPICRD(kind, pluralKind string) *apiextensionsv1.CustomR
5050
Group: "cluster.x-k8s.io",
5151
Scope: apiextensionsv1.NamespaceScoped,
5252
Names: apiextensionsv1.CustomResourceDefinitionNames{
53-
Kind: strings.Title(kind),
53+
Kind: cases.Title(language.Und, cases.NoLower).String(kind),
5454
Plural: pluralKind,
5555
},
5656
Versions: []apiextensionsv1.CustomResourceDefinitionVersion{

0 commit comments

Comments
 (0)