Skip to content

Commit

Permalink
Fix to ensure operator not found error exits with correct status (#797)
Browse files Browse the repository at this point in the history
Co-authored-by: Luigi Mario Zuccarelli <luzuccar@redhat.com>
  • Loading branch information
openshift-cherrypick-robot and lmzuccarelli committed Mar 12, 2024
1 parent 6874730 commit 1a64678
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 9 additions & 2 deletions pkg/cli/mirror/operator.go
Expand Up @@ -445,8 +445,15 @@ func (o *OperatorOptions) verifyDC(dic diff.DiffIncludeConfig, dc *declcfg.Decla
klog.V(2).Infof("Checking for package: %s", pkg)

if !dcMap[pkg.Name] {
// The operator package wasn't found. Log the error and continue on.
o.Logger.Errorf("Operator %s was not found, please check name, minVersion, maxVersion, and channels in the config file.", pkg.Name)
// The operator package wasn't found.
// OCPBUGS-25003 - request is to exit immediately
// Log the error and continue if --continue-on-error flag is set
msg := fmt.Sprintf("Operator %s was not found, please check name, minVersion, maxVersion, and channels in the config file.", pkg.Name)
if !o.MirrorOptions.ContinueOnError {
return fmt.Errorf(msg)
} else {
o.Logger.Errorf(msg)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/cli/mirror/operator_test.go
Expand Up @@ -164,7 +164,8 @@ func TestPinImages(t *testing.T) {
func TestVerifyDC(t *testing.T) {

mo := &MirrorOptions{
RootOptions: &cli.RootOptions{},
RootOptions: &cli.RootOptions{},
ContinueOnError: true,
}
o := NewOperatorOptions(mo)
o.complete()
Expand Down

0 comments on commit 1a64678

Please sign in to comment.