github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/fake/fake.go (about) 1 package fake 2 3 import ( 4 "context" 5 "io" 6 "time" 7 8 enginetypes "github.com/projecteru2/core/engine/types" 9 resourcetypes "github.com/projecteru2/core/resource/types" 10 coresource "github.com/projecteru2/core/source" 11 ) 12 13 // EngineWithErr use to mock the nil engine 14 type EngineWithErr struct { 15 DefaultErr error 16 } 17 18 // Info . 19 func (f *EngineWithErr) Info(_ context.Context) (*enginetypes.Info, error) { 20 return nil, f.DefaultErr 21 } 22 23 // Ping . 24 func (f *EngineWithErr) Ping(_ context.Context) error { 25 return f.DefaultErr 26 } 27 28 // CloseConn . 29 func (f *EngineWithErr) CloseConn() error { 30 return nil 31 } 32 33 // Execute . 34 func (f *EngineWithErr) Execute(context.Context, string, *enginetypes.ExecConfig) (execID string, stdout, stderr io.ReadCloser, stdin io.WriteCloser, err error) { 35 return "", nil, nil, nil, f.DefaultErr 36 } 37 38 // ExecResize . 39 func (f *EngineWithErr) ExecResize(context.Context, string, uint, uint) (err error) { 40 return f.DefaultErr 41 } 42 43 // ExecExitCode . 44 func (f *EngineWithErr) ExecExitCode(context.Context, string, string) (int, error) { 45 return 0, f.DefaultErr 46 } 47 48 // NetworkConnect . 49 func (f *EngineWithErr) NetworkConnect(context.Context, string, string, string, string) ([]string, error) { 50 return nil, f.DefaultErr 51 } 52 53 // NetworkDisconnect . 54 func (f *EngineWithErr) NetworkDisconnect(context.Context, string, string, bool) error { 55 return f.DefaultErr 56 } 57 58 // NetworkList . 59 func (f *EngineWithErr) NetworkList(context.Context, []string) ([]*enginetypes.Network, error) { 60 return nil, f.DefaultErr 61 } 62 63 // ImageList . 64 func (f *EngineWithErr) ImageList(context.Context, string) ([]*enginetypes.Image, error) { 65 return nil, f.DefaultErr 66 } 67 68 // ImageRemove . 69 func (f *EngineWithErr) ImageRemove(context.Context, string, bool, bool) ([]string, error) { 70 return nil, f.DefaultErr 71 } 72 73 // ImagesPrune . 74 func (f *EngineWithErr) ImagesPrune(context.Context) error { 75 return f.DefaultErr 76 } 77 78 // ImagePull . 79 func (f *EngineWithErr) ImagePull(context.Context, string, bool) (io.ReadCloser, error) { 80 return nil, f.DefaultErr 81 } 82 83 // ImagePush . 84 func (f *EngineWithErr) ImagePush(context.Context, string) (io.ReadCloser, error) { 85 return nil, f.DefaultErr 86 } 87 88 // ImageBuild . 89 func (f *EngineWithErr) ImageBuild(context.Context, io.Reader, []string, string) (io.ReadCloser, error) { 90 return nil, f.DefaultErr 91 } 92 93 // ImageBuildCachePrune . 94 func (f *EngineWithErr) ImageBuildCachePrune(context.Context, bool) (uint64, error) { 95 return 0, f.DefaultErr 96 } 97 98 // ImageLocalDigests . 99 func (f *EngineWithErr) ImageLocalDigests(context.Context, string) ([]string, error) { 100 return nil, f.DefaultErr 101 } 102 103 // ImageRemoteDigest . 104 func (f *EngineWithErr) ImageRemoteDigest(context.Context, string) (string, error) { 105 return "", f.DefaultErr 106 } 107 108 // ImageBuildFromExist . 109 func (f *EngineWithErr) ImageBuildFromExist(context.Context, string, []string, string) (string, error) { 110 return "", f.DefaultErr 111 } 112 113 // BuildRefs . 114 func (f *EngineWithErr) BuildRefs(context.Context, *enginetypes.BuildRefOptions) []string { 115 return nil 116 } 117 118 // BuildContent . 119 func (f *EngineWithErr) BuildContent(context.Context, coresource.Source, *enginetypes.BuildContentOptions) (string, io.Reader, error) { 120 return "", nil, f.DefaultErr 121 } 122 123 // VirtualizationCreate . 124 func (f *EngineWithErr) VirtualizationCreate(context.Context, *enginetypes.VirtualizationCreateOptions) (*enginetypes.VirtualizationCreated, error) { 125 return nil, f.DefaultErr 126 } 127 128 // VirtualizationCopyTo . 129 func (f *EngineWithErr) VirtualizationCopyTo(context.Context, string, string, []byte, int, int, int64) error { 130 return f.DefaultErr 131 } 132 133 // VirtualizationCopyChunkTo . 134 func (f *EngineWithErr) VirtualizationCopyChunkTo(context.Context, string, string, int64, io.Reader, int, int, int64) error { 135 return f.DefaultErr 136 } 137 138 // VirtualizationStart . 139 func (f *EngineWithErr) VirtualizationStart(context.Context, string) error { 140 return f.DefaultErr 141 } 142 143 // VirtualizationStop . 144 func (f *EngineWithErr) VirtualizationStop(context.Context, string, time.Duration) error { 145 return f.DefaultErr 146 } 147 148 // VirtualizationSuspend . 149 func (f *EngineWithErr) VirtualizationSuspend(context.Context, string) error { 150 return f.DefaultErr 151 } 152 153 // VirtualizationResume . 154 func (f *EngineWithErr) VirtualizationResume(context.Context, string) error { 155 return f.DefaultErr 156 } 157 158 // VirtualizationRemove . 159 func (f *EngineWithErr) VirtualizationRemove(context.Context, string, bool, bool) error { 160 return f.DefaultErr 161 } 162 163 func (f *EngineWithErr) RawEngine(context.Context, *enginetypes.RawEngineOptions) (*enginetypes.RawEngineResult, error) { 164 return nil, f.DefaultErr 165 } 166 167 // VirtualizationInspect . 168 func (f *EngineWithErr) VirtualizationInspect(context.Context, string) (*enginetypes.VirtualizationInfo, error) { 169 return nil, f.DefaultErr 170 } 171 172 // VirtualizationLogs . 173 func (f *EngineWithErr) VirtualizationLogs(context.Context, *enginetypes.VirtualizationLogStreamOptions) (stdout, stderr io.ReadCloser, err error) { 174 return nil, nil, f.DefaultErr 175 } 176 177 // VirtualizationAttach . 178 func (f *EngineWithErr) VirtualizationAttach(context.Context, string, bool, bool) (stdout, stderr io.ReadCloser, stdin io.WriteCloser, err error) { 179 return nil, nil, nil, f.DefaultErr 180 } 181 182 // VirtualizationResize . 183 func (f *EngineWithErr) VirtualizationResize(context.Context, string, uint, uint) error { 184 return f.DefaultErr 185 } 186 187 // VirtualizationWait . 188 func (f *EngineWithErr) VirtualizationWait(context.Context, string, string) (*enginetypes.VirtualizationWaitResult, error) { 189 return nil, f.DefaultErr 190 } 191 192 // VirtualizationUpdateResource . 193 func (f *EngineWithErr) VirtualizationUpdateResource(context.Context, string, resourcetypes.Resources) error { 194 return f.DefaultErr 195 } 196 197 // VirtualizationCopyFrom . 198 func (f *EngineWithErr) VirtualizationCopyFrom(context.Context, string, string) (content []byte, uid, gid int, mode int64, _ error) { 199 return nil, 0, 0, 0, f.DefaultErr 200 }