Skip to content

Commit

Permalink
Merge pull request #3602 from dgageot/fix-3588
Browse files Browse the repository at this point in the history
[bp] Use the same Docker client than Skaffold
  • Loading branch information
tejal29 authored Jan 28, 2020
2 parents b7a3605 + b464a98 commit d6910bb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/skaffold/build/buildpacks/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type fakePack struct {
Opts pack.BuildOptions
}

func (f *fakePack) runPack(_ context.Context, _ io.Writer, opts pack.BuildOptions) error {
func (f *fakePack) runPack(_ context.Context, _ io.Writer, _ docker.LocalDaemon, opts pack.BuildOptions) error {
f.Opts = opts
return nil
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact,

alreadyPulled := images.AreAlreadyPulled(artifact.Builder, artifact.RunImage)

if err := runPackBuildFunc(ctx, out, pack.BuildOptions{
if err := runPackBuildFunc(ctx, out, b.localDocker, pack.BuildOptions{
AppPath: workspace,
Builder: artifact.Builder,
RunImage: artifact.RunImage,
Expand All @@ -82,8 +82,11 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latest.Artifact,
return latest, nil
}

func runPackBuild(ctx context.Context, out io.Writer, opts pack.BuildOptions) error {
packClient, err := pack.NewClient(pack.WithLogger(NewLogger(out)))
func runPackBuild(ctx context.Context, out io.Writer, localDocker docker.LocalDaemon, opts pack.BuildOptions) error {
packClient, err := pack.NewClient(
pack.WithDockerClient(localDocker.RawClient()),
pack.WithLogger(NewLogger(out)),
)
if err != nil {
return errors.Wrap(err, "unable to create pack client")
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/docker/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type LocalDaemon interface {
ImageRemove(ctx context.Context, image string, opts types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
ImageExists(ctx context.Context, ref string) bool
Prune(ctx context.Context, out io.Writer, images []string, pruneChildren bool) error
RawClient() client.CommonAPIClient
}

type localDaemon struct {
Expand Down Expand Up @@ -104,6 +105,10 @@ type BuildResult struct {
ID string
}

func (l *localDaemon) RawClient() client.CommonAPIClient {
return l.apiClient
}

// Close closes the connection with the local daemon.
func (l *localDaemon) Close() error {
return l.apiClient.Close()
Expand Down

0 comments on commit d6910bb

Please sign in to comment.