Skip to content

Commit

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

This reverts commit eaa8fb1.
  • Loading branch information
LucaGuerra committed Jan 18, 2024
1 parent 6c0d1bc commit 6d5ef20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 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_semver"
EngineVersionKey = "engine_version"
// 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
17 changes: 4 additions & 13 deletions build/registry/pkg/oci/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"errors"
"fmt"
"os"
"strconv"
"strings"

"github.com/blang/semver"
Expand Down Expand Up @@ -64,25 +65,15 @@ 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.
tokens := strings.Split(fileScanner.Text(), ":")
reqVer, err := semver.Parse(tokens[1])
reqVer, err := semver.ParseTolerant(tokens[1])
if err != nil {
reqVer, err = semver.ParseTolerant(tokens[1])
if err != nil {
return nil, fmt.Errorf("unable to parse requirement %q: expected a numeric value or a valid semver string", tokens[1])
}
reqVer = semver.Version{
Major: 0,
Minor: reqVer.Major,
Patch: 0,
}
return nil, fmt.Errorf("unable to parse to semVer the version requirement %q", tokens[1])
}

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

Expand Down

0 comments on commit 6d5ef20

Please sign in to comment.