Add new "ArchLastStageFrom" function for getting the effective "base" of the given image (needed for docs generation)

This commit is contained in:
Tianon Gravi 2019-05-20 15:18:09 -07:00
parent 62995582c7
commit b939318aa7
1 changed files with 9 additions and 0 deletions

View File

@ -25,6 +25,15 @@ type dockerfileMetadata struct {
Froms []string // every "FROM" or "COPY --from=xxx" value (minus named and/or numbered stages in the case of "--from=") Froms []string // every "FROM" or "COPY --from=xxx" value (minus named and/or numbered stages in the case of "--from=")
} }
// this returns the "FROM" value for the last stage (which essentially determines the "base" for the final published image)
func (r Repo) ArchLastStageFrom(arch string, entry *manifest.Manifest2822Entry) (string, error) {
dockerfileMeta, err := r.archDockerfileMetadata(arch, entry)
if err != nil {
return "", err
}
return dockerfileMeta.StageFroms[len(dockerfileMeta.StageFroms)-1], nil
}
func (r Repo) DockerFroms(entry *manifest.Manifest2822Entry) ([]string, error) { func (r Repo) DockerFroms(entry *manifest.Manifest2822Entry) ([]string, error) {
return r.ArchDockerFroms(arch, entry) return r.ArchDockerFroms(arch, entry)
} }