Skip to content

Commit 30d4d2e

Browse files
committed
fix: parse channel version for pre-apply check
Signed-off-by: Eiichi Kitagawa <[email protected]>
1 parent b485065 commit 30d4d2e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/product/common/api/mcr_config.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ func processVersionChannelMatch(config *MCRConfig) error {
113113
return nil
114114
}
115115

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

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

129132
return nil

0 commit comments

Comments
 (0)