-
Notifications
You must be signed in to change notification settings - Fork 57
/
mock_crane.go
71 lines (56 loc) · 1.41 KB
/
mock_crane.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package kaniko
import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/types"
)
func MockCraneLoad(path string, loadErr error) func(string) (v1.Image, error) {
return func(inputPath string) (v1.Image, error) {
if loadErr != nil {
return nil, loadErr
}
return &mockImage{}, nil
}
}
func MockCranePush(pushErr error) func(v1.Image, string) error {
return func(img v1.Image, dest string) error {
if pushErr != nil {
return pushErr
}
return nil
}
}
// mockImage is a mock implementation of v1.Image interface
type mockImage struct{}
func (m *mockImage) Size() (int64, error) {
return 0, nil
}
func (m *mockImage) RawConfigFile() ([]byte, error) {
return nil, nil
}
func (m *mockImage) Digest() (v1.Hash, error) {
return v1.Hash{}, nil
}
func (m *mockImage) Manifest() (*v1.Manifest, error) {
return nil, nil
}
func (m *mockImage) RawManifest() ([]byte, error) {
return nil, nil
}
func (m *mockImage) LayerByDigest(hash v1.Hash) (v1.Layer, error) {
return nil, nil
}
func (m *mockImage) LayerByDiffID(hash v1.Hash) (v1.Layer, error) {
return nil, nil
}
func (m *mockImage) Layers() ([]v1.Layer, error) {
return nil, nil
}
func (m *mockImage) MediaType() (types.MediaType, error) {
return "", nil
}
func (m *mockImage) ConfigFile() (*v1.ConfigFile, error) {
return nil, nil
}
func (m *mockImage) ConfigName() (v1.Hash, error) {
return v1.Hash{}, nil
}