Skip to content

Commit d82a803

Browse files
committed
exporter: Add exptypes with Common exporter keys
Signed-off-by: Paweł Gronowski <[email protected]>
1 parent cecab8d commit d82a803

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

exporter/containerimage/exptypes/keys.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package exptypes
22

3+
import commonexptypes "github.com/moby/buildkit/exporter/exptypes"
4+
35
type ImageExporterOptKey string
46

57
// Options keys supported by the image exporter output.
@@ -55,7 +57,7 @@ var (
5557
// Clamp produced timestamps. For more information see the
5658
// SOURCE_DATE_EPOCH specification.
5759
// Value: int (number of seconds since Unix epoch)
58-
OptKeySourceDateEpoch ImageExporterOptKey = "source-date-epoch"
60+
OptKeySourceDateEpoch ImageExporterOptKey = ImageExporterOptKey(commonexptypes.OptKeySourceDateEpoch)
5961

6062
// Compression type for newly created and cached layers.
6163
// estargz should be used with OptKeyOCITypes set to true.

exporter/containerimage/exptypes/types.go

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const (
1212
ExporterImageDescriptorKey = "containerimage.descriptor"
1313
ExporterInlineCache = "containerimage.inlinecache"
1414
ExporterPlatformsKey = "refs.platforms"
15-
ExporterEpochKey = "source.date.epoch"
1615
)
1716

1817
// KnownRefMetadataKeys are the subset of exporter keys that can be suffixed by

exporter/exptypes/keys.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package exptypes
2+
3+
const (
4+
ExporterEpochKey = "source.date.epoch"
5+
)
6+
7+
type ExporterOptKey string
8+
9+
// Options keys supported by all exporters.
10+
var (
11+
// Clamp produced timestamps. For more information see the
12+
// SOURCE_DATE_EPOCH specification.
13+
// Value: int (number of seconds since Unix epoch)
14+
OptKeySourceDateEpoch ExporterOptKey = "source-date-epoch"
15+
)

exporter/util/epoch/parse.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"time"
66

77
"github.com/moby/buildkit/exporter"
8-
"github.com/moby/buildkit/exporter/containerimage/exptypes"
8+
commonexptypes "github.com/moby/buildkit/exporter/exptypes"
99
"github.com/pkg/errors"
1010
)
1111

@@ -25,7 +25,7 @@ func ParseExporterAttrs(opt map[string]string) (*time.Time, map[string]string, e
2525

2626
for k, v := range opt {
2727
switch k {
28-
case string(exptypes.OptKeySourceDateEpoch):
28+
case string(commonexptypes.OptKeySourceDateEpoch):
2929
var err error
3030
tm, err = parseTime(k, v)
3131
if err != nil {
@@ -40,7 +40,7 @@ func ParseExporterAttrs(opt map[string]string) (*time.Time, map[string]string, e
4040
}
4141

4242
func ParseSource(inp *exporter.Source) (*time.Time, bool, error) {
43-
if v, ok := inp.Metadata[exptypes.ExporterEpochKey]; ok {
43+
if v, ok := inp.Metadata[commonexptypes.ExporterEpochKey]; ok {
4444
epoch, err := parseTime("", string(v))
4545
if err != nil {
4646
return nil, false, errors.Wrapf(err, "invalid SOURCE_DATE_EPOCH from frontend: %q", v)

0 commit comments

Comments
 (0)