Skip to content

Commit

Permalink
Fix to ensure operator not found error exits with correct status (#770)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmzuccarelli committed Jan 9, 2024
1 parent 82781f2 commit 92380ac
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 92380ac

Please sign in to comment.