secret

package
v0.33.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 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 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 interface{}) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockClientMockRecorder) Get

func (mr *MockClientMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call

Get indicates an expected call of Get.

func (*MockClientMockRecorder) Save

func (mr *MockClientMockRecorder) Save(arg0, arg1, arg2 interface{}) *gomock.Call

Save indicates an expected call of Save.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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