Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.

Commit b9cb0b2

Browse files
committed
Fix lint error.
Signed-off-by: Lantao Liu <[email protected]>
1 parent 0e24a83 commit b9cb0b2

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

pkg/server/events.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ func convertEvent(e *gogotypes.Any) (string, interface{}, error) {
106106
return "", nil, errors.Wrap(err, "failed to unmarshalany")
107107
}
108108

109-
switch evt.(type) {
109+
switch e := evt.(type) {
110110
case *eventtypes.TaskExit:
111-
containerID = evt.(*eventtypes.TaskExit).ContainerID
111+
containerID = e.ContainerID
112112
case *eventtypes.TaskOOM:
113-
containerID = evt.(*eventtypes.TaskOOM).ContainerID
113+
containerID = e.ContainerID
114114
default:
115115
return "", nil, errors.New("unsupported event")
116116
}
@@ -185,13 +185,12 @@ func (em *eventMonitor) stop() {
185185
// handleEvent handles a containerd event.
186186
func (em *eventMonitor) handleEvent(any interface{}) error {
187187
ctx := ctrdutil.NamespacedContext()
188-
switch any.(type) {
188+
switch e := any.(type) {
189189
// If containerd-shim exits unexpectedly, there will be no corresponding event.
190190
// However, containerd could not retrieve container state in that case, so it's
191191
// fine to leave out that case for now.
192192
// TODO(random-liu): [P2] Handle containerd-shim exit.
193193
case *eventtypes.TaskExit:
194-
e := any.(*eventtypes.TaskExit)
195194
cntr, err := em.containerStore.Get(e.ContainerID)
196195
if err == nil {
197196
if err := handleContainerExit(ctx, e, cntr); err != nil {
@@ -213,7 +212,6 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
213212
}
214213
return nil
215214
case *eventtypes.TaskOOM:
216-
e := any.(*eventtypes.TaskOOM)
217215
logrus.Infof("TaskOOM event %+v", e)
218216
cntr, err := em.containerStore.Get(e.ContainerID)
219217
if err != nil {

pkg/util/strings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import "strings"
2222
// Comparison is case insensitive.
2323
func InStringSlice(ss []string, str string) bool {
2424
for _, s := range ss {
25-
if strings.ToLower(s) == strings.ToLower(str) {
25+
if strings.EqualFold(s, str) {
2626
return true
2727
}
2828
}
@@ -34,7 +34,7 @@ func InStringSlice(ss []string, str string) bool {
3434
func SubtractStringSlice(ss []string, str string) []string {
3535
var res []string
3636
for _, s := range ss {
37-
if strings.ToLower(s) == strings.ToLower(str) {
37+
if strings.EqualFold(s, str) {
3838
continue
3939
}
4040
res = append(res, s)

0 commit comments

Comments
 (0)