store

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

mockFactory := new(MockFactory) mockItemStore := new(MockItemStore) mockFactory.On("Item").Return(mockItemStore) mockItemStore.On("Create", ctx, item, opts).Return(nil)

err := mockFactory.Item().Create(ctx, item, opts) assert.NoError(t, err)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetClient

func SetClient(factory Factory)

SetClient set the iam store client.

Types

type Factory

type Factory interface {
	Users() UserStore
	Secrets() SecretStore
	Policies() PolicyStore
	PolicyAudits() PolicyAuditStore
	Items() ItemStore
	ItemAttributes() ItemAttributesStore
	ItemImage() ItemImageStore
	Close() error
}

Factory defines the iam platform storage interface.

func Client

func Client() Factory

Client return the store client instance.

type ItemAttributesStore

type ItemAttributesStore interface {
	Create(ctx context.Context, itemAttribute *v1.ItemAttributes, opts metav1.CreateOptions) error
	Update(ctx context.Context, itemAttribute *v1.ItemAttributes, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
	Get(ctx context.Context, id int, opts metav1.GetOptions) (*v1.ItemAttributes, error)
	FindByAttributes(ctx context.Context, attributes *v1.ItemAttributes, opts metav1.ListOptions) (*v1.ItemList, error)
}

ItemAttributeSrv defines functions used to handle item attribute requests.

type ItemImageStore

type ItemImageStore interface {
	Create(ctx context.Context, itemAttribute *v1.ItemImage, opts metav1.CreateOptions) error
	Update(ctx context.Context, itemAttribute *v1.ItemImage, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, id uint64, opts metav1.DeleteOptions) error
	Get(ctx context.Context, id uint64, opts metav1.GetOptions) (*v1.ItemImage, error)
	List(ctx context.Context, itemID uint64, opts metav1.ListOptions) ([]*v1.ItemImage, error) // 添加这行
}

ItemAttributeSrv defines functions used to handle item attribute requests.

type ItemStore

type ItemStore interface {
	Create(ctx context.Context, item *v1.Item, opts metav1.CreateOptions) error
	Update(ctx context.Context, item *v1.Item, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error
	Get(ctx context.Context, id int, opts metav1.GetOptions) (*v1.Item, error)
	List(ctx context.Context, opts metav1.ListOptions) (*v1.ItemList, error)
}

ItemStore defines the methods for working with items and their related details in the datastore.

type MockFactory

type MockFactory struct {
	mock.Mock
}

func (*MockFactory) Close

func (m *MockFactory) Close() error

func (*MockFactory) ItemAttributes

func (m *MockFactory) ItemAttributes() ItemAttributesStore

func (*MockFactory) ItemImage

func (m *MockFactory) ItemImage() ItemImageStore

func (*MockFactory) Items

func (m *MockFactory) Items() ItemStore

func (*MockFactory) Policies

func (m *MockFactory) Policies() PolicyStore

func (*MockFactory) PolicyAudits

func (m *MockFactory) PolicyAudits() PolicyAuditStore

func (*MockFactory) Secrets

func (m *MockFactory) Secrets() SecretStore

func (*MockFactory) Users

func (m *MockFactory) Users() UserStore

type MockItemStore

type MockItemStore struct {
	mock.Mock
}

func (*MockItemStore) Create

func (m *MockItemStore) Create(ctx context.Context, item *model.Item, opts metav1.CreateOptions) error

func (*MockItemStore) Delete

func (m *MockItemStore) Delete(ctx context.Context, id int, opts metav1.DeleteOptions) error

func (*MockItemStore) Get

func (m *MockItemStore) Get(ctx context.Context, id int, opts metav1.GetOptions) (*model.Item, error)

func (*MockItemStore) List

func (*MockItemStore) Update

func (m *MockItemStore) Update(ctx context.Context, item *model.Item, opts metav1.UpdateOptions) error

type PolicyAuditStore

type PolicyAuditStore interface {
	ClearOutdated(ctx context.Context, maxReserveDays int) (int64, error)
}

PolicyAuditStore defines the policy_audit storage interface.

type PolicyStore

type PolicyStore interface {
	Create(ctx context.Context, policy *v1.Policy, opts metav1.CreateOptions) error
	Update(ctx context.Context, policy *v1.Policy, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, username string, name string, opts metav1.DeleteOptions) error
	DeleteCollection(ctx context.Context, username string, names []string, opts metav1.DeleteOptions) error
	Get(ctx context.Context, username string, name string, opts metav1.GetOptions) (*v1.Policy, error)
	List(ctx context.Context, username string, opts metav1.ListOptions) (*v1.PolicyList, error)
}

PolicyStore defines the policy storage interface.

type SecretStore

type SecretStore interface {
	Create(ctx context.Context, secret *v1.Secret, opts metav1.CreateOptions) error
	Update(ctx context.Context, secret *v1.Secret, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, username, secretID string, opts metav1.DeleteOptions) error
	DeleteCollection(ctx context.Context, username string, secretIDs []string, opts metav1.DeleteOptions) error
	Get(ctx context.Context, username, secretID string, opts metav1.GetOptions) (*v1.Secret, error)
	List(ctx context.Context, username string, opts metav1.ListOptions) (*v1.SecretList, error)
}

SecretStore defines the secret storage interface.

type UserStore

type UserStore interface {
	Create(ctx context.Context, user *v1.User, opts metav1.CreateOptions) error
	Update(ctx context.Context, user *v1.User, opts metav1.UpdateOptions) error
	Delete(ctx context.Context, username string, opts metav1.DeleteOptions) error
	DeleteCollection(ctx context.Context, usernames []string, opts metav1.DeleteOptions) error
	Get(ctx context.Context, username string, opts metav1.GetOptions) (*v1.User, error)
	List(ctx context.Context, opts metav1.ListOptions) (*v1.UserList, error)
}

UserStore defines the user storage interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL