|
14 | 14 | limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -package api |
| 17 | +package dryrun |
18 | 18 |
|
19 | 19 | import ( |
20 | 20 | "bytes" |
@@ -50,10 +50,6 @@ import ( |
50 | 50 | specs "github.com/opencontainers/image-spec/specs-go/v1" |
51 | 51 | ) |
52 | 52 |
|
53 | | -const ( |
54 | | - DRYRUN_PREFIX = " DRY-RUN MODE - " |
55 | | -) |
56 | | - |
57 | 53 | var _ client.APIClient = &DryRunClient{} |
58 | 54 |
|
59 | 55 | // DryRunClient implements APIClient by delegating to implementation functions. This allows lazy init and per-method overrides |
@@ -192,28 +188,17 @@ func (d *DryRunClient) ContainerUnpause(ctx context.Context, container string) e |
192 | 188 | func (d *DryRunClient) CopyFromContainer(ctx context.Context, container, srcPath string) (io.ReadCloser, containerType.PathStat, error) { |
193 | 189 | rc := io.NopCloser(strings.NewReader("")) |
194 | 190 | if _, err := d.ContainerStatPath(ctx, container, srcPath); err != nil { |
195 | | - return rc, containerType.PathStat{}, fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, srcPath, container) |
| 191 | + return rc, containerType.PathStat{}, fmt.Errorf("could not find the file %s in container %s", srcPath, container) |
196 | 192 | } |
197 | 193 | return rc, containerType.PathStat{}, nil |
198 | 194 | } |
199 | 195 |
|
200 | 196 | func (d *DryRunClient) CopyToContainer(ctx context.Context, container, path string, content io.Reader, options containerType.CopyToContainerOptions) error { |
201 | | - if _, err := d.ContainerStatPath(ctx, container, path); err != nil { |
202 | | - return fmt.Errorf(" %s Could not find the file %s in container %s", DRYRUN_PREFIX, path, container) |
203 | | - } |
204 | 197 | return nil |
205 | 198 | } |
206 | 199 |
|
207 | 200 | func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) { |
208 | | - jsonMessage, err := json.Marshal(&jsonmessage.JSONMessage{ |
209 | | - Status: fmt.Sprintf("%[1]sSuccessfully built: dryRunID\n%[1]sSuccessfully tagged: %[2]s\n", DRYRUN_PREFIX, options.Tags[0]), |
210 | | - Progress: &jsonmessage.JSONProgress{}, |
211 | | - ID: "", |
212 | | - }) |
213 | | - if err != nil { |
214 | | - return build.ImageBuildResponse{}, err |
215 | | - } |
216 | | - rc := io.NopCloser(bytes.NewReader(jsonMessage)) |
| 201 | + rc := io.NopCloser(bytes.NewReader(nil)) |
217 | 202 |
|
218 | 203 | return build.ImageBuildResponse{ |
219 | 204 | Body: rc, |
@@ -321,12 +306,10 @@ func (d *DryRunClient) ContainerExecCreate(ctx context.Context, container string |
321 | 306 | } |
322 | 307 |
|
323 | 308 | func (d *DryRunClient) ContainerExecStart(ctx context.Context, execID string, config containerType.ExecStartOptions) error { |
324 | | - v, ok := d.execs.LoadAndDelete(execID) |
| 309 | + _, ok := d.execs.LoadAndDelete(execID) |
325 | 310 | if !ok { |
326 | 311 | return fmt.Errorf("invalid exec ID %q", execID) |
327 | 312 | } |
328 | | - details := v.(execDetails) |
329 | | - fmt.Printf("%sExecuting command %q in %s (detached mode)\n", DRYRUN_PREFIX, details.command, details.container) |
330 | 313 | return nil |
331 | 314 | } |
332 | 315 |
|
|
0 commit comments