github.com/demonoid81/containerd@v1.3.4/runtime/v2/runc/util.go (about)

     1  // +build linux
     2  
     3  /*
     4     Copyright The containerd Authors.
     5  
     6     Licensed under the Apache License, Version 2.0 (the "License");
     7     you may not use this file except in compliance with the License.
     8     You may obtain a copy of the License at
     9  
    10         http://www.apache.org/licenses/LICENSE-2.0
    11  
    12     Unless required by applicable law or agreed to in writing, software
    13     distributed under the License is distributed on an "AS IS" BASIS,
    14     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15     See the License for the specific language governing permissions and
    16     limitations under the License.
    17  */
    18  
    19  package runc
    20  
    21  import (
    22  	"github.com/containerd/containerd/api/events"
    23  	"github.com/containerd/containerd/runtime"
    24  	"github.com/sirupsen/logrus"
    25  )
    26  
    27  // GetTopic converts an event from an interface type to the specific
    28  // event topic id
    29  func GetTopic(e interface{}) string {
    30  	switch e.(type) {
    31  	case *events.TaskCreate:
    32  		return runtime.TaskCreateEventTopic
    33  	case *events.TaskStart:
    34  		return runtime.TaskStartEventTopic
    35  	case *events.TaskOOM:
    36  		return runtime.TaskOOMEventTopic
    37  	case *events.TaskExit:
    38  		return runtime.TaskExitEventTopic
    39  	case *events.TaskDelete:
    40  		return runtime.TaskDeleteEventTopic
    41  	case *events.TaskExecAdded:
    42  		return runtime.TaskExecAddedEventTopic
    43  	case *events.TaskExecStarted:
    44  		return runtime.TaskExecStartedEventTopic
    45  	case *events.TaskPaused:
    46  		return runtime.TaskPausedEventTopic
    47  	case *events.TaskResumed:
    48  		return runtime.TaskResumedEventTopic
    49  	case *events.TaskCheckpointed:
    50  		return runtime.TaskCheckpointedEventTopic
    51  	default:
    52  		logrus.Warnf("no topic for type %#v", e)
    53  	}
    54  	return runtime.TaskUnknownTopic
    55  }