@@ -3,12 +3,35 @@ package container
33import (
44 "context"
55 "io"
6+ "reflect"
7+ "strings"
8+ "unsafe"
69
7- "github.com/moby/moby/api/types/container"
8- "github.com/moby/moby/api/types/system"
910 "github.com/moby/moby/client"
1011)
1112
13+ func mockContainerExportResult (content string ) client.ContainerExportResult {
14+ out := client.ContainerExportResult {}
15+
16+ // Set unexported field "rc"
17+ v := reflect .ValueOf (& out ).Elem ()
18+ f := v .FieldByName ("rc" )
19+ r := io .NopCloser (strings .NewReader (content ))
20+ reflect .NewAt (f .Type (), unsafe .Pointer (f .UnsafeAddr ())).Elem ().Set (reflect .ValueOf (r ))
21+ return out
22+ }
23+
24+ func mockContainerLogsResult (content string ) client.ContainerLogsResult {
25+ out := client.ContainerLogsResult {}
26+
27+ // Set unexported field "rc"
28+ v := reflect .ValueOf (& out ).Elem ()
29+ f := v .FieldByName ("rc" )
30+ r := io .NopCloser (strings .NewReader (content ))
31+ reflect .NewAt (f .Type (), unsafe .Pointer (f .UnsafeAddr ())).Elem ().Set (reflect .ValueOf (r ))
32+ return out
33+ }
34+
1235type fakeClient struct {
1336 client.Client
1437 inspectFunc func (string ) (client.ContainerInspectResult , error )
@@ -17,13 +40,13 @@ type fakeClient struct {
1740 createContainerFunc func (options client.ContainerCreateOptions ) (client.ContainerCreateResult , error )
1841 containerStartFunc func (containerID string , options client.ContainerStartOptions ) (client.ContainerStartResult , error )
1942 imageCreateFunc func (ctx context.Context , parentReference string , options client.ImageCreateOptions ) (client.ImageCreateResult , error )
20- infoFunc func () (system. Info , error )
21- containerStatPathFunc func (containerID , path string ) (container. PathStat , error )
22- containerCopyFromFunc func (containerID , srcPath string ) (io. ReadCloser , container. PathStat , error )
23- logFunc func (string , client.ContainerLogsOptions ) (io. ReadCloser , error )
24- waitFunc func (string ) ( <- chan container. WaitResponse , <- chan error )
25- containerListFunc func (client.ContainerListOptions ) ([]container. Summary , error )
26- containerExportFunc func (string ) (io. ReadCloser , error )
43+ infoFunc func () (client. SystemInfoResult , error )
44+ containerStatPathFunc func (containerID , path string ) (client. ContainerStatPathResult , error )
45+ containerCopyFromFunc func (containerID , srcPath string ) (client. CopyFromContainerResult , error )
46+ logFunc func (string , client.ContainerLogsOptions ) (client. ContainerLogsResult , error )
47+ waitFunc func (string ) client. ContainerWaitResult
48+ containerListFunc func (client.ContainerListOptions ) (client. ContainerListResult , error )
49+ containerExportFunc func (string ) (client. ContainerExportResult , error )
2750 containerExecResizeFunc func (id string , options client.ExecResizeOptions ) (client.ExecResizeResult , error )
2851 containerRemoveFunc func (ctx context.Context , containerID string , options client.ContainerRemoveOptions ) (client.ContainerRemoveResult , error )
2952 containerRestartFunc func (ctx context.Context , containerID string , options client.ContainerRestartOptions ) (client.ContainerRestartResult , error )
@@ -38,14 +61,14 @@ type fakeClient struct {
3861 Version string
3962}
4063
41- func (f * fakeClient ) ContainerList (_ context.Context , options client.ContainerListOptions ) ([]container. Summary , error ) {
64+ func (f * fakeClient ) ContainerList (_ context.Context , options client.ContainerListOptions ) (client. ContainerListResult , error ) {
4265 if f .containerListFunc != nil {
4366 return f .containerListFunc (options )
4467 }
45- return []container. Summary {}, nil
68+ return client. ContainerListResult {}, nil
4669}
4770
48- func (f * fakeClient ) ContainerInspect (_ context.Context , containerID string , options client.ContainerInspectOptions ) (client.ContainerInspectResult , error ) {
71+ func (f * fakeClient ) ContainerInspect (_ context.Context , containerID string , _ client.ContainerInspectOptions ) (client.ContainerInspectResult , error ) {
4972 if f .inspectFunc != nil {
5073 return f .inspectFunc (containerID )
5174 }
@@ -91,43 +114,43 @@ func (f *fakeClient) ImageCreate(ctx context.Context, parentReference string, op
91114 return client.ImageCreateResult {}, nil
92115}
93116
94- func (f * fakeClient ) Info (_ context.Context ) (system. Info , error ) {
117+ func (f * fakeClient ) Info (context.Context , client. InfoOptions ) (client. SystemInfoResult , error ) {
95118 if f .infoFunc != nil {
96119 return f .infoFunc ()
97120 }
98- return system. Info {}, nil
121+ return client. SystemInfoResult {}, nil
99122}
100123
101- func (f * fakeClient ) ContainerStatPath (_ context.Context , containerID , path string ) (container. PathStat , error ) {
124+ func (f * fakeClient ) ContainerStatPath (_ context.Context , containerID string , options client. ContainerStatPathOptions ) (client. ContainerStatPathResult , error ) {
102125 if f .containerStatPathFunc != nil {
103- return f .containerStatPathFunc (containerID , path )
126+ return f .containerStatPathFunc (containerID , options . Path )
104127 }
105- return container. PathStat {}, nil
128+ return client. ContainerStatPathResult {}, nil
106129}
107130
108- func (f * fakeClient ) CopyFromContainer (_ context.Context , containerID , srcPath string ) (io. ReadCloser , container. PathStat , error ) {
131+ func (f * fakeClient ) CopyFromContainer (_ context.Context , containerID string , options client. CopyFromContainerOptions ) (client. CopyFromContainerResult , error ) {
109132 if f .containerCopyFromFunc != nil {
110- return f .containerCopyFromFunc (containerID , srcPath )
133+ return f .containerCopyFromFunc (containerID , options . SourcePath )
111134 }
112- return nil , container. PathStat {}, nil
135+ return client. CopyFromContainerResult {}, nil
113136}
114137
115- func (f * fakeClient ) ContainerLogs (_ context.Context , containerID string , options client.ContainerLogsOptions ) (io. ReadCloser , error ) {
138+ func (f * fakeClient ) ContainerLogs (_ context.Context , containerID string , options client.ContainerLogsOptions ) (client. ContainerLogsResult , error ) {
116139 if f .logFunc != nil {
117140 return f .logFunc (containerID , options )
118141 }
119- return nil , nil
142+ return client. ContainerLogsResult {} , nil
120143}
121144
122145func (f * fakeClient ) ClientVersion () string {
123146 return f .Version
124147}
125148
126- func (f * fakeClient ) ContainerWait (_ context.Context , containerID string , _ container. WaitCondition ) ( <- chan container. WaitResponse , <- chan error ) {
149+ func (f * fakeClient ) ContainerWait (_ context.Context , containerID string , _ client. ContainerWaitOptions ) client. ContainerWaitResult {
127150 if f .waitFunc != nil {
128151 return f .waitFunc (containerID )
129152 }
130- return nil , nil
153+ return client. ContainerWaitResult {}
131154}
132155
133156func (f * fakeClient ) ContainerStart (_ context.Context , containerID string , options client.ContainerStartOptions ) (client.ContainerStartResult , error ) {
@@ -137,11 +160,11 @@ func (f *fakeClient) ContainerStart(_ context.Context, containerID string, optio
137160 return client.ContainerStartResult {}, nil
138161}
139162
140- func (f * fakeClient ) ContainerExport (_ context.Context , containerID string ) (io. ReadCloser , error ) {
163+ func (f * fakeClient ) ContainerExport (_ context.Context , containerID string , _ client. ContainerExportOptions ) (client. ContainerExportResult , error ) {
141164 if f .containerExportFunc != nil {
142165 return f .containerExportFunc (containerID )
143166 }
144- return nil , nil
167+ return client. ContainerExportResult {} , nil
145168}
146169
147170func (f * fakeClient ) ExecResize (_ context.Context , id string , options client.ExecResizeOptions ) (client.ExecResizeResult , error ) {
@@ -194,12 +217,12 @@ func (f *fakeClient) ContainerDiff(ctx context.Context, containerID string, _ cl
194217 return client.ContainerDiffResult {}, nil
195218}
196219
197- func (f * fakeClient ) ContainerRename (ctx context.Context , oldName , newName string ) error {
220+ func (f * fakeClient ) ContainerRename (ctx context.Context , oldName string , options client. ContainerRenameOptions ) (client. ContainerRenameResult , error ) {
198221 if f .containerRenameFunc != nil {
199- return f .containerRenameFunc (ctx , oldName , newName )
222+ return client. ContainerRenameResult {}, f .containerRenameFunc (ctx , oldName , options . NewName )
200223 }
201224
202- return nil
225+ return client. ContainerRenameResult {}, nil
203226}
204227
205228func (f * fakeClient ) ContainerCommit (ctx context.Context , containerID string , options client.ContainerCommitOptions ) (client.ContainerCommitResult , error ) {
0 commit comments