mirror of
https://github.com/SAP/jenkins-library.git
synced 2024-12-14 11:03:09 +02:00
1f750af16d
Co-authored-by: Ralf Pannemans <ralf.pannemans@sap.com> Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
31 lines
524 B
Go
31 lines
524 B
Go
package cnbutils
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/buildpacks/lifecycle/platform"
|
|
"github.com/pelletier/go-toml"
|
|
)
|
|
|
|
const reportFile = "/layers/report.toml"
|
|
|
|
func DigestFromReport(utils BuildUtils) (string, error) {
|
|
report := platform.ExportReport{}
|
|
|
|
data, err := utils.FileRead(reportFile)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
err = toml.Unmarshal(data, &report)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if report.Image.Digest == "" {
|
|
return "", fmt.Errorf("image digest is empty")
|
|
}
|
|
|
|
return report.Image.Digest, nil
|
|
}
|