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