Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sha256sum for oci artifact #83

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion tibuild/pkg/rest/service/dev_build_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ func (s DevbuildServer) inflate(entity *DevBuild) {
for i, bin := range entity.Status.BuildReport.Binaries {
if bin.URL == "" && bin.OciFile != nil {
entity.Status.BuildReport.Binaries[i].URL = s.ociFileToUrl(*bin.OciFile)
if bin.Sha256OciFile != nil {
entity.Status.BuildReport.Binaries[i].Sha256URL = s.ociFileToUrl(*bin.Sha256OciFile)
}
}
}
}
Expand Down Expand Up @@ -457,8 +460,16 @@ func getLatestEndAt(pipelines []TektonPipeline) *time.Time {

func ociArtifactToFiles(platform Platform, artifact OciArtifact) []BinArtifact {
var rt []BinArtifact
var sha256s = make(map[string]*OciFile)
for _, file := range artifact.Files {
rt = append(rt, BinArtifact{Platform: platform, OciFile: &OciFile{Repo: artifact.Repo, Tag: artifact.Tag, File: file}})
if before, isSha256 := strings.CutSuffix(file, ".sha256"); isSha256 {
sha256s[before] = &OciFile{Repo: artifact.Repo, Tag: artifact.Tag, File: before}
} else {
rt = append(rt, BinArtifact{Platform: platform, OciFile: &OciFile{Repo: artifact.Repo, Tag: artifact.Tag, File: file}})
}
}
for idx := 0; idx < len(rt); idx += 1 {
rt[idx].Sha256OciFile = sha256s[rt[idx].OciFile.File]
}
return rt
}
Expand Down
11 changes: 6 additions & 5 deletions tibuild/pkg/rest/service/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,12 @@ var (
)

type BinArtifact struct {
Component string `json:"component,omitempty"`
Platform Platform `json:"platform"`
URL string `json:"url"`
Sha256URL string `json:"sha256URL"`
OciFile *OciFile `json:"ociFile,omitempty"`
Component string `json:"component,omitempty"`
Platform Platform `json:"platform"`
URL string `json:"url"`
Sha256URL string `json:"sha256URL"`
OciFile *OciFile `json:"ociFile,omitempty"`
Sha256OciFile *OciFile `json:"sha256OciFile,omitempty"`
}

type OciFile struct {
Expand Down
Loading