Skip to content

Commit

Permalink
Parse extension ID from history so that we can output a useful log me…
Browse files Browse the repository at this point in the history
…ssage

Signed-off-by: Natalie Arellano <narellano@vmware.com>
  • Loading branch information
natalieparellano committed May 23, 2023
1 parent 98c6c2f commit 1b4a070
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ func (e *Exporter) addExtensionLayers(opts ExportOptions, meta *platform.LayersM
layerPath = filepath.Join(artifactsDir, calculatedDiffID)
}
layer := layers.Layer{
ID: "from extensions",
ID: parseExtensionIDFromHistory(history[idx]),
TarPath: layerPath,
Digest: layerHex.String(),
History: history[idx],
Expand All @@ -332,6 +332,18 @@ func (e *Exporter) addExtensionLayers(opts ExportOptions, meta *platform.LayersM
return nil
}

func parseExtensionIDFromHistory(history v1.History) string {
r := strings.NewReader(history.CreatedBy)
var (
layerName, extensionID string
)
n, err := fmt.Fscanf(r, layers.ExtensionLayerName, &layerName, &extensionID)
if err != nil || n != 2 {
return "from extensions"
}
return strings.ReplaceAll(extensionID, "@", ":") // matches buildpacks
}

func isLocalImage(workingImage imgutil.Image) bool {
if _, ok := workingImage.(*local.Image); ok {
return true
Expand Down

0 comments on commit 1b4a070

Please sign in to comment.