-
Notifications
You must be signed in to change notification settings - Fork 250
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(validation): Remove default channel validation from bundle lib #408
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,32 +293,6 @@ func ValidateAnnotations(existing, expected []byte) error { | |
return utilerrors.NewAggregate(errs) | ||
} | ||
|
||
// ValidateChannelDefault validates provided default channel to ensure it exists in | ||
// provided channel list. | ||
func ValidateChannelDefault(channels, channelDefault string) (string, error) { | ||
var chanDefault string | ||
var chanErr error | ||
channelList := strings.Split(channels, ",") | ||
|
||
if containsString(channelList, "") { | ||
return chanDefault, fmt.Errorf("invalid channels are provided: %s", channels) | ||
} | ||
|
||
if channelDefault != "" { | ||
for _, channel := range channelList { | ||
if channel == channelDefault { | ||
chanDefault = channelDefault | ||
break | ||
} | ||
} | ||
if chanDefault == "" { | ||
chanDefault = channelList[0] | ||
chanErr = fmt.Errorf(`The channel list "%s" doesn't contain channelDefault "%s"`, channels, channelDefault) | ||
} | ||
} | ||
return chanDefault, chanErr | ||
} | ||
|
||
// GenerateAnnotations builds annotations.yaml with mediatype, manifests & | ||
// metadata directories in bundle image, package name, channels and default | ||
// channels information. | ||
|
@@ -334,12 +308,7 @@ func GenerateAnnotations(mediaType, manifests, metadata, packageName, channels, | |
}, | ||
} | ||
|
||
chanDefault, err := ValidateChannelDefault(channels, channelDefault) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
annotations.Annotations[ChannelDefaultLabel] = chanDefault | ||
annotations.Annotations[ChannelDefaultLabel] = channelDefault | ||
|
||
afile, err := yaml.Marshal(annotations) | ||
if err != nil { | ||
|
@@ -355,11 +324,6 @@ func GenerateAnnotations(mediaType, manifests, metadata, packageName, channels, | |
func GenerateDockerfile(mediaType, manifests, metadata, copyManifestDir, copyMetadataDir, workingDir, packageName, channels, channelDefault string) ([]byte, error) { | ||
var fileContent string | ||
|
||
chanDefault, err := ValidateChannelDefault(channels, channelDefault) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
relativeManifestDirectory, err := filepath.Rel(workingDir, copyManifestDir) | ||
if err != nil { | ||
return nil, err | ||
|
@@ -379,7 +343,7 @@ func GenerateDockerfile(mediaType, manifests, metadata, copyManifestDir, copyMet | |
fileContent += fmt.Sprintf("LABEL %s=%s\n", MetadataLabel, metadata) | ||
fileContent += fmt.Sprintf("LABEL %s=%s\n", PackageLabel, packageName) | ||
fileContent += fmt.Sprintf("LABEL %s=%s\n", ChannelsLabel, channels) | ||
fileContent += fmt.Sprintf("LABEL %s=%s\n\n", ChannelDefaultLabel, chanDefault) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is OK to not have a defaultChannel value AKA empty string because in annotation generation function, there is a case where inferred defaultChannel is set to empty string. @Bowenislandsong Can you double-confirm this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't it be better to just not set this label at all? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. Later when added to Index, the default behavior will kick in (right now the default behavior is to add the first channel as default). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fileContent += fmt.Sprintf("LABEL %s=%s\n\n", ChannelDefaultLabel, channelDefault) | ||
|
||
// CONTENT | ||
fileContent += fmt.Sprintf("COPY %s %s\n", relativeManifestDirectory, "/manifests/") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
channelDefault
is not an empty string, we still want to verify that it exists inchannels
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are cases when that is totally fine to have default channel not on the list. @shawn-hurley Can you explain this further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default channel mentioned in the bundle != Default channel on the package