@@ -40,6 +40,7 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx
4040 var (
4141 resolvedBundle * declcfg.Bundle
4242 resolvedDeprecation * declcfg.Deprecation
43+ oldBundle * declcfg.Bundle
4344 )
4445
4546 if err := r .WalkCatalogsFunc (ctx , packageName , func (ctx context.Context , cat * catalogd.ClusterCatalog , packageFBC * declcfg.DeclarativeConfig , err error ) error {
@@ -101,6 +102,7 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx
101102 return nil
102103 }
103104 if compare .ByVersion (* resolvedBundle , thisBundle ) < 0 {
105+ oldBundle = & thisBundle
104106 return nil
105107 }
106108 }
@@ -116,15 +118,26 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx
116118 if installedBundle != nil {
117119 errPrefix = fmt .Sprintf ("error upgrading from currently installed version %q: " , installedBundle .Version )
118120 }
119- switch {
120- case versionRange != "" && channelName != "" :
121- return nil , nil , nil , fmt .Errorf ("%sno package %q matching version %q in channel %q found" , errPrefix , packageName , versionRange , channelName )
122- case versionRange != "" :
123- return nil , nil , nil , fmt .Errorf ("%sno package %q matching version %q found" , errPrefix , packageName , versionRange )
124- case channelName != "" :
125- return nil , nil , nil , fmt .Errorf ("%sno package %q in channel %q found" , errPrefix , packageName , channelName )
126- default :
127- return nil , nil , nil , fmt .Errorf ("%sno package %q found" , errPrefix , packageName )
121+ if oldBundle == nil {
122+ switch {
123+ case versionRange != "" && channelName != "" :
124+ return nil , nil , nil , fmt .Errorf ("%sno package %q matching version %q in channel %q found" , errPrefix , packageName , versionRange , channelName )
125+ case versionRange != "" :
126+ return nil , nil , nil , fmt .Errorf ("%sno package %q matching version %q found" , errPrefix , packageName , versionRange )
127+ case channelName != "" :
128+ return nil , nil , nil , fmt .Errorf ("%sno package %q in channel %q found" , errPrefix , packageName , channelName )
129+ default :
130+ return nil , nil , nil , fmt .Errorf ("%sno package %q found" , errPrefix , packageName )
131+ }
132+ } else {
133+ switch {
134+ case versionRange != "" && channelName != "" :
135+ return nil , nil , nil , fmt .Errorf ("%sdesired package %q with version %q in channel %q does not match any successor of %q" , errPrefix , packageName , versionRange , channelName , installedBundle .Version )
136+ case versionRange != "" :
137+ return nil , nil , nil , fmt .Errorf ("%sdesired package %q with version %q does not match any successors of %q" , errPrefix , packageName , versionRange , installedBundle .Version )
138+ default :
139+ return nil , nil , nil , fmt .Errorf ("%sno package %q found" , errPrefix , packageName )
140+ }
128141 }
129142 }
130143
0 commit comments