backend

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package backend provides CRUD for the secrets

Index

Constants

View Source
const (
	// DefaultRequestTimeout for k8s requests
	DefaultRequestTimeout = 5 * time.Second
	// AnnotationKey is the name of the secfs annotation
	AnnotationKey = "secfs"
	// AnnotationValue is the secfs version
	AnnotationValue = "v1"
	// ModTimeKey is the name of the modification time annotation
	ModTimeKey = "modtime"
)
View Source
const (
	FakePrefix = "unit-"
	FakeSuffix = "-test"
)

Constants for testing with fake backend

Variables

View Source
var (
	// ErrNotManaged for secrets not managed with secfs
	ErrNotManaged = errors.New("not managed with secfs")
)

Functions

func NewFakeClientset

func NewFakeClientset() kubernetes.Interface

NewFakeClientset returns a fake clientset for testing

Types

type Backend

type Backend interface {
	Create(Secret) error
	Get(Secret) error
	Update(Secret) error
	Delete(Secret) error
	Rename(Metadata, Metadata) error
}

Backend is the interface that groups the basic Create, Get, Update and Delete methods.

func New

func New(c kubernetes.Interface, opts ...Option) Backend

New returns a Backend

type Metadata

type Metadata interface {
	Namespace() string
	Secret() string
	Key() string
}

Metadata is the interface for basic metadata information

type Option

type Option func(*backend)

Option represents a functional Option

func WithIgnoreAnnotation added in v0.1.1

func WithIgnoreAnnotation() Option

WithIgnoreAnnotation configures the backend to ignore if the secret is managed with secfs or not

func WithSecretLabels

func WithSecretLabels(labels map[string]string) Option

WithSecretLabels configures a custom secret labels

func WithSecretPrefix

func WithSecretPrefix(x string) Option

WithSecretPrefix configures a custom secret prefix

func WithSecretSuffix

func WithSecretSuffix(x string) Option

WithSecretSuffix configures a custom secret prefix

func WithTimeout

func WithTimeout(t time.Duration) Option

WithTimeout configures a custom request timeout

type Secret

type Secret interface {
	Metadata

	Value() []byte
	Delete() bool // delete Key() from map

	Data() map[string][]byte
	SetData(map[string][]byte)

	SetTime(time.Time)
}

Secret is the interface that abstracts the Kubernetes secret

Jump to

Keyboard shortcuts

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