From 10b9a8225811488ec29520ac3a3fc045ff0b2989 Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Wed, 16 Feb 2022 13:05:26 +0000 Subject: [PATCH] Updated bellsoft action to set purl to NIK version --- actions/bellsoft-liberica-dependency/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/actions/bellsoft-liberica-dependency/main.go b/actions/bellsoft-liberica-dependency/main.go index 9ae257b3..837da803 100644 --- a/actions/bellsoft-liberica-dependency/main.go +++ b/actions/bellsoft-liberica-dependency/main.go @@ -21,6 +21,7 @@ import ( "fmt" "net/http" "os" + "regexp" "github.com/paketo-buildpacks/pipeline-builder/actions" ) @@ -81,6 +82,7 @@ func main() { } versions := make(actions.Versions) + additionalOutputs := make(actions.Outputs) for _, r := range raw { key := fmt.Sprintf("%d.%d.%d-%d", r.FeatureVersion, r.InterimVersion, r.UpdateVersion, r.BuildVersion) @@ -91,6 +93,14 @@ func main() { s = fmt.Sprintf("%s-%s", s, v[4]) } key = s + + // Use NIK version for CPE/PURL + re := regexp.MustCompile(`\/vm/([\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)) + } + additionalOutputs["purl"] = matches[1] } } versions[key] = r.DownloadURL @@ -101,7 +111,7 @@ func main() { panic(fmt.Errorf("unable to get latest version\n%w", err)) } - outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil) + outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, additionalOutputs) if err != nil { panic(fmt.Errorf("unable to create outputs\n%w", err)) }