Skip to content

Commit

Permalink
Update to latest buildkit and associated dependencies (#352)
Browse files Browse the repository at this point in the history
There are a number of breaking API changes... trying to keep up to date
with them.
  • Loading branch information
aaronlehmann authored Oct 27, 2023
1 parent 9f11942 commit c2e1195
Show file tree
Hide file tree
Showing 16 changed files with 375 additions and 327 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
# expression language does not support ternary, so hack it via indexing boolean keys of an json object
runs-on: ${{ fromJSON('{true:"buildkitd",false:"ubuntu-latest"}')[github.repository == 'openllb/hlb'] }}
steps:
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v2
with:
go-version: ^1.19
go-version: ^1.21
id: go

- name: Check out code into the Go module directory
Expand Down
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ linters:
enable-all: false
disable-all: true
enable:
- depguard
- gofmt
- goimports
- gosimple
Expand Down
22 changes: 15 additions & 7 deletions codegen/builtin_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
gateway "github.com/moby/buildkit/frontend/gateway/client"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/solver/pb"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/openllb/hlb/errdefs"
Expand Down Expand Up @@ -100,7 +99,7 @@ func (i Image) Call(ctx context.Context, cln *client.Client, val Value, opts Opt
}
)
if resolver != nil {
dgst, config, err := resolver.ResolveImageConfig(ctx, ref, resolveOpt)
_, dgst, config, err := resolver.ResolveImageConfig(ctx, ref, resolveOpt)
if err != nil {
return nil, Arg(ctx, 0).WithError(err)
}
Expand Down Expand Up @@ -258,14 +257,22 @@ func (l Local) Call(ctx context.Context, cln *client.Client, val Value, opts Opt
State: st,
Platform: DefaultPlatform(ctx),
}
fs.SessionOpts = append(fs.SessionOpts, llbutil.WithSyncedDir(localPath, filesync.SyncedDir{
Dir: localDir,

syncedDirFS, err := fsutil.NewFS(localDir)
if err != nil {
return nil, err
}
syncedDirFS, err = fsutil.NewFilterFS(syncedDirFS, &fsutil.FilterOpt{
Map: func(_ string, st *fstypes.Stat) fsutil.MapResult {
st.Uid = 0
st.Gid = 0
return fsutil.MapResultKeep
},
}))
})
if err != nil {
return nil, err
}
fs.SessionOpts = append(fs.SessionOpts, llbutil.WithSyncedDir(localPath, syncedDirFS))

return NewValue(ctx, fs)
}
Expand Down Expand Up @@ -1004,8 +1011,9 @@ func (dl DockerLoad) Call(ctx context.Context, cln *client.Client, val Value, op
}

pw := mw.WithPrefix("", false)
progress.FromReader(pw, fmt.Sprintf("importing %s to docker", ref), resp.Body)
return nil
return progress.Wrap(fmt.Sprintf("importing %s to docker", ref), pw.Write, func(l progress.SubLogger) error {
return solver.ProgressFromReader(l, resp.Body)
})
})

fs, err := val.Filesystem()
Expand Down
13 changes: 9 additions & 4 deletions codegen/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ type cachedImageResolver struct {
}

type imageConfig struct {
ref string
dgst digest.Digest
config []byte
}

func (r *cachedImageResolver) ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (dgst digest.Digest, config []byte, err error) {
func (r *cachedImageResolver) ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (resolvedRef string, dgst digest.Digest, config []byte, err error) {
key := cacheKey{ref: ref}
if opt.Platform != nil {
key.os = opt.Platform.OS
Expand All @@ -61,7 +62,7 @@ func (r *cachedImageResolver) ResolveImageConfig(ctx context.Context, ref string
cfg, ok := r.cache[key]
r.mu.RUnlock()
if ok {
return cfg.dgst, cfg.config, nil
return cfg.ref, cfg.dgst, cfg.config, nil
}

s, err := llbutil.NewSession(ctx)
Expand All @@ -85,7 +86,7 @@ func (r *cachedImageResolver) ResolveImageConfig(ctx context.Context, ref string
}

return solver.Build(ctx, r.cln, s, pw, func(ctx context.Context, c gateway.Client) (res *gateway.Result, err error) {
dgst, config, err = c.ResolveImageConfig(ctx, ref, opt)
resolvedRef, dgst, config, err = c.ResolveImageConfig(ctx, ref, opt)
return gateway.NewResult(), err
})
})
Expand All @@ -96,7 +97,11 @@ func (r *cachedImageResolver) ResolveImageConfig(ctx context.Context, ref string
}

r.mu.Lock()
r.cache[key] = &imageConfig{dgst, config}
r.cache[key] = &imageConfig{
ref: resolvedRef,
dgst: dgst,
config: config,
}
r.mu.Unlock()
return
}
6 changes: 3 additions & 3 deletions go.hlb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ string versionCmd() {
}

fs golang() {
image "golang:1.19-alpine"
image "golang:1.21-alpine"
}

fs build(fs src, string package, string verPackage) {
Expand All @@ -28,7 +28,7 @@ fs build(fs src, string package, string verPackage) {
pipeline crossBinaries(fs src, string package, string verPackage) {
go.buildCommonWithOptions src package option::template {
stringField "base" "docker.elastic.co/beats-dev/golang-crossbuild"
stringField "goVersion" "1.19.3"
stringField "goVersion" "1.21.3"
stringField "goBuildFlags" "-ldflags \"-X ${verPackage}.Version=$(${versionCmd})\""
} option::run {
env "CGO_ENABLED" "0"
Expand All @@ -38,7 +38,7 @@ pipeline crossBinaries(fs src, string package, string verPackage) {
fs lint(fs src) {
golang
run "apk add -U git gcc libc-dev"
run "sh /golangci/install.sh -b /usr/bin v1.50.1" with option {
run "sh /golangci/install.sh -b /usr/bin v1.55.0" with option {
mount http("https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh") "/golangci"
}
env "GO111MODULE" "on"
Expand Down
124 changes: 70 additions & 54 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,109 +6,125 @@ require (
github.com/alecthomas/participle/v2 v2.0.0-alpha7.0.20211230082035-5a357f57e525
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
github.com/containerd/console v1.0.3
github.com/containerd/containerd v1.6.14
github.com/containerd/containerd v1.7.7
github.com/creachadair/jrpc2 v0.26.1
github.com/creack/pty v1.1.11
github.com/docker/buildx v0.10.0
github.com/docker/cli v23.0.0-rc.1+incompatible
github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker v23.0.0-rc.1+incompatible
github.com/creack/pty v1.1.18
github.com/docker/buildx v0.11.1-0.20231023141442-390eedc50ba8
github.com/docker/cli v24.0.5+incompatible
github.com/docker/distribution v2.8.2+incompatible
github.com/docker/docker v24.0.5+incompatible
github.com/google/go-dap v0.6.0
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/lithammer/dedent v1.1.0
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
github.com/mattn/go-isatty v0.0.14
github.com/moby/buildkit v0.11.0
github.com/moby/buildkit v0.13.0-beta1.0.20231023220200-20847b7c8306
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.0-rc2
github.com/opencontainers/image-spec v1.1.0-rc5
github.com/openllb/doxygen-parser v0.0.0-20201031162929-e0b5cceb2d0c
github.com/pkg/errors v0.9.1
github.com/sourcegraph/go-lsp v0.0.0-20200117082640-b19bb38222e2
github.com/stretchr/testify v1.8.1
github.com/tonistiigi/fsutil v0.0.0-20230105215944-fb433841cbfa
github.com/stretchr/testify v1.8.4
github.com/tonistiigi/fsutil v0.0.0-20230825212630-f09800878302
github.com/urfave/cli/v2 v2.3.0
github.com/xlab/treeprint v1.0.0
golang.org/x/crypto v0.2.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.3.0
google.golang.org/grpc v1.50.1
golang.org/x/crypto v0.14.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.13.0
google.golang.org/grpc v1.53.0
)

require (
cloud.google.com/go v0.75.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.1 // indirect
github.com/alecthomas/participle v1.0.0-alpha1.0.20201031050245-4435aeea334f // indirect
github.com/aws/aws-sdk-go-v2 v1.17.6 // indirect
github.com/aws/aws-sdk-go-v2/config v1.18.16 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.16 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.24 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.30 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.24 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.31 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.24 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.12.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.18.6 // indirect
github.com/aws/smithy-go v1.13.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fvbommel/sortorder v1.0.2 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.3.1+incompatible // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/in-toto/in-toto-golang v0.5.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/term v0.0.0-20221120202655-abb19827d345 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cobra v1.6.1 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.4.0 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/theupdateframework/notary v0.7.0 // indirect
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
github.com/tonistiigi/vt100 v0.0.0-20210615222946-8066bb97264f // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.29.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.29.0 // indirect
go.opentelemetry.io/otel v1.4.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.4.1 // indirect
go.opentelemetry.io/otel/internal/metric v0.27.0 // indirect
go.opentelemetry.io/otel/metric v0.27.0 // indirect
go.opentelemetry.io/otel/sdk v1.4.1 // indirect
go.opentelemetry.io/otel/trace v1.4.1 // indirect
go.opentelemetry.io/proto/otlp v0.12.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
github.com/tonistiigi/vt100 v0.0.0-20230623042737-f9a4f7ef6531 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.40.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.40.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.40.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.14.0 // indirect
go.opentelemetry.io/otel/metric v0.37.0 // indirect
go.opentelemetry.io/otel/sdk v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
)

replace github.com/sourcegraph/go-lsp => github.com/radeksimko/go-lsp v0.0.0-20200223162147-9f2c54f29c9f
Expand Down
Loading

0 comments on commit c2e1195

Please sign in to comment.