secrets

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileManager

type FileManager interface {
	// ReadDir returns the directory entries for the directory.
	ReadDir(dirname string) ([]fs.DirEntry, error)
	// Remove file with given name.
	Remove(name string) error
	// Create file at the provided filepath.
	Create(name string) (*os.File, error)
	// Chmod sets the mode of the file.
	Chmod(file *os.File, mode os.FileMode) error
	// Write writes contents to the file.
	Write(file *os.File, contents []byte) error
}

FileManager is an interface that exposes File I/O operations. Used for unit testing.

type Secret

type Secret struct {
	// Secret is the Kubernetes Secret object.
	Secret *apiv1.Secret
	// Valid is whether the Kubernetes Secret is valid.
	Valid bool
}

Secret is the internal representation of a Kubernetes Secret.

type SecretDiskMemoryManager

type SecretDiskMemoryManager interface {
	// Request marks the secret as requested so that it can be written to disk before reloading NGINX.
	// Returns the path to the secret if it exists.
	// Returns an error if the secret does not exist in the secret store or the secret is invalid.
	Request(nsname types.NamespacedName) (string, error)
	// WriteAllRequestedSecrets writes all requested secrets to disk.
	WriteAllRequestedSecrets() error
}

SecretDiskMemoryManager manages secrets that are requested by Gateway resources.

type SecretDiskMemoryManagerImpl

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

FIXME(kate-osborn): Is it necessary to make this concurrent-safe?

func NewSecretDiskMemoryManager

func NewSecretDiskMemoryManager(
	secretDirectory string,
	secretStore SecretStore,
	options ...SecretDiskMemoryManagerOption,
) *SecretDiskMemoryManagerImpl

func (*SecretDiskMemoryManagerImpl) Request

func (*SecretDiskMemoryManagerImpl) WriteAllRequestedSecrets

func (s *SecretDiskMemoryManagerImpl) WriteAllRequestedSecrets() error

type SecretDiskMemoryManagerOption

type SecretDiskMemoryManagerOption func(*SecretDiskMemoryManagerImpl)

SecretDiskMemoryManagerOption is a function that modifies the configuration of the SecretDiskMemoryManager.

func WithSecretFileManager

func WithSecretFileManager(fileManager FileManager) SecretDiskMemoryManagerOption

WithSecretFileManager sets the file manager of the SecretDiskMemoryManager. Used to inject a fake fileManager for unit tests.

type SecretStore

type SecretStore interface {
	// Upsert upserts the secret into the store.
	Upsert(secret *apiv1.Secret)
	// Delete deletes the secret from the store.
	Delete(nsname types.NamespacedName)
	// Get gets the secret from the store.
	Get(nsname types.NamespacedName) *Secret
}

SecretStore stores secrets.

type SecretStoreImpl

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

func NewSecretStore

func NewSecretStore() *SecretStoreImpl

func (SecretStoreImpl) Delete

func (s SecretStoreImpl) Delete(nsname types.NamespacedName)

func (SecretStoreImpl) Get

func (s SecretStoreImpl) Get(nsname types.NamespacedName) *Secret

func (SecretStoreImpl) Upsert

func (s SecretStoreImpl) Upsert(secret *apiv1.Secret)

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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