Skip to content

Commit

Permalink
update(build): create new engine_version_semver string for new plugin…
Browse files Browse the repository at this point in the history
… rulesfiles artifact configs

Signed-off-by: Lorenzo Susini <[email protected]>
  • Loading branch information
loresuso committed Nov 2, 2023
1 parent 16306f2 commit efdd652
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/registry/pkg/common/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
RulesArtifactSuffix = "-rules"
// EngineVersionKey is the name given to all the engine requirements.
// The same name used by Falco when outputting the engine version.
EngineVersionKey = "engine_version"
EngineVersionKey = "engine_version_semver"
// PluginAPIVersion is the name givet to the plugin api version requirements.
// The same name used by Falco when outputting the plugin api version
PluginAPIVersion = "plugin_api_version"
Expand Down
15 changes: 12 additions & 3 deletions build/registry/pkg/oci/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,24 @@ func rulesfileRequirement(filePath string) (*oci.ArtifactRequirement, error) {
}

// Split the requirement and parse the version to semVer.
// In case the requirement was expressed as a numeric value,
// we convert it to semver and treat it as minor version.
var version string
tokens := strings.Split(fileScanner.Text(), ":")
reqVer, err := semver.ParseTolerant(tokens[1])
reqVer, err := semver.Parse(tokens[1])
if err != nil {
return nil, fmt.Errorf("unable to parse to semVer the version requirement %q", tokens[1])
reqVer = semver.ParseTolerant(tokens[1])
if err != nil {
return nil, fmt.Errorf("unable to parse requirement %q: %w", tokens[1], err)
}
version = "0." + strconv.FormatUint(reqVer.Major, 10) + ".0"
} else {
version = reqVer.String()
}

return &oci.ArtifactRequirement{
Name: common.EngineVersionKey,
Version: strconv.FormatUint(reqVer.Major, 10),
Version: version,
}, nil
}

Expand Down

0 comments on commit efdd652

Please sign in to comment.