secret

package
v0.36.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package secret is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSecret

func GetSecret[T any](ctx context.Context, client Client, name string) (T, error)

GetSecret retrieves a secret using secret client and returns it as a generic type, returning an error if the retrieval or unmarshalling fails.

func SaveSecret

func SaveSecret[T any](ctx context.Context, client Client, name string, value T) error

SaveSecret saves a secret value using secret client, marshalling it to JSON first.

Types

type Client

type Client interface {
	// Save creates or updates secret.
	// Returns ErrInvalid in case of invalid input.
	Save(ctx context.Context, name string, value []byte) error

	// Delete deletes the secret with the given name.
	Delete(ctx context.Context, name string) error

	// Get gets secret name if present else returns an error.
	// Returns ErrNotFound in case of invalid input.
	Get(ctx context.Context, name string) ([]byte, error)
}

Client is an interface to implement secret operations.

type ErrInvalid

type ErrInvalid struct {
	Message string
}

ErrInvalid represents error when resource inputs are invalid.

func (*ErrInvalid) Error

func (e *ErrInvalid) Error() string

Error returns a string representation of the error.

func (*ErrInvalid) Is

func (e *ErrInvalid) Is(target error) bool

Is checks if the target error is of type ErrInvalid and if the message of the target error is equal to the message of the current error or if the message of the target error is empty.

type ErrNotFound

type ErrNotFound struct {
}

ErrNotFound represents error when resource is missing.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

Error returns the error message.

func (*ErrNotFound) Is

func (e *ErrNotFound) Is(target error) bool

Is checks if the error is of type ErrNotFound.

type MockClient

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient is a mock of Client interface.

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

NewMockClient creates a new mock instance.

func (*MockClient) Delete

func (m *MockClient) Delete(arg0 context.Context, arg1 string) error

Delete mocks base method.

func (*MockClient) EXPECT

func (m *MockClient) EXPECT() *MockClientMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockClient) Get

func (m *MockClient) Get(arg0 context.Context, arg1 string) ([]byte, error)

Get mocks base method.

func (*MockClient) Save

func (m *MockClient) Save(arg0 context.Context, arg1 string, arg2 []byte) error

Save mocks base method.

type MockClientDeleteCall added in v0.35.0

type MockClientDeleteCall struct {
	*gomock.Call
}

MockClientDeleteCall wrap *gomock.Call

func (*MockClientDeleteCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientDeleteCall) DoAndReturn added in v0.35.0

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientDeleteCall) Return added in v0.35.0

Return rewrite *gomock.Call.Return

type MockClientGetCall added in v0.35.0

type MockClientGetCall struct {
	*gomock.Call
}

MockClientGetCall wrap *gomock.Call

func (*MockClientGetCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientGetCall) DoAndReturn added in v0.35.0

func (c *MockClientGetCall) DoAndReturn(f func(context.Context, string) ([]byte, error)) *MockClientGetCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientGetCall) Return added in v0.35.0

func (c *MockClientGetCall) Return(arg0 []byte, arg1 error) *MockClientGetCall

Return rewrite *gomock.Call.Return

type MockClientMockRecorder

type MockClientMockRecorder struct {
	// contains filtered or unexported fields
}

MockClientMockRecorder is the mock recorder for MockClient.

func (*MockClientMockRecorder) Delete

func (mr *MockClientMockRecorder) Delete(arg0, arg1 any) *MockClientDeleteCall

Delete indicates an expected call of Delete.

func (*MockClientMockRecorder) Get

func (mr *MockClientMockRecorder) Get(arg0, arg1 any) *MockClientGetCall

Get indicates an expected call of Get.

func (*MockClientMockRecorder) Save

func (mr *MockClientMockRecorder) Save(arg0, arg1, arg2 any) *MockClientSaveCall

Save indicates an expected call of Save.

type MockClientSaveCall added in v0.35.0

type MockClientSaveCall struct {
	*gomock.Call
}

MockClientSaveCall wrap *gomock.Call

func (*MockClientSaveCall) Do added in v0.35.0

Do rewrite *gomock.Call.Do

func (*MockClientSaveCall) DoAndReturn added in v0.35.0

func (c *MockClientSaveCall) DoAndReturn(f func(context.Context, string, []byte) error) *MockClientSaveCall

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockClientSaveCall) Return added in v0.35.0

func (c *MockClientSaveCall) Return(arg0 error) *MockClientSaveCall

Return rewrite *gomock.Call.Return

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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