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
19 changes: 12 additions & 7 deletions commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"text/tabwriter"

"github.com/containerd/console"
"github.com/containerd/containerd/v2/pkg/epoch"
"github.com/containerd/platforms"
"github.com/docker/buildx/bake"
"github.com/docker/buildx/bake/hclparser"
Expand Down Expand Up @@ -241,16 +242,20 @@ func runBake(ctx context.Context, dockerCli command.Cli, targets []string, in ba
return err
}

if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
// TODO: extract env var parsing to a method easily usable by library consumers
for _, t := range tgts {
if _, ok := t.Args["SOURCE_DATE_EPOCH"]; ok {
continue
}
var sourceDateEpoch *string
for _, t := range tgts {
if _, ok := t.Args[epoch.SourceDateEpochEnv]; ok {
continue
}

v := os.Getenv(epoch.SourceDateEpochEnv)
sourceDateEpoch = &v

if *sourceDateEpoch != "" {
if t.Args == nil {
t.Args = map[string]*string{}
}
t.Args["SOURCE_DATE_EPOCH"] = &v
t.Args[epoch.SourceDateEpochEnv] = sourceDateEpoch
}
}

Expand Down
8 changes: 4 additions & 4 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"time"

"github.com/containerd/console"
"github.com/containerd/containerd/v2/pkg/epoch"
"github.com/docker/buildx/build"
"github.com/docker/buildx/builder"
"github.com/docker/buildx/store"
Expand Down Expand Up @@ -139,10 +140,9 @@ func (o *buildOptions) toOptions() (*BuildOptions, error) {
ExportLoad: o.exportLoad,
}

// TODO: extract env var parsing to a method easily usable by library consumers
if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
if _, ok := opts.BuildArgs["SOURCE_DATE_EPOCH"]; !ok {
opts.BuildArgs["SOURCE_DATE_EPOCH"] = v
if _, ok := opts.BuildArgs[epoch.SourceDateEpochEnv]; !ok {
if v := os.Getenv(epoch.SourceDateEpochEnv); v != "" {
opts.BuildArgs[epoch.SourceDateEpochEnv] = v
}
}

Expand Down
3 changes: 2 additions & 1 deletion commands/history/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/containerd/containerd/v2/core/content"
"github.com/containerd/containerd/v2/core/content/proxy"
"github.com/containerd/containerd/v2/core/images"
"github.com/containerd/containerd/v2/pkg/epoch"
"github.com/containerd/platforms"
"github.com/docker/buildx/localstate"
"github.com/docker/buildx/util/cobrautil/completion"
Expand Down Expand Up @@ -392,7 +393,7 @@ workers0:
readAttr(attrs, "ulimit", &out.Config.Ulimit, nil)
readAttr(attrs, "build-arg:BUILDKIT_CACHE_MOUNT_NS", &out.Config.CacheMountNS, nil)
readAttr(attrs, "build-arg:BUILDKIT_DOCKERFILE_CHECK", &out.Config.DockerfileCheckConfig, nil)
readAttr(attrs, "build-arg:SOURCE_DATE_EPOCH", &out.Config.SourceDateEpoch, nil)
readAttr(attrs, "build-arg:"+epoch.SourceDateEpochEnv, &out.Config.SourceDateEpoch, nil)
readAttr(attrs, "build-arg:SANDBOX_HOSTNAME", &out.Config.SandboxHostname, nil)

var unusedAttrs []keyValueOutput
Expand Down
41 changes: 41 additions & 0 deletions vendor/github.com/containerd/containerd/v2/pkg/epoch/context.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions vendor/github.com/containerd/containerd/v2/pkg/epoch/epoch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ github.com/containerd/containerd/v2/internal/fsverity
github.com/containerd/containerd/v2/internal/lazyregexp
github.com/containerd/containerd/v2/internal/randutil
github.com/containerd/containerd/v2/pkg/archive/compression
github.com/containerd/containerd/v2/pkg/epoch
github.com/containerd/containerd/v2/pkg/filters
github.com/containerd/containerd/v2/pkg/identifiers
github.com/containerd/containerd/v2/pkg/kernelversion
Expand Down
Loading