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

fix(packaging): fix version number for fips build #1710

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions pkg/extension/sumologicextension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -1064,12 +1064,19 @@ func getHostname(logger *zap.Logger) (string, error) {
// cleaned up. All other version formats will remain the same.
// Cleaned up format: 0.108.0-sumo-2-4d57200692d5c5c39effad4ae3b29fef79209113
func cleanupBuildVersion(version string) string {
pattern := "(^[0-9]+\\.[0-9]+\\.[0-9]+-sumo-[0-9]+)-[0-9a-f]{40}$"
pattern := "^v?([0-9]+\\.[0-9]+\\.[0-9]+-sumo-[0-9]+)(-[0-9a-f]{40}){0,1}(-fips){0,1}$"
re := regexp.MustCompile(pattern)

sm := re.FindAllStringSubmatch(version, 1)
if len(sm) == 1 {
ver := sm[0][1]
matches := re.FindAllStringSubmatch(version, 1)
if len(matches) != 1 {
return version
}
subMatches := matches[0]
if len(subMatches) > 1 {
ver := subMatches[1]
if len(subMatches) == 4 {
ver += subMatches[3]
}
return "v" + ver
}

Expand Down
44 changes: 40 additions & 4 deletions pkg/extension/sumologicextension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1604,17 +1604,53 @@ func Test_cleanupBuildVersion(t *testing.T) {
want string
}{
{
name: "already ok",
args: args{version: "0.108.0-sumo-2"},
want: "v0.108.0-sumo-2",
}, {
name: "no hash fips",
args: args{version: "0.108.0-sumo-2-fips"},
want: "v0.108.0-sumo-2-fips",
}, {
name: "with hash",
args: args{version: "0.108.0-sumo-2-4d57200692d5c5c39effad4ae3b29fef79209113"},
want: "v0.108.0-sumo-2",
}, {
name: "already ok",
name: "hash fips",
args: args{version: "0.108.0-sumo-2-4d57200692d5c5c39effad4ae3b29fef79209113-fips"},
want: "v0.108.0-sumo-2-fips",
}, {
name: "v already ok",
args: args{version: "v0.108.0-sumo-2"},
want: "v0.108.0-sumo-2",
}, {
name: "non v",
args: args{version: "0.108.0-sumo-2"},
want: "0.108.0-sumo-2",
name: "v no hash fips",
args: args{version: "v0.108.0-sumo-2-fips"},
want: "v0.108.0-sumo-2-fips",
}, {
name: "v with hash",
args: args{version: "v0.108.0-sumo-2-4d57200692d5c5c39effad4ae3b29fef79209113"},
want: "v0.108.0-sumo-2",
}, {
name: "v hash fips",
args: args{version: "v0.108.0-sumo-2-4d57200692d5c5c39effad4ae3b29fef79209113-fips"},
want: "v0.108.0-sumo-2-fips",
}, {
name: "no patch version",
args: args{version: "0.108-sumo-2"},
want: "0.108-sumo-2",
}, {
name: "v no patch version",
args: args{version: "v0.108-sumo-2"},
want: "v0.108-sumo-2",
}, {
name: "no sumo version",
args: args{version: "0.108-0-sumo"},
want: "0.108-0-sumo",
}, {
name: "v no patch version",
args: args{version: "v0.108-0-sumo"},
want: "v0.108-0-sumo",
}, {
name: "nonsense",
args: args{version: "hfiwe-23rhc8eg.fhf"},
Expand Down
Loading