...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package utils
17
18 import "fmt"
19
20 type failToFindContainer struct {
21 namespace string
22 name string
23 containerName string
24
25 err error
26 }
27
28 func NewFailToFindContainer(namespace string, name string, containerName string, err error) error {
29 return &failToFindContainer{
30 namespace,
31 name,
32 containerName,
33 err,
34 }
35 }
36
37 func (e *failToFindContainer) Error() string {
38 if e.err == nil {
39 return fmt.Sprintf("fail to find container %s on pod %s/%s", e.containerName, e.namespace, e.name)
40 }
41
42 return e.err.Error()
43 }
44
45 func IsFailToGet(e error) bool {
46 switch e.(type) {
47 case *failToFindContainer:
48 return true
49 default:
50 return false
51 }
52 }
53