@@ -17,9 +17,10 @@ limitations under the License.
17
17
package record
18
18
19
19
import (
20
- "strings"
21
20
"sync"
22
21
22
+ "golang.org/x/text/cases"
23
+ "golang.org/x/text/language"
23
24
corev1 "k8s.io/api/core/v1"
24
25
runtime "k8s.io/apimachinery/pkg/runtime"
25
26
cgrecord "k8s.io/client-go/tools/record"
@@ -44,20 +45,26 @@ func InitFromRecorder(recorder cgrecord.EventRecorder) {
44
45
45
46
// Event constructs an event from the given information and puts it in the queue for sending.
46
47
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 )
48
49
}
49
50
50
51
// Eventf is just like Event, but with Sprintf for the message field.
51
52
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 ... )
53
54
}
54
55
55
56
// Warn constructs a warning event from the given information and puts it in the queue for sending.
56
57
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 )
58
59
}
59
60
60
61
// Warnf is just like Event, but with Sprintf for the message field.
61
62
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 )
63
70
}
0 commit comments