Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Aug 16, 2021
1 parent 7fdd8cc commit c9bff8b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
19 changes: 15 additions & 4 deletions exporter/containerimage/exptypes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,26 @@ type Platform struct {
Platform ocispecs.Platform
}

// BuildInfo defines build dependencies that will be added to image config as
// moby.buildkit.buildinfo.v0 key and returned in solver ExporterResponse as
// ExporterBuildInfo key.
type BuildInfo struct {
Type BuildInfoType `json:"type,omitempty"`
Ref string `json:"ref,omitempty"`
Alias string `json:"alias,omitempty"`
Pin string `json:"pin,omitempty"`
// Type defines the BuildInfoType source type (docker-image, git, http).
Type BuildInfoType `json:"type,omitempty"`
// Ref is the reference of the source type.
Ref string `json:"ref,omitempty"`
// Alias is a special field used to match with the actual source ref
// because frontend might have already transformed a string user typed
// before generating LLB.
Alias string `json:"alias,omitempty"`
// Pin is the source digest.
Pin string `json:"pin,omitempty"`
}

// BuildInfoType contains source type.
type BuildInfoType string

// List of source types.
const (
BuildInfoTypeDockerImage BuildInfoType = "docker-image"
BuildInfoTypeGit BuildInfoType = "git"
Expand Down
4 changes: 3 additions & 1 deletion frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
}
}
if !isScratch {
// image not scratch set original image name as ref
// and actual reference as alias in BuildInfo
d.buildInfo = &exptypes.BuildInfo{
Type: exptypes.BuildInfoTypeDockerImage,
Ref: origName,
Expand Down Expand Up @@ -411,7 +413,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
}
}

// Set target with gathered build dependencies
// set target with gathered build dependencies
target.image.BuildInfo = []byte{}
if len(buildInfos) > 0 {
target.image.BuildInfo, err = json.Marshal(buildInfos)
Expand Down
2 changes: 1 addition & 1 deletion frontend/dockerfile/dockerfile2llb/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type Image struct {
// Variant defines platform variant. To be added to OCI.
Variant string `json:"variant,omitempty"`

// BuildInfo defines build dependencies
// BuildInfo defines build dependencies.
BuildInfo []byte `json:"moby.buildkit.buildinfo.v0,omitempty"`
}

Expand Down

0 comments on commit c9bff8b

Please sign in to comment.