diff --git a/internal/inspectimage/info_display.go b/internal/inspectimage/info_display.go index ba4e0b7cd8..112f076692 100644 --- a/internal/inspectimage/info_display.go +++ b/internal/inspectimage/info_display.go @@ -44,6 +44,7 @@ type InfoDisplay struct { Base BaseDisplay `json:"base_image" yaml:"base_image" toml:"base_image"` RunImageMirrors []RunImageMirrorDisplay `json:"run_images" yaml:"run_images" toml:"run_images"` Buildpacks []dist.ModuleInfo `json:"buildpacks" yaml:"buildpacks" toml:"buildpacks"` + Extensions []dist.ModuleInfo `json:"extensions" yaml:"extensions" toml:"extensions"` Processes []ProcessDisplay `json:"processes" yaml:"processes" toml:"processes"` } @@ -62,6 +63,7 @@ func NewInfoDisplay(info *client.ImageInfo, generalInfo GeneralInfo) *InfoDispla Base: displayBase(info.Base), RunImageMirrors: displayMirrors(info, generalInfo), Buildpacks: displayBuildpacks(info.Buildpacks), + Extensions: displayExtensions(info.Extensions), Processes: displayProcesses(info.Processes), } } @@ -140,6 +142,18 @@ func displayBuildpacks(buildpacks []buildpack.GroupElement) []dist.ModuleInfo { return result } +func displayExtensions(extensions []buildpack.GroupElement) []dist.ModuleInfo { + var result []dist.ModuleInfo + for _, extension := range extensions { + result = append(result, dist.ModuleInfo{ + ID: extension.ID, + Version: extension.Version, + Homepage: extension.Homepage, + }) + } + return result +} + func displayProcesses(details client.ProcessDetails) []ProcessDisplay { var result []ProcessDisplay detailsArray := details.OtherProcesses diff --git a/internal/inspectimage/writer/human_readable.go b/internal/inspectimage/writer/human_readable.go index ac4c36fb5d..fa3e10a06c 100644 --- a/internal/inspectimage/writer/human_readable.go +++ b/internal/inspectimage/writer/human_readable.go @@ -61,6 +61,7 @@ func writeImageInfo( Parse(runImagesTemplate)) imgTpl = template.Must(imgTpl.New("buildpacks"). Parse(buildpacksTemplate)) + imgTpl = template.Must(imgTpl.New("extensions").Parse(extensionsTemplate)) imgTpl = template.Must(imgTpl.New("processes"). Parse(processesTemplate)) imgTpl = template.Must(imgTpl.New("image"). @@ -127,6 +128,17 @@ Buildpacks: (buildpack metadata not present) {{- end }}` +var extensionsTemplate = ` +Extensions: +{{- if .Info.Extensions }} + ID VERSION HOMEPAGE +{{- range $_, $b := .Info.Extensions }} + {{ $b.ID }} {{ $b.Version }} {{ StringsValueOrDefault $b.Homepage "-" }} +{{- end }} +{{- else }} + (extension metadata not present) +{{- end }}` + var processesTemplate = ` {{- if .Info.Processes }} @@ -150,4 +162,6 @@ Base Image: {{- end}} Top Layer: {{ .Info.Base.TopLayer }} {{ template "runImages" . }} -{{ template "buildpacks" . }}{{ template "processes" . }}` +{{ template "buildpacks" . }} +{{ template "extensions" . }} +{{ template "processes" . }}` diff --git a/pkg/client/inspect_image.go b/pkg/client/inspect_image.go index 9e9998fcf4..49e815248c 100644 --- a/pkg/client/inspect_image.go +++ b/pkg/client/inspect_image.go @@ -24,6 +24,10 @@ type ImageInfo struct { // phases and made a contribution to this image. Buildpacks []buildpack.GroupElement + // List of extensions that passed detection, ran their generate + // phases and made a contribution to this image. + Extensions []buildpack.GroupElement + // Base includes two references to the run image, // - the Run Image ID, // - the hash of the last layer in the app image that belongs to the run image. @@ -178,6 +182,7 @@ func (c *Client) InspectImage(name string, daemon bool) (*ImageInfo, error) { Base: layersMd.RunImage, BOM: buildMD.BOM, Buildpacks: buildMD.Buildpacks, + Extensions: buildMD.Extensions, Processes: processDetails, }, nil }