Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: buildkit with defaults #682

Merged
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
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
with:
go-version: "1.22"
check-latest: true
- name: Add containerd-snapshotter to docker daemon
run: |
echo '{"features": { "containerd-snapshotter": true }}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
- name: Unit test
shell: bash
env:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.1

require (
github.com/aquasecurity/trivy v0.51.4
github.com/containerd/containerd v1.7.19
github.com/containerd/platforms v0.2.1
github.com/cpuguy83/dockercfg v0.3.1
github.com/cpuguy83/go-docker v0.3.0
github.com/distribution/reference v0.6.0
Expand Down Expand Up @@ -57,11 +57,11 @@ require (
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/console v1.0.4 // indirect
github.com/containerd/containerd v1.7.19 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/containerd/ttrpc v1.2.5 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down
2 changes: 1 addition & 1 deletion pkg/buildkit/buildkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"

"github.com/containerd/containerd/platforms"
"github.com/containerd/platforms"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/client/llb/sourceresolver"
gwclient "github.com/moby/buildkit/frontend/gateway/client"
Expand Down
24 changes: 21 additions & 3 deletions pkg/buildkit/buildkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ func TestNewClient(t *testing.T) {
cancel()
checkMissingCapsError(t, err, requiredCaps...)
})
t.Run("Invalid key path", func(t *testing.T) {
t.Parallel()
addr := newMockBuildkitAPI(t)
ctxT, cancel := context.WithTimeout(ctx, time.Second)
defer cancel()
bkOpts := Opts{
Addr: `https://` + addr,
KeyPath: `No-Keys-Exist/Here`,
}
_, err := NewClient(ctxT, bkOpts)
assert.ErrorContains(t, err, "could not read certificate/key")
})
t.Run("with caps", func(t *testing.T) {
t.Parallel()
addr := newMockBuildkitAPI(t, requiredCaps...)
Expand All @@ -213,10 +225,16 @@ func TestNewClient(t *testing.T) {
err = ValidateClient(ctxT, client)
assert.NoError(t, err)
})
t.Run("default buildkit addr", func(t *testing.T) {
t.Parallel()
bkOpts := Opts{} // Initialize with default values
client, err := NewClient(context.TODO(), bkOpts)
assert.NoError(t, err)
defer client.Close()
err = ValidateClient(context.TODO(), client)
assert.NoError(t, err)
})
})

// TODO: Test with defaults, but then we need to control those socket paths.
// I considered doing this in a chroot, but it is fairly complicated to do so and requires root privileges anyway (or CAP_SYS_CHROOT).
}

func TestArrayFile(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/patch/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/containerd/containerd/platforms"
"github.com/containerd/platforms"
"github.com/docker/buildx/build"
"github.com/docker/cli/cli/config"
log "github.com/sirupsen/logrus"
Expand Down
Loading