@@ -16,6 +16,7 @@ type ChannelEntryStream interface {
16
16
}
17
17
18
18
type RegistryClientInterface interface {
19
+ client.Interface
19
20
FindBundleThatProvides (ctx context.Context , group , version , kind , pkgName string ) (* registryapi.Bundle , error )
20
21
GetLatestChannelEntriesThatProvide (ctx context.Context , group , version , kind string ) (* ChannelEntryIterator , error )
21
22
}
@@ -47,19 +48,21 @@ func (ceit *ChannelEntryIterator) Error() error {
47
48
return ceit .error
48
49
}
49
50
50
- type OLMRegistryClient struct {
51
+ type RegistryClient struct {
52
+ client.Interface
51
53
Client * client.Client
52
54
}
53
55
54
- func NewRegistryClient (client * client.Client ) * OLMRegistryClient {
55
- return & OLMRegistryClient { Client : client }
56
+ func NewRegistryClient (client * client.Client ) * RegistryClient {
57
+ return & RegistryClient { client , client }
56
58
}
57
59
58
- var _ RegistryClientInterface = & OLMRegistryClient {}
60
+ var _ RegistryClientInterface = & RegistryClient {}
61
+ var _ client.Interface = & RegistryClient {}
59
62
60
63
// GetLatestChannelEntriesThatProvide uses registry client to get a list of
61
64
// latest channel entries that provide the requested API (via an iterator)
62
- func (rc * OLMRegistryClient ) GetLatestChannelEntriesThatProvide (ctx context.Context , group , version , kind string ) (* ChannelEntryIterator , error ) {
65
+ func (rc * RegistryClient ) GetLatestChannelEntriesThatProvide (ctx context.Context , group , version , kind string ) (* ChannelEntryIterator , error ) {
63
66
stream , err := rc .Client .Registry .GetLatestChannelEntriesThatProvide (ctx , & registryapi.GetLatestProvidersRequest {Group : group , Version : version , Kind : kind })
64
67
if err != nil {
65
68
return nil , err
@@ -69,7 +72,7 @@ func (rc *OLMRegistryClient) GetLatestChannelEntriesThatProvide(ctx context.Cont
69
72
70
73
// FindBundleThatProvides returns a bundle that provides the request API and
71
74
// doesn't belong to the provided package
72
- func (rc * OLMRegistryClient ) FindBundleThatProvides (ctx context.Context , group , version , kind , pkgName string ) (* registryapi.Bundle , error ) {
75
+ func (rc * RegistryClient ) FindBundleThatProvides (ctx context.Context , group , version , kind , pkgName string ) (* registryapi.Bundle , error ) {
73
76
it , err := rc .GetLatestChannelEntriesThatProvide (ctx , group , version , kind )
74
77
if err != nil {
75
78
return nil , err
@@ -88,18 +91,22 @@ func (rc *OLMRegistryClient) FindBundleThatProvides(ctx context.Context, group,
88
91
// FilterChannelEntries filters out a channel entries that provide the requested
89
92
// API and come from the same package with original operator and returns the
90
93
// first entry on the list
91
- func (rc * OLMRegistryClient ) filterChannelEntries (it * ChannelEntryIterator , pkgName string ) * opregistry.ChannelEntry {
92
- var entry * opregistry.ChannelEntry
94
+ func (rc * RegistryClient ) filterChannelEntries (it * ChannelEntryIterator , pkgName string ) * opregistry.ChannelEntry {
95
+ var entries [] * opregistry.ChannelEntry
93
96
for e := it .Next (); e != nil ; e = it .Next () {
94
97
if e .PackageName != pkgName {
95
- entry = & opregistry.ChannelEntry {
98
+ entry : = & opregistry.ChannelEntry {
96
99
PackageName : e .PackageName ,
97
100
ChannelName : e .ChannelName ,
98
101
BundleName : e .BundleName ,
99
102
Replaces : e .Replaces ,
100
103
}
101
- break
104
+ entries = append ( entries , entry )
102
105
}
103
106
}
104
- return entry
107
+
108
+ if entries != nil {
109
+ return entries [0 ]
110
+ }
111
+ return nil
105
112
}
0 commit comments