2022-03-02 16:26:45 +01:00
|
|
|
package cnbutils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-07-06 11:34:05 +02:00
|
|
|
"github.com/BurntSushi/toml"
|
2022-03-02 16:26:45 +01:00
|
|
|
"github.com/buildpacks/lifecycle/platform"
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|