1
0
mirror of https://github.com/rancher/steve.git synced 2025-09-08 02:39:26 +00:00

#50914 - Changed ParseQuery projectornamespace Handling (#718)

* changed ParseQuery projectornamespace handling

* addressed comments from eric/chad and tom

* fixing lint error

* added resourceVersion to list

* updated mocks

* updated tests

* Update tests after rebase

---------

Co-authored-by: Tom Lebreux <tom.lebreux@suse.com>
This commit is contained in:
Felipe Gehrke
2025-07-17 14:51:13 -03:00
committed by GitHub
parent 0c2c554c8c
commit b556256ed3
8 changed files with 67 additions and 20 deletions

View File

@@ -48,6 +48,7 @@ type WatchFilter struct {
type ByOptionsLister interface {
ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, string, error)
Watch(ctx context.Context, options WatchOptions, eventsCh chan<- watch.Event) error
GetLatestResourceVersion() []string
}
// this is set to a var so that it can be overridden by test code for mocking purposes

View File

@@ -44,6 +44,20 @@ func (m *MockByOptionsLister) EXPECT() *MockByOptionsListerMockRecorder {
return m.recorder
}
// GetLatestResourceVersion mocks base method.
func (m *MockByOptionsLister) GetLatestResourceVersion() []string {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetLatestResourceVersion")
ret0, _ := ret[0].([]string)
return ret0
}
// GetLatestResourceVersion indicates an expected call of GetLatestResourceVersion.
func (mr *MockByOptionsListerMockRecorder) GetLatestResourceVersion() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLatestResourceVersion", reflect.TypeOf((*MockByOptionsLister)(nil).GetLatestResourceVersion))
}
// ListByOptions mocks base method.
func (m *MockByOptionsLister) ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, string, error) {
m.ctrl.T.Helper()

View File

@@ -285,6 +285,16 @@ func NewListOptionIndexer(ctx context.Context, s Store, opts ListOptionIndexerOp
return l, nil
}
func (l *ListOptionIndexer) GetLatestResourceVersion() []string {
var latestRV []string
l.latestRVLock.RLock()
latestRV = []string{l.latestRV}
l.latestRVLock.RUnlock()
return latestRV
}
func (l *ListOptionIndexer) Watch(ctx context.Context, opts WatchOptions, eventsCh chan<- watch.Event) error {
l.latestRVLock.RLock()
latestRV := l.latestRV