exporter: Add exptypes with Common exporter keys

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski committed 2023-06-02 09:38:27 +02:00
1 parent cecab8d64b
commit d82a80313e
4 files changed
+21 -5

No files matched your search

+3 -1
View File
@@ -1,5 +1,7 @@
package exptypes
import commonexptypes "github.com/moby/buildkit/exporter/exptypes"
type ImageExporterOptKey string
// Options keys supported by the image exporter output.
@@ -55,7 +57,7 @@ var (
// Clamp produced timestamps. For more information see the
// SOURCE_DATE_EPOCH specification.
// Value: int (number of seconds since Unix epoch)
OptKeySourceDateEpoch ImageExporterOptKey = "source-date-epoch"
OptKeySourceDateEpoch ImageExporterOptKey = ImageExporterOptKey(commonexptypes.OptKeySourceDateEpoch)
// Compression type for newly created and cached layers.
// estargz should be used with OptKeyOCITypes set to true.
@@ -12,7 +12,6 @@ const (
ExporterImageDescriptorKey = "containerimage.descriptor"
ExporterInlineCache = "containerimage.inlinecache"
ExporterPlatformsKey = "refs.platforms"
ExporterEpochKey = "source.date.epoch"
)
// KnownRefMetadataKeys are the subset of exporter keys that can be suffixed by
+15
View File
@@ -0,0 +1,15 @@
package exptypes
const (
ExporterEpochKey = "source.date.epoch"
)
type ExporterOptKey string
// Options keys supported by all exporters.
var (
// Clamp produced timestamps. For more information see the
// SOURCE_DATE_EPOCH specification.
// Value: int (number of seconds since Unix epoch)
OptKeySourceDateEpoch ExporterOptKey = "source-date-epoch"
)
+3 -3
View File
@@ -5,7 +5,7 @@ import (
"time"
"github.com/moby/buildkit/exporter"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
commonexptypes "github.com/moby/buildkit/exporter/exptypes"
"github.com/pkg/errors"
)
@@ -25,7 +25,7 @@ func ParseExporterAttrs(opt map[string]string) (*time.Time, map[string]string, e
for k, v := range opt {
switch k {
case string(exptypes.OptKeySourceDateEpoch):
case string(commonexptypes.OptKeySourceDateEpoch):
var err error
tm, err = parseTime(k, v)
if err != nil {
@@ -40,7 +40,7 @@ func ParseExporterAttrs(opt map[string]string) (*time.Time, map[string]string, e
}
func ParseSource(inp *exporter.Source) (*time.Time, bool, error) {
if v, ok := inp.Metadata[exptypes.ExporterEpochKey]; ok {
if v, ok := inp.Metadata[commonexptypes.ExporterEpochKey]; ok {
epoch, err := parseTime("", string(v))
if err != nil {
return nil, false, errors.Wrapf(err, "invalid SOURCE_DATE_EPOCH from frontend: %q", v)