github.com/google/cadvisor@v0.49.1/container/container.go (about)

     1  // Copyright 2014 Google Inc. All Rights Reserved.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Package container defines types for sub-container events and also
    16  // defines an interface for container operation handlers.
    17  package container
    18  
    19  import info "github.com/google/cadvisor/info/v1"
    20  
    21  // ListType describes whether listing should be just for a
    22  // specific container or performed recursively.
    23  type ListType int
    24  
    25  const (
    26  	ListSelf ListType = iota
    27  	ListRecursive
    28  )
    29  
    30  type ContainerType int
    31  
    32  const (
    33  	ContainerTypeRaw ContainerType = iota
    34  	ContainerTypeDocker
    35  	ContainerTypeCrio
    36  	ContainerTypeContainerd
    37  	ContainerTypeMesos
    38  	ContainerTypePodman
    39  )
    40  
    41  // Interface for container operation handlers.
    42  type ContainerHandler interface {
    43  	// Returns the ContainerReference
    44  	ContainerReference() (info.ContainerReference, error)
    45  
    46  	// Returns container's isolation spec.
    47  	GetSpec() (info.ContainerSpec, error)
    48  
    49  	// Returns the current stats values of the container.
    50  	GetStats() (*info.ContainerStats, error)
    51  
    52  	// Returns the subcontainers of this container.
    53  	ListContainers(listType ListType) ([]info.ContainerReference, error)
    54  
    55  	// Returns the processes inside this container.
    56  	ListProcesses(listType ListType) ([]int, error)
    57  
    58  	// Returns absolute cgroup path for the requested resource.
    59  	GetCgroupPath(resource string) (string, error)
    60  
    61  	// Returns container labels, if available.
    62  	GetContainerLabels() map[string]string
    63  
    64  	// Returns the container's ip address, if available
    65  	GetContainerIPAddress() string
    66  
    67  	// Returns whether the container still exists.
    68  	Exists() bool
    69  
    70  	// Cleanup frees up any resources being held like fds or go routines, etc.
    71  	Cleanup()
    72  
    73  	// Start starts any necessary background goroutines - must be cleaned up in Cleanup().
    74  	// It is expected that most implementations will be a no-op.
    75  	Start()
    76  
    77  	// Type of handler
    78  	Type() ContainerType
    79  }