mirror of
https://github.com/moby/buildkit.git
synced 2026-11-06 05:16:45 +00:00
exporter: Add exptypes with Common exporter keys
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
4 files changed
+21
-5
No files matched your search
@@ -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
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user