github.com/aporeto-inc/trireme-lib@v10.358.0+incompatible/monitor/extractors/error.go (about)

     1  package extractors
     2  
     3  import (
     4  	"fmt"
     5  )
     6  
     7  type errNetclsAlreadyProgrammed struct {
     8  	mark string
     9  }
    10  
    11  func (e *errNetclsAlreadyProgrammed) Error() string {
    12  	return fmt.Sprintf("net_cls cgroup already programmed with mark %s", e.mark)
    13  }
    14  
    15  // ErrNetclsAlreadyProgrammed is returned from the NetclsProgrammer when the net_cls cgroup for this pod has already been programmed
    16  func ErrNetclsAlreadyProgrammed(mark string) error {
    17  	return &errNetclsAlreadyProgrammed{mark: mark}
    18  }
    19  
    20  // ErrNoHostNetworkPod is returned from the NetclsProgrammer if the given pod is not a host network pod.
    21  var ErrNoHostNetworkPod = fmt.Errorf("pod is not a host network pod")
    22  
    23  // IsErrNetclsAlreadyProgrammed checks if the provided error is an ErrNetclsAlreadyProgrammed error
    24  func IsErrNetclsAlreadyProgrammed(err error) bool {
    25  	switch err.(type) {
    26  	case *errNetclsAlreadyProgrammed:
    27  		return true
    28  	default:
    29  		return false
    30  	}
    31  }
    32  
    33  // IsErrNoHostNetworkPod checks if the provided error is an ErrNoHostNetworkPod error
    34  func IsErrNoHostNetworkPod(err error) bool {
    35  	return err.Error() == ErrNoHostNetworkPod.Error()
    36  }