Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hack/cmd/update-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func buildBuilderImage(ctx context.Context, variant, version, arch, builderTomlP
}
addGoAndRustBuildpacks(&builderConfig)

var dockerClient docker.CommonAPIClient
var dockerClient docker.APIClient
dockerClient, err = docker.NewClientWithOpts(docker.FromEnv, docker.WithAPIVersionNegotiation())
if err != nil {
return "", fmt.Errorf("cannot create docker client")
Expand Down Expand Up @@ -819,14 +819,14 @@ func dockerDaemonAuthStr(img string) (string, error) {
// For some reason moby/docker erroneously returns 500 HTTP code for these missing images.
// Interestingly podman correctly returns 404 for same request.
type hackDockerClient struct {
docker.CommonAPIClient
docker.APIClient
}

func (c hackDockerClient) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
if strings.HasPrefix(ref, "ghcr.io/knative/buildpacks/") {
return nil, fmt.Errorf("this image is supposed to exist only in daemon: %w", errdefs.ErrNotFound)
}
return c.CommonAPIClient.ImagePull(ctx, ref, options)
return c.APIClient.ImagePull(ctx, ref, options)
}

func getReleaseByVersion(ctx context.Context, repo, vers string) (*github.RepositoryRelease, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/builders/buildpacks/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf
// (and update build opts as necessary)
if impl == nil {
var (
cli client.CommonAPIClient
cli client.APIClient
dockerHost string
)

Expand Down Expand Up @@ -248,7 +248,7 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf
return
}

func isPodmanV43(ctx context.Context, cli client.CommonAPIClient) (b bool, err error) {
func isPodmanV43(ctx context.Context, cli client.APIClient) (b bool, err error) {
version, err := cli.ServerVersion(ctx)
if err != nil {
return
Expand Down
6 changes: 3 additions & 3 deletions pkg/builders/buildpacks/scaffolding_injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// The CopyToContainer method hijacks the uploaded project stream and injects function scaffolding to it.
// It basically moves content of /workspace to /workspace/fn and then setup scaffolding code directly in /workspace.
type pyScaffoldInjector struct {
client.CommonAPIClient
client.APIClient
invoke string
}

Expand All @@ -26,7 +26,7 @@ func (s pyScaffoldInjector) CopyToContainer(ctx context.Context, ctr, p string,
if pc, _, _, ok := runtime.Caller(1); ok &&
!strings.Contains(runtime.FuncForPC(pc).Name(), "build.copyDir") {
// We are not called by "project dir copy" so we do simple direct forward call.
return s.CommonAPIClient.CopyToContainer(ctx, ctr, p, r, opts)
return s.APIClient.CopyToContainer(ctx, ctr, p, r, opts)
}

pr, pw := io.Pipe()
Expand Down Expand Up @@ -70,7 +70,7 @@ func (s pyScaffoldInjector) CopyToContainer(ctx context.Context, ctr, p string,
err = tw.Close()
}()

return s.CommonAPIClient.CopyToContainer(ctx, ctr, p, pr, opts)
return s.APIClient.CopyToContainer(ctx, ctr, p, pr, opts)
}

func writePythonScaffolding(tw *tar.Writer, invoke string) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/builders/s2i/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf

var client = b.cli
if client == nil {
var c dockerClient.CommonAPIClient
var c dockerClient.APIClient
c, _, err = docker.NewClient(dockerClient.DefaultDockerHost)
if err != nil {
return fmt.Errorf("cannot create docker client: %w", err)
Expand Down
24 changes: 12 additions & 12 deletions pkg/builders/s2i/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"testing"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/image"
typesImage "github.com/docker/docker/api/types/image"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/errdefs"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
Expand Down Expand Up @@ -211,8 +212,8 @@ func Test_BuildEnvs(t *testing.T) {

func TestBuildFail(t *testing.T) {
cli := mockDocker{
inspect: func(ctx context.Context, image string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{}, nil, errors.New("this is expected")
inspect: func(ctx context.Context, image string) (typesImage.InspectResponse, []byte, error) {
return typesImage.InspectResponse{}, nil, errors.New("this is expected")
},
}
b := s2i.NewBuilder(s2i.WithDockerClient(cli))
Expand All @@ -232,34 +233,34 @@ func (i *mockImpl) Build(cfg *api.Config) (*api.Result, error) {
}

type mockDocker struct {
inspect func(ctx context.Context, image string) (types.ImageInspect, []byte, error)
inspect func(ctx context.Context, image string) (typesImage.InspectResponse, []byte, error)
}

func (m mockDocker) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) {
func (m mockDocker) ImageInspectWithRaw(ctx context.Context, image string) (typesImage.InspectResponse, []byte, error) {
if m.inspect != nil {
return m.inspect(ctx, image)
}

return types.ImageInspect{}, nil, nil
return typesImage.InspectResponse{}, nil, nil
}

func (m mockDocker) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
func (m mockDocker) ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
panic("implement me")
}

func (m mockDocker) ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) {
panic("implement me")
}

func (m mockDocker) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) {
func (m mockDocker) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (container.CommitResponse, error) {
panic("implement me")
}

func (m mockDocker) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) {
panic("implement me")
}

func (m mockDocker) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) {
func (m mockDocker) ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error) {
panic("implement me")
}

Expand Down Expand Up @@ -287,16 +288,15 @@ func (m mockDocker) CopyFromContainer(ctx context.Context, container, srcPath st
panic("implement me")
}

func (m mockDocker) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
func (m mockDocker) ImagePull(ctx context.Context, ref string, options typesImage.PullOptions) (io.ReadCloser, error) {
panic("implement me")
}

func (m mockDocker) ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
func (m mockDocker) ImageRemove(ctx context.Context, image string, options typesImage.RemoveOptions) ([]typesImage.DeleteResponse, error) {
panic("implement me")
}

func (m mockDocker) ServerVersion(ctx context.Context) (types.Version, error) {

panic("implement me")
}

Expand Down
13 changes: 6 additions & 7 deletions pkg/docker/pusher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"testing"
"time"

"github.com/docker/docker/api/types"
api "github.com/docker/docker/api/types/image"
"github.com/docker/docker/client"
"github.com/google/go-containerregistry/pkg/authn"
Expand Down Expand Up @@ -177,8 +176,8 @@ func TestPush(t *testing.T) {
dockerClient.imagePush = pushUnreachable
}

dockerClient.imageInspect = func(ctx context.Context, s string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{ID: imageID}, []byte{}, nil
dockerClient.imageInspect = func(ctx context.Context, s string) (api.InspectResponse, []byte, error) {
return api.InspectResponse{ID: imageID}, []byte{}, nil
}

dockerClient.imageSave = func(ctx context.Context, tags []string) (io.ReadCloser, error) {
Expand Down Expand Up @@ -275,8 +274,8 @@ func newMockPusherDockerClient() *mockPusherDockerClient {
imageSave: func(ctx context.Context, strings []string) (io.ReadCloser, error) {
return nil, fmt.Errorf("imageSave not implemented")
},
imageInspect: func(ctx context.Context, s string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{}, nil, fmt.Errorf("imageInspect not implemented")
imageInspect: func(ctx context.Context, s string) (api.InspectResponse, []byte, error) {
return api.InspectResponse{}, nil, fmt.Errorf("imageInspect not implemented")
},
negotiateAPIVersion: func(ctx context.Context) {},
close: func() error { return nil },
Expand All @@ -287,7 +286,7 @@ type mockPusherDockerClient struct {
negotiateAPIVersion func(ctx context.Context)
imagePush func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error)
imageSave func(ctx context.Context, strings []string) (io.ReadCloser, error)
imageInspect func(ctx context.Context, s string) (types.ImageInspect, []byte, error)
imageInspect func(ctx context.Context, s string) (api.InspectResponse, []byte, error)
close func() error
}

Expand All @@ -307,7 +306,7 @@ func (m *mockPusherDockerClient) ImageTag(ctx context.Context, s string, s2 stri
panic("implement me")
}

func (m *mockPusherDockerClient) ImageInspectWithRaw(ctx context.Context, s string) (types.ImageInspect, []byte, error) {
func (m *mockPusherDockerClient) ImageInspectWithRaw(ctx context.Context, s string) (api.InspectResponse, []byte, error) {
return m.imageInspect(ctx, s)
}

Expand Down
Loading
Loading