Skip to content

Commit 1022851

Browse files
authored
fix ci lint issues (#3114)
1 parent 29c43ab commit 1022851

7 files changed

Lines changed: 54 additions & 51 deletions

File tree

hack/cmd/update-builder/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func buildBuilderImage(ctx context.Context, variant, version, arch, builderTomlP
130130
}
131131
addGoAndRustBuildpacks(&builderConfig)
132132

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

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

832832
func getReleaseByVersion(ctx context.Context, repo, vers string) (*github.RepositoryRelease, error) {

pkg/builders/buildpacks/builder.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf
200200
// (and update build opts as necessary)
201201
if impl == nil {
202202
var (
203-
cli client.CommonAPIClient
203+
cli client.APIClient
204204
dockerHost string
205205
)
206206

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

251-
func isPodmanV43(ctx context.Context, cli client.CommonAPIClient) (b bool, err error) {
251+
func isPodmanV43(ctx context.Context, cli client.APIClient) (b bool, err error) {
252252
version, err := cli.ServerVersion(ctx)
253253
if err != nil {
254254
return

pkg/builders/buildpacks/scaffolding_injector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
// The CopyToContainer method hijacks the uploaded project stream and injects function scaffolding to it.
1818
// It basically moves content of /workspace to /workspace/fn and then setup scaffolding code directly in /workspace.
1919
type pyScaffoldInjector struct {
20-
client.CommonAPIClient
20+
client.APIClient
2121
invoke string
2222
}
2323

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

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

73-
return s.CommonAPIClient.CopyToContainer(ctx, ctr, p, pr, opts)
73+
return s.APIClient.CopyToContainer(ctx, ctr, p, pr, opts)
7474
}
7575

7676
func writePythonScaffolding(tw *tar.Writer, invoke string) error {

pkg/builders/s2i/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (b *Builder) Build(ctx context.Context, f fn.Function, platforms []fn.Platf
121121

122122
var client = b.cli
123123
if client == nil {
124-
var c dockerClient.CommonAPIClient
124+
var c dockerClient.APIClient
125125
c, _, err = docker.NewClient(dockerClient.DefaultDockerHost)
126126
if err != nil {
127127
return fmt.Errorf("cannot create docker client: %w", err)

pkg/builders/s2i/builder_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"testing"
88

99
"github.com/docker/docker/api/types"
10+
"github.com/docker/docker/api/types/build"
1011
"github.com/docker/docker/api/types/container"
11-
"github.com/docker/docker/api/types/image"
12+
typesImage "github.com/docker/docker/api/types/image"
1213
"github.com/docker/docker/api/types/network"
1314
"github.com/docker/docker/errdefs"
1415
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -211,8 +212,8 @@ func Test_BuildEnvs(t *testing.T) {
211212

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

234235
type mockDocker struct {
235-
inspect func(ctx context.Context, image string) (types.ImageInspect, []byte, error)
236+
inspect func(ctx context.Context, image string) (typesImage.InspectResponse, []byte, error)
236237
}
237238

238-
func (m mockDocker) ImageInspectWithRaw(ctx context.Context, image string) (types.ImageInspect, []byte, error) {
239+
func (m mockDocker) ImageInspectWithRaw(ctx context.Context, image string) (typesImage.InspectResponse, []byte, error) {
239240
if m.inspect != nil {
240241
return m.inspect(ctx, image)
241242
}
242243

243-
return types.ImageInspect{}, nil, nil
244+
return typesImage.InspectResponse{}, nil, nil
244245
}
245246

246-
func (m mockDocker) ImageBuild(ctx context.Context, context io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) {
247+
func (m mockDocker) ImageBuild(ctx context.Context, context io.Reader, options build.ImageBuildOptions) (build.ImageBuildResponse, error) {
247248
panic("implement me")
248249
}
249250

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

254-
func (m mockDocker) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (types.IDResponse, error) {
255+
func (m mockDocker) ContainerCommit(ctx context.Context, container string, options container.CommitOptions) (container.CommitResponse, error) {
255256
panic("implement me")
256257
}
257258

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

262-
func (m mockDocker) ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error) {
263+
func (m mockDocker) ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error) {
263264
panic("implement me")
264265
}
265266

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

290-
func (m mockDocker) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error) {
291+
func (m mockDocker) ImagePull(ctx context.Context, ref string, options typesImage.PullOptions) (io.ReadCloser, error) {
291292
panic("implement me")
292293
}
293294

294-
func (m mockDocker) ImageRemove(ctx context.Context, image string, options image.RemoveOptions) ([]image.DeleteResponse, error) {
295+
func (m mockDocker) ImageRemove(ctx context.Context, image string, options typesImage.RemoveOptions) ([]typesImage.DeleteResponse, error) {
295296
panic("implement me")
296297
}
297298

298299
func (m mockDocker) ServerVersion(ctx context.Context) (types.Version, error) {
299-
300300
panic("implement me")
301301
}
302302

pkg/docker/pusher_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"testing"
2727
"time"
2828

29-
"github.com/docker/docker/api/types"
3029
api "github.com/docker/docker/api/types/image"
3130
"github.com/docker/docker/client"
3231
"github.com/google/go-containerregistry/pkg/authn"
@@ -177,8 +176,8 @@ func TestPush(t *testing.T) {
177176
dockerClient.imagePush = pushUnreachable
178177
}
179178

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

184183
dockerClient.imageSave = func(ctx context.Context, tags []string) (io.ReadCloser, error) {
@@ -275,8 +274,8 @@ func newMockPusherDockerClient() *mockPusherDockerClient {
275274
imageSave: func(ctx context.Context, strings []string) (io.ReadCloser, error) {
276275
return nil, fmt.Errorf("imageSave not implemented")
277276
},
278-
imageInspect: func(ctx context.Context, s string) (types.ImageInspect, []byte, error) {
279-
return types.ImageInspect{}, nil, fmt.Errorf("imageInspect not implemented")
277+
imageInspect: func(ctx context.Context, s string) (api.InspectResponse, []byte, error) {
278+
return api.InspectResponse{}, nil, fmt.Errorf("imageInspect not implemented")
280279
},
281280
negotiateAPIVersion: func(ctx context.Context) {},
282281
close: func() error { return nil },
@@ -287,7 +286,7 @@ type mockPusherDockerClient struct {
287286
negotiateAPIVersion func(ctx context.Context)
288287
imagePush func(ctx context.Context, ref string, options api.PushOptions) (io.ReadCloser, error)
289288
imageSave func(ctx context.Context, strings []string) (io.ReadCloser, error)
290-
imageInspect func(ctx context.Context, s string) (types.ImageInspect, []byte, error)
289+
imageInspect func(ctx context.Context, s string) (api.InspectResponse, []byte, error)
291290
close func() error
292291
}
293292

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

310-
func (m *mockPusherDockerClient) ImageInspectWithRaw(ctx context.Context, s string) (types.ImageInspect, []byte, error) {
309+
func (m *mockPusherDockerClient) ImageInspectWithRaw(ctx context.Context, s string) (api.InspectResponse, []byte, error) {
311310
return m.imageInspect(ctx, s)
312311
}
313312

0 commit comments

Comments
 (0)