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

Add separate CPE & PURL version #581

Merged
merged 1 commit into from
Mar 2, 2022
Merged
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
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