|
@@ -4,7 +4,6 @@ import (
|
|
"context"
|
|
"context"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"fmt"
|
|
"fmt"
|
|
- "strconv"
|
|
|
|
"strings"
|
|
"strings"
|
|
|
|
|
|
distref "github.com/docker/distribution/reference"
|
|
distref "github.com/docker/distribution/reference"
|
|
@@ -18,9 +17,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
const (
|
|
const (
|
|
- keyImageName = "name"
|
|
|
|
- keyBuildInfo = "buildinfo"
|
|
|
|
- keyBuildInfoAttrs = "buildinfo-attrs"
|
|
|
|
|
|
+ keyImageName = "name"
|
|
)
|
|
)
|
|
|
|
|
|
// Differ can make a moby layer from a snapshot
|
|
// Differ can make a moby layer from a snapshot
|
|
@@ -48,7 +45,6 @@ func New(opt Opt) (exporter.Exporter, error) {
|
|
func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exporter.ExporterInstance, error) {
|
|
func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exporter.ExporterInstance, error) {
|
|
i := &imageExporterInstance{
|
|
i := &imageExporterInstance{
|
|
imageExporter: e,
|
|
imageExporter: e,
|
|
- buildInfo: true,
|
|
|
|
}
|
|
}
|
|
for k, v := range opt {
|
|
for k, v := range opt {
|
|
switch k {
|
|
switch k {
|
|
@@ -60,26 +56,6 @@ func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp
|
|
}
|
|
}
|
|
i.targetNames = append(i.targetNames, ref)
|
|
i.targetNames = append(i.targetNames, ref)
|
|
}
|
|
}
|
|
- case keyBuildInfo:
|
|
|
|
- if v == "" {
|
|
|
|
- i.buildInfo = true
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- b, err := strconv.ParseBool(v)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, errors.Wrapf(err, "non-bool value specified for %s", k)
|
|
|
|
- }
|
|
|
|
- i.buildInfo = b
|
|
|
|
- case keyBuildInfoAttrs:
|
|
|
|
- if v == "" {
|
|
|
|
- i.buildInfoAttrs = false
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- b, err := strconv.ParseBool(v)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, errors.Wrapf(err, "non-bool value specified for %s", k)
|
|
|
|
- }
|
|
|
|
- i.buildInfoAttrs = b
|
|
|
|
default:
|
|
default:
|
|
if i.meta == nil {
|
|
if i.meta == nil {
|
|
i.meta = make(map[string][]byte)
|
|
i.meta = make(map[string][]byte)
|
|
@@ -92,10 +68,8 @@ func (e *imageExporter) Resolve(ctx context.Context, opt map[string]string) (exp
|
|
|
|
|
|
type imageExporterInstance struct {
|
|
type imageExporterInstance struct {
|
|
*imageExporter
|
|
*imageExporter
|
|
- targetNames []distref.Named
|
|
|
|
- meta map[string][]byte
|
|
|
|
- buildInfo bool
|
|
|
|
- buildInfoAttrs bool
|
|
|
|
|
|
+ targetNames []distref.Named
|
|
|
|
+ meta map[string][]byte
|
|
}
|
|
}
|
|
|
|
|
|
func (e *imageExporterInstance) Name() string {
|
|
func (e *imageExporterInstance) Name() string {
|
|
@@ -122,13 +96,9 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source
|
|
}
|
|
}
|
|
|
|
|
|
var config []byte
|
|
var config []byte
|
|
- var buildInfo []byte
|
|
|
|
switch len(inp.Refs) {
|
|
switch len(inp.Refs) {
|
|
case 0:
|
|
case 0:
|
|
config = inp.Metadata[exptypes.ExporterImageConfigKey]
|
|
config = inp.Metadata[exptypes.ExporterImageConfigKey]
|
|
- if v, ok := inp.Metadata[exptypes.ExporterBuildInfo]; ok {
|
|
|
|
- buildInfo = v
|
|
|
|
- }
|
|
|
|
case 1:
|
|
case 1:
|
|
platformsBytes, ok := inp.Metadata[exptypes.ExporterPlatformsKey]
|
|
platformsBytes, ok := inp.Metadata[exptypes.ExporterPlatformsKey]
|
|
if !ok {
|
|
if !ok {
|
|
@@ -142,9 +112,6 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source
|
|
return nil, nil, errors.Errorf("number of platforms does not match references %d %d", len(p.Platforms), len(inp.Refs))
|
|
return nil, nil, errors.Errorf("number of platforms does not match references %d %d", len(p.Platforms), len(inp.Refs))
|
|
}
|
|
}
|
|
config = inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, p.Platforms[0].ID)]
|
|
config = inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, p.Platforms[0].ID)]
|
|
- if v, ok := inp.Metadata[fmt.Sprintf("%s/%s", exptypes.ExporterBuildInfo, p.Platforms[0].ID)]; ok {
|
|
|
|
- buildInfo = v
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
var diffs []digest.Digest
|
|
var diffs []digest.Digest
|
|
@@ -187,7 +154,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, inp *exporter.Source
|
|
|
|
|
|
diffs, history = normalizeLayersAndHistory(diffs, history, ref)
|
|
diffs, history = normalizeLayersAndHistory(diffs, history, ref)
|
|
|
|
|
|
- config, err = patchImageConfig(config, diffs, history, inp.Metadata[exptypes.ExporterInlineCache], buildInfo)
|
|
|
|
|
|
+ config, err = patchImageConfig(config, diffs, history, inp.Metadata[exptypes.ExporterInlineCache])
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, nil, err
|
|
return nil, nil, err
|
|
}
|
|
}
|