@@ -40,6 +40,7 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx
40
40
var (
41
41
resolvedBundle * declcfg.Bundle
42
42
resolvedDeprecation * declcfg.Deprecation
43
+ oldBundle * declcfg.Bundle
43
44
)
44
45
45
46
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
101
102
return nil
102
103
}
103
104
if compare .ByVersion (* resolvedBundle , thisBundle ) < 0 {
105
+ oldBundle = & thisBundle
104
106
return nil
105
107
}
106
108
}
@@ -116,15 +118,26 @@ func (r *CatalogResolver) Resolve(ctx context.Context, ext *ocv1alpha1.ClusterEx
116
118
if installedBundle != nil {
117
119
errPrefix = fmt .Sprintf ("error upgrading from currently installed version %q: " , installedBundle .Version )
118
120
}
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
+ }
128
141
}
129
142
}
130
143
0 commit comments