diff --git a/internal/commands/build.go b/internal/commands/build.go index 2297cdbae..007c801ce 100644 --- a/internal/commands/build.go +++ b/internal/commands/build.go @@ -284,7 +284,6 @@ This option may set DOCKER_HOST environment variable for the build container if cmd.Flags().MarkHidden("sparse") } } - } func validateBuildFlags(flags *BuildFlags, cfg config.Config, inputImageRef client.InputImageReference, logger logging.Logger) error { diff --git a/internal/commands/testmocks/mock_pack_client.go b/internal/commands/testmocks/mock_pack_client.go index 981704c09..125cd83fb 100644 --- a/internal/commands/testmocks/mock_pack_client.go +++ b/internal/commands/testmocks/mock_pack_client.go @@ -120,6 +120,20 @@ func (mr *MockPackClientMockRecorder) DeleteManifest(arg0 interface{}) *gomock.C return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteManifest", reflect.TypeOf((*MockPackClient)(nil).DeleteManifest), arg0) } +// Detect mocks base method. +func (m *MockPackClient) Detect(arg0 context.Context, arg1 client.BuildOptions) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Detect", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Detect indicates an expected call of Detect. +func (mr *MockPackClientMockRecorder) Detect(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Detect", reflect.TypeOf((*MockPackClient)(nil).Detect), arg0, arg1) +} + // DownloadSBOM mocks base method. func (m *MockPackClient) DownloadSBOM(arg0 string, arg1 client.DownloadSBOMOptions) error { m.ctrl.T.Helper() diff --git a/internal/fakes/fake_lifecycle.go b/internal/fakes/fake_lifecycle.go index 280c1bf1d..a431ef69e 100644 --- a/internal/fakes/fake_lifecycle.go +++ b/internal/fakes/fake_lifecycle.go @@ -14,3 +14,8 @@ func (f *FakeLifecycle) Execute(ctx context.Context, opts build.LifecycleOptions f.Opts = opts return nil } + +func (f *FakeLifecycle) Detect(ctx context.Context, opts build.LifecycleOptions) error { + f.Opts = opts + return nil +} diff --git a/pkg/client/detect.go b/pkg/client/detect.go index 20703c9fa..7f0bf69c8 100644 --- a/pkg/client/detect.go +++ b/pkg/client/detect.go @@ -3,8 +3,6 @@ package client import ( "context" "fmt" - - "github.com/docker/docker/api/types" ) func (c *Client) Detect(ctx context.Context, opts BuildOptions) error { @@ -13,8 +11,7 @@ func (c *Client) Detect(ctx context.Context, opts BuildOptions) error { return err } - defer c.docker.ImageRemove(context.Background(), lifecycleOpts.LifecycleImage, types.ImageRemoveOptions{Force: true}) - defer c.docker.ImageRemove(context.Background(), lifecycleOpts.Builder.Name(), types.ImageRemoveOptions{Force: true}) + // TODO: Cleanup if err = c.lifecycleExecutor.Detect(ctx, *lifecycleOpts); err != nil { return fmt.Errorf("executing detect: %w", err)