Skip to content

Commit

Permalink
Merge pull request #1535 from paketo-buildpacks/fix-bellsoft
Browse files Browse the repository at this point in the history
Fix bellsoft liberica NIK retrieval
  • Loading branch information
dmikusa authored Mar 25, 2024
2 parents 01528b5 + fc7badb commit 3ee1e65
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions actions/bellsoft-liberica-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/paketo-buildpacks/pipeline-builder/actions"
)

const liberica = "liberica"

func main() {
inputs := actions.NewInputs()

Expand Down Expand Up @@ -171,12 +173,16 @@ func main() {

func determineNikVersion(r Release, additionalOutputs actions.Outputs) string {
key := ""
if v, err := actions.NormalizeVersion(r.Components[0].Version); err != nil {
componentVersion, err := r.retrieveComponentVersionFor(liberica)
if err != nil {
panic(err)
}
if v, err := actions.NormalizeVersion(componentVersion); err != nil {
panic(err)
} else {
key = v
// Use NIK version for CPE/PURL
re := regexp.MustCompile(`\/vm/([\d]+\.[\d]+\.[\d]+\.?[\d]?)\/`)
re := regexp.MustCompile(`/LibericaNIK/releases/download/([\d]+\.[\d]+\.[\d]+\.?[\d]?)\+.*-`)
matches := re.FindStringSubmatch(r.DownloadURL)
if matches == nil || len(matches) != 2 {
panic(fmt.Errorf("unable to parse NIK version: %s", matches))
Expand All @@ -194,6 +200,16 @@ type Release struct {
BuildVersion int `json:"buildVersion"`
DownloadURL string `json:"downloadUrl"`
Components []struct {
Version string `json:"version"`
Version string `json:"version"`
Component string `json:"component"`
}
}

func (r Release) retrieveComponentVersionFor(componentName string) (string, error) {
for _, v := range r.Components {
if v.Component == componentName {
return v.Version, nil
}
}
return "", fmt.Errorf("unable to find a component for: %s", componentName)
}

0 comments on commit 3ee1e65

Please sign in to comment.