config

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyOne

func CopyOne(ctx context.Context, params CopyParams) (err error)

func CopyRecursive

func CopyRecursive(ctx context.Context, params CopyParams) (err error)

Types

type CipherText

type CipherText struct {
	EncryptionKey  EncryptionKey
	Data           string
	Version        uint64     `json:",omitempty"`
	CreatedAt      *time.Time `json:",omitempty"`
	LastModifiedAt *time.Time `json:",omitempty"`
}

type CopyFunc

type CopyFunc func(ctx context.Context, params CopyParams) (err error)

type CopyParams

type CopyParams struct {
	Source         Store
	SourcePath     string
	Destination    Store
	DestinationKey EncryptionKey
}

type Crypter

type Crypter interface {
	Encrypter
	Decrypter
}

func DefaultCrypterFactory

func DefaultCrypterFactory(ctx context.Context, key EncryptionKey) (Crypter, error)

type CrypterFactoryFunc

type CrypterFactoryFunc func(ctx context.Context, key EncryptionKey) (Crypter, error)

type Decrypter

type Decrypter interface {
	Decrypt(ctx context.Context, ciphertext []byte) (plaintext []byte, err error)
}

type DirectoryFS

type DirectoryFS struct {
	Path string
}

func (DirectoryFS) OpenReadable

func (d DirectoryFS) OpenReadable(ctx context.Context, params OpenParams) (stream io.ReadCloser, err error)

func (DirectoryFS) OpenWritable

func (d DirectoryFS) OpenWritable(ctx context.Context, params OpenParams) (stream io.WriteCloser, err error)

func (DirectoryFS) Root

func (d DirectoryFS) Root() string

type EditParams

type EditParams struct {
	Path          string
	EncryptionKey EncryptionKey
}

type EncryptedFileEditor

type EncryptedFileEditor struct {
	Store Store
}

func NewEncryptedFileEditor

func NewEncryptedFileEditor(store Store) *EncryptedFileEditor

func (*EncryptedFileEditor) DecryptToFile

func (e *EncryptedFileEditor) DecryptToFile(ctx context.Context, secretPath string) (decryptedPath string, err error)

DecryptToFile writes a secret to a random secret data file on disk

func (*EncryptedFileEditor) Edit

func (e *EncryptedFileEditor) Edit(ctx context.Context, params EditParams) error

Edit opens a workspace KV file in the user's $EDITOR for modifications and applies those modifications

type Encrypter

type Encrypter interface {
	Encrypt(ctx context.Context, plaintext []byte) (ciphertext []byte, err error)
}

type EncryptionKey

type EncryptionKey struct {
	Engine string `json:"engine"`
	Env    string `json:"env"`
	Key    string `json:"key"`
}

func (EncryptionKey) String

func (k EncryptionKey) String() string

type FS

type FS interface {
	Root() string
	OpenReadable(ctx context.Context, params OpenParams) (stream io.ReadCloser, err error)
	OpenWritable(ctx context.Context, params OpenParams) (stream io.WriteCloser, err error)
}

type FileStore

type FileStore struct {
	FS                 FS
	CrypterFactoryFunc CrypterFactoryFunc
}

func NewDefaultFileStore

func NewDefaultFileStore(dir string) (store *FileStore)

func (*FileStore) Get

func (s *FileStore) Get(ctx context.Context, params GetParams) (ciphertext *CipherText, err error)

func (*FileStore) GetByKey

func (s *FileStore) GetByKey(ctx context.Context, key string, target any) (*CipherText, error)

GetByKey is a convenience method for getting a value by key A simpler alias interface to Get

func (*FileStore) List

func (s *FileStore) List(_ context.Context, params ListParams) (Iterator, error)

func (*FileStore) Set

func (s *FileStore) Set(ctx context.Context, params SetParams) (ciphertext *CipherText, err error)

type FileStoreIterResult

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

func (FileStoreIterResult) Error

func (f FileStoreIterResult) Error() error

func (FileStoreIterResult) Get

func (f FileStoreIterResult) Get(ctx context.Context, target any) (ciphertext *CipherText, err error)

func (FileStoreIterResult) Path

func (f FileStoreIterResult) Path() string

func (FileStoreIterResult) Set

func (f FileStoreIterResult) Set(ctx context.Context, key EncryptionKey, target any) (ciphertext *CipherText, err error)

type FileStoreIterator

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

func NewFileStoreIterator

func NewFileStoreIterator(store *FileStore) *FileStoreIterator

func (FileStoreIterator) Next

func (f FileStoreIterator) Next() <-chan IteratorResult

type GCPSecretManagerStore

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

func NewGCPSecretManagerStore

func NewGCPSecretManagerStore(ctx context.Context, projectID string) (store *GCPSecretManagerStore, err error)

func (GCPSecretManagerStore) Get

func (c GCPSecretManagerStore) Get(ctx context.Context, params GetParams) (ciphertext *CipherText, err error)

func (GCPSecretManagerStore) GetByKey

func (c GCPSecretManagerStore) GetByKey(ctx context.Context, key string, target any) (*CipherText, error)

GetByKey is a convenience method for getting a value by key A simpler alias interface to Get

func (GCPSecretManagerStore) List

func (c GCPSecretManagerStore) List(ctx context.Context, params ListParams) (iter Iterator, err error)

func (GCPSecretManagerStore) Set

func (c GCPSecretManagerStore) Set(ctx context.Context, params SetParams) (ciphertext *CipherText, err error)

type GetParams

type GetParams struct {
	Result any
	Path   string
}

type Iterator

type Iterator interface {
	Next() <-chan IteratorResult
}

type IteratorResult

type IteratorResult interface {
	Path() string
	Error() error
	Get(ctx context.Context, target any) (ciphertext *CipherText, err error)
	Set(ctx context.Context, key EncryptionKey, target any) (ciphertext *CipherText, err error)
}

type ListParams

type ListParams struct {
	Path string
}

type OpenParams

type OpenParams struct {
	Path string
}

type SetParams

type SetParams struct {
	Data          any
	Path          string
	EncryptionKey EncryptionKey
}

type Store

type Store interface {
	Get(ctx context.Context, params GetParams) (ciphertext *CipherText, err error)
	Set(ctx context.Context, params SetParams) (ciphertext *CipherText, err error)
	GetByKey(ctx context.Context, key string, target any) (ciphertext *CipherText, err error)
	List(ctx context.Context, params ListParams) (iter Iterator, err error)
}

Jump to

Keyboard shortcuts

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