diff --git a/pkg/product/common/api/mcr_config.go b/pkg/product/common/api/mcr_config.go index 6ed1a04e..0c16afe3 100644 --- a/pkg/product/common/api/mcr_config.go +++ b/pkg/product/common/api/mcr_config.go @@ -3,6 +3,7 @@ package api import ( "errors" "fmt" + "regexp" "strings" "github.com/Mirantis/launchpad/pkg/constant" @@ -15,7 +16,8 @@ var ( minVersionNeedsMatchingChannel, _ = version.NewVersion("25.0.0") ErrChannelDoesntMatchVersion = errors.New("MCR version and channel don't match, which is required for versions >= 25.0.0") - fipsChannelSuffix = "/fips" // this suffix is removed from channels for version comparison testing + fipsChannelSuffix = "/fips" // this suffix is removed from channels for version comparison testing + suffixPattern = regexp.MustCompile(`-(tp|rc)\d+$`) // this filters out internal build suffix like -tp1 ) type DockerInfo struct { @@ -125,7 +127,8 @@ func processVersionChannelMatch(config *MCRConfig) error { return fmt.Errorf("%w; channel parts could not be interpreted", ErrChannelDoesntMatchVersion) } - if !strings.HasPrefix(chanParts[1], config.Version) { + configVerNum := suffixPattern.ReplaceAllString(config.Version, "") // remove build number + if !strings.HasPrefix(chanParts[1], configVerNum) { return fmt.Errorf("%w; MCR version does not match channel-version '%s' vs '%s'", ErrChannelDoesntMatchVersion, chanParts[1], config.Version) } diff --git a/pkg/product/common/api/mcr_config_validate_test.go b/pkg/product/common/api/mcr_config_validate_test.go index da662ecb..0b2c0d31 100644 --- a/pkg/product/common/api/mcr_config_validate_test.go +++ b/pkg/product/common/api/mcr_config_validate_test.go @@ -145,3 +145,21 @@ func Test_ValidateWildcardChannelVersionFIPS(t *testing.T) { require.Nil(t, configFips.Validate(), "received unexpected error for valid MCR config which uses a wildcard version and specific channel w/ FIPS") } + +func Test_ValidateInternalBuild(t *testing.T) { + config := commonapi.MCRConfig{ + Version: "25.0.12-tp1", + Channel: "test-25.0.12", + } + + require.Nil(t, config.Validate(), "received unexpected error for valid MCR config which contains internal build suffix -tp1") +} + +func Test_ValidateInternalBuildFIPS(t *testing.T) { + config := commonapi.MCRConfig{ + Version: "25.0.12-rc2", + Channel: "test-25.0.12/fips", + } + + require.Nil(t, config.Validate(), "received unexpected error for valid MCR config which contains internal build suffix -tp1 w/ FIPS") +} \ No newline at end of file