mirror of
https://github.com/rancher/steve.git
synced 2025-09-16 07:18:28 +00:00
Sort-indirect PR broken into smaller parts: part 3/6 - pass listOptions by reference (#612)
* Move types related to list options and sql queries into their own package. The problem having these in the informer package is that eventually code in other packages will need to import `informer` only for constants or types, but some members of the informer package may already depend on those. Best to move type definitions into their own simpler package.
This commit is contained in:
@@ -57,7 +57,7 @@ type Cache interface {
|
||||
// - the total number of resources (returned list might be a subset depending on pagination options in lo)
|
||||
// - a continue token, if there are more pages after the returned one
|
||||
// - an error instead of all of the above if anything went wrong
|
||||
ListByOptions(ctx context.Context, lo sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, string, error)
|
||||
ListByOptions(ctx context.Context, lo *sqltypes.ListOptions, partitions []partition.Partition, namespace string) (*unstructured.UnstructuredList, int, string, error)
|
||||
}
|
||||
|
||||
func k8sOpToRancherOp(k8sOp selection.Operator) (sqltypes.Op, bool, error) {
|
||||
@@ -202,7 +202,7 @@ func splitQuery(query string) []string {
|
||||
func parseNamespaceOrProjectFilters(ctx context.Context, projOrNS string, op sqltypes.Op, namespaceInformer Cache) ([]sqltypes.Filter, error) {
|
||||
var filters []sqltypes.Filter
|
||||
for _, pn := range strings.Split(projOrNS, ",") {
|
||||
uList, _, _, err := namespaceInformer.ListByOptions(ctx, sqltypes.ListOptions{
|
||||
uList, _, _, err := namespaceInformer.ListByOptions(ctx, &sqltypes.ListOptions{
|
||||
Filters: []sqltypes.OrFilter{
|
||||
{
|
||||
Filters: []sqltypes.Filter{
|
||||
|
@@ -82,7 +82,7 @@ func TestParseQuery(t *testing.T) {
|
||||
},
|
||||
}
|
||||
nsc := NewMockCache(gomock.NewController(t))
|
||||
nsc.EXPECT().ListByOptions(context.Background(), sqltypes.ListOptions{
|
||||
nsc.EXPECT().ListByOptions(context.Background(), &sqltypes.ListOptions{
|
||||
Filters: []sqltypes.OrFilter{
|
||||
{
|
||||
Filters: []sqltypes.Filter{
|
||||
@@ -132,7 +132,7 @@ func TestParseQuery(t *testing.T) {
|
||||
errExpected: true,
|
||||
setupNSCache: func() Cache {
|
||||
nsi := NewMockCache(gomock.NewController(t))
|
||||
nsi.EXPECT().ListByOptions(context.Background(), sqltypes.ListOptions{
|
||||
nsi.EXPECT().ListByOptions(context.Background(), &sqltypes.ListOptions{
|
||||
Filters: []sqltypes.OrFilter{
|
||||
{
|
||||
Filters: []sqltypes.Filter{
|
||||
@@ -185,7 +185,7 @@ func TestParseQuery(t *testing.T) {
|
||||
Items: []unstructured.Unstructured{},
|
||||
}
|
||||
nsi := NewMockCache(gomock.NewController(t))
|
||||
nsi.EXPECT().ListByOptions(context.Background(), sqltypes.ListOptions{
|
||||
nsi.EXPECT().ListByOptions(context.Background(), &sqltypes.ListOptions{
|
||||
Filters: []sqltypes.OrFilter{
|
||||
{
|
||||
Filters: []sqltypes.Filter{
|
||||
|
@@ -43,7 +43,7 @@ func (m *MockCache) EXPECT() *MockCacheMockRecorder {
|
||||
}
|
||||
|
||||
// ListByOptions mocks base method.
|
||||
func (m *MockCache) ListByOptions(arg0 context.Context, arg1 sqltypes.ListOptions, arg2 []partition.Partition, arg3 string) (*unstructured.UnstructuredList, int, string, error) {
|
||||
func (m *MockCache) ListByOptions(arg0 context.Context, arg1 *sqltypes.ListOptions, arg2 []partition.Partition, arg3 string) (*unstructured.UnstructuredList, int, string, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListByOptions", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*unstructured.UnstructuredList)
|
||||
|
Reference in New Issue
Block a user