Skip to content

WIP: fix: parse channel version for pre-apply check #580

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions pkg/product/common/api/mcr_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ func processVersionChannelMatch(config *MCRConfig) error {
return nil
}

chanParts := strings.Split(config.Channel, "-")
channel := strings.Split(config.Channel, "/")[0] // remove "/fips" or anything after "/"
chanParts := strings.Split(channel, "-")
if len(chanParts) == 1 {
return fmt.Errorf("%w; channel has no version (%s)", ErrChannelDoesntMatchVersion, config.Channel)
}
Expand All @@ -122,8 +123,10 @@ func processVersionChannelMatch(config *MCRConfig) error {
return fmt.Errorf("%w; channel parts could not be interpreted", ErrChannelDoesntMatchVersion)
}

if !strings.HasPrefix(chanParts[1], config.Version) {
return fmt.Errorf("%w; MCR version does not match channel-version '%s' vs '%s'", ErrChannelDoesntMatchVersion, chanParts[1], config.Version)
configVersionParts := strings.Split(config.Version, ".")
configChannel := configVersionParts[0] + "." + configVersionParts[1] // take only the major and minor version
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you limiting to major.minor versions and omitting the patch. The entire point to the channel validation is that in order to install a repo for a pinned patch version of MCR25, you need to use the major.minor.patch path for the repo information.

E.G.

if !strings.HasPrefix(chanParts[1], configChannel) {
return fmt.Errorf("%w; MCR version does not match channel-version '%s' vs '%s'", ErrChannelDoesntMatchVersion, chanParts[1], configChannel)
}

return nil
Expand Down
Loading