1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/pkg/cnbutils/report.go
Pavel Busko 0de06c6207
feat(cnbBuild): write image digests to the CPE (#3602)
Co-authored-by: Johannes Dillmann <j.dillmann@sap.com>
2022-03-02 16:26:45 +01:00

34 lines
618 B
Go

package cnbutils
import (
"fmt"
"github.com/SAP/jenkins-library/pkg/log"
"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
}
log.Entry().Debugf("Image report: %#v\n", report)
if report.Image.Digest == "" {
return "", fmt.Errorf("image digest is empty")
}
return report.Image.Digest, nil
}