resource

package
v0.0.0-...-83947fe Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CaCert         = "ca.crt"
	CaKey          = "ca.key"
	CertValidFrom  = "certificate-valid-from"
	CertValidUpto  = "certificate-valid-upto"
	CertDuration   = "certificate-duration"
	SecretDataHash = "secret-data-hash"
)

Variables

This section is empty.

Functions

func Clean

func Clean(ctx context.Context, cl client.Client, namespace string, stsName string)

func GetSecretAnnotations

func GetSecretAnnotations(validFrom, validUpto, duration string) map[string]string

Types

type Fetcher

type Fetcher interface {
	Fetch(obj client.Object) error
}

Fetcher updates the object with its state from Kubernetes

type KubeFetcher

type KubeFetcher struct {
	client.Reader
	// contains filtered or unexported fields
}

KubeFetcher fetches Kubernetes results

func NewKubeFetcher

func NewKubeFetcher(ctx context.Context, namespace string, reader client.Reader) *KubeFetcher

func (KubeFetcher) Fetch

func (f KubeFetcher) Fetch(o client.Object) error

type KubePersister

type KubePersister struct {
	client.Client
	// contains filtered or unexported fields
}

KubePersister saves resources back into Kubernetes

func NewKubePersister

func NewKubePersister(ctx context.Context, namespace string, client client.Client, persistFn kube.PersistFn) *KubePersister

func (KubePersister) Persist

func (p KubePersister) Persist(obj client.Object, mutateFn func() error) (upserted bool, err error)

Persist saves the resource in the cluster

type Persister

type Persister interface {
	Persist(obj client.Object, mutateFn func() error) (upserted bool, err error)
}

Persister creates or updates the object in Kubernetes after calling the mutation function.

type Resource

type Resource struct {
	Fetcher
	Persister
}

Resource represents a resource that can be fetched or saved

func NewKubeResource

func NewKubeResource(ctx context.Context, client client.Client, namespace string, persistFn kube.PersistFn) Resource

type TLSSecret

type TLSSecret struct {
	Resource
	// contains filtered or unexported fields
}

func CreateTLSSecret

func CreateTLSSecret(name string, secretType corev1.SecretType, r Resource) *TLSSecret

CreateTLSSecret returns a TLSSecret struct that is used to store the certs via secrets.

func LoadTLSSecret

func LoadTLSSecret(name string, r Resource) (*TLSSecret, error)

LoadTLSSecret fetches secret from the API server

func (*TLSSecret) CA

func (s *TLSSecret) CA() []byte

func (*TLSSecret) CAKey

func (s *TLSSecret) CAKey() []byte

func (*TLSSecret) IsRotationRequired

func (s *TLSSecret) IsRotationRequired(duration time.Duration, cronStr string) (bool, string)

IsRotationRequired validates if all the required annotations are present

func (*TLSSecret) Ready

func (s *TLSSecret) Ready() bool

Ready checks if secret contains required data

func (*TLSSecret) ReadyCA

func (s *TLSSecret) ReadyCA() bool

ReadyCA checks if the CA secret contains required data

func (*TLSSecret) Secret

func (s *TLSSecret) Secret() *corev1.Secret

Secret returns the Secret object

func (*TLSSecret) TLSCert

func (s *TLSSecret) TLSCert() []byte

func (*TLSSecret) TLSPrivateKey

func (s *TLSSecret) TLSPrivateKey() []byte

func (*TLSSecret) UpdateCASecret

func (s *TLSSecret) UpdateCASecret(cakey []byte, caCert []byte, annotations map[string]string) error

UpdateCASecret updates CA key and CA Cert

func (*TLSSecret) UpdateTLSSecret

func (s *TLSSecret) UpdateTLSSecret(cert, key, ca []byte, annotations map[string]string) error

UpdateTLSSecret updates three different certificates at the same time. It save the TLSCert, the CA, and the TLSPrivateKey in a secret.

func (*TLSSecret) ValidateAnnotations

func (s *TLSSecret) ValidateAnnotations() bool

ValidateAnnotations validates if all the required annotations are present

Jump to

Keyboard shortcuts

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