Skip to content

Commit

Permalink
Merge pull request #581 from paketo-buildpacks/liberty-purl-cpe
Browse files Browse the repository at this point in the history
Add separate CPE & PURL version
  • Loading branch information
Daniel Mikusa authored Mar 2, 2022
2 parents 942f5e6 + 7892608 commit df0d615
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions actions/liberty-dependency/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func main() {
panic(fmt.Errorf("unable to decode payload\n%w", err))
}

originalVersions := map[string]string{}
versions := make(actions.Versions)
for _, v := range raw.Versioning.Versions {
w := fmt.Sprintf("%s/%s/%s/%s", u, strings.ReplaceAll(g, ".", "/"), a, v)
Expand All @@ -80,14 +81,23 @@ func main() {
panic(err)
}

originalVersions[n] = v
versions[n] = w
}

if o, err := versions.GetLatest(inputs); err != nil {
panic(err)
} else {
o.Write(os.Stdout)
latestVersion, err := versions.GetLatestVersion(inputs)
if err != nil {
panic(fmt.Errorf("unable to get latest version\n%w", err))
}

outputs, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, nil)
if err != nil {
panic(fmt.Errorf("unable to create outputs\n%w", err))
}

outputs["cpe"] = originalVersions[latestVersion.Original()]
outputs["purl"] = originalVersions[latestVersion.Original()]
outputs.Write(os.Stdout)
}

var ExtendedVersionPattern = regexp.MustCompile(`^v?([\d]+)\.?([\d]+)?\.?([\d]+)?[-+.]?(.*)$`)
Expand All @@ -106,7 +116,7 @@ func NormalizeVersion(raw string) (string, error) {
}

return "", fmt.Errorf("unable to parse %s as a extended version (%s)", raw, ExtendedVersionPattern)
}
}

type Metadata struct {
Versioning Versioning `xml:"versioning"`
Expand Down

0 comments on commit df0d615

Please sign in to comment.