secret

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package secret implements the secret lister. It is responsible for retrieving the list of secrets containing MapR tickets and enriching them with additional information.

The lister is implemented as a chain of filters and collectors. The filters are used to filter out secrets, ie. to only keep those that contain a MapR ticket. The collectors are used to collect additional information about the secrets, ie. to collect the number of persistent volumes using each secret. This data is then used to print the secrets in a human-readable tabular format.

Index

Constants

This section is empty.

Variables

View Source
var (
	// SortOptionsList is the list of valid sort options
	SortOptionsList = []string{
		SortByName.String(),
		SortByNamespace.String(),
		SortByMaprCluster.String(),
		SortByMaprUser.String(),
		SortByAge.String(),
		SortByExpiration.String(),
		SortByNumPVCs.String(),
	}

	// DefaultSortBy is the default sort order
	DefaultSortBy = []SortOption{
		SortByNamespace,
		SortByName,
	}
)

Functions

func Print

func Print(cmd *cobra.Command, secrets []types.MaprSecret) error

Print prints the secrets containing MapR tickets in a human-readable format to the given output stream.

Types

type Lister

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

Lister is the struct that is used to list secrets containing MapR tickets in the cluster.

func NewLister

func NewLister(client kubernetes.Interface, namespace string, opts ...ListerOption) *Lister

NewLister creates a new secret lister. It requires a Kubernetes client and a namespace to operate on. It also accepts a list of options that can be used to configure the lister.

func (*Lister) List

func (l *Lister) List() ([]types.MaprSecret, error)

List returns a list of secrets containing MapR tickets in the cluster, enriched with additional information and filtered according to the specified options.

func (*Lister) Sort

func (l *Lister) Sort() *Lister

Sort sorts the items by the specified sort options, in reverse order of the order in which they are specified. This makes for a more natural sort result when using multiple sort options.

type ListerOption

type ListerOption func(*Lister)

ListerOption is a function that can be used to configure the secret lister.

func WithFilterByGID

func WithFilterByGID(gid uint32) ListerOption

WithFilterByGID configures the secret lister to only list tickets that include a group with the given GID.

func WithFilterByInUse

func WithFilterByInUse() ListerOption

WithFilterByInUse configures the secret lister to only list tickets that are in use by a persistent volume.

func WithFilterByMaprCluster

func WithFilterByMaprCluster(cluster string) ListerOption

WithFilterByMaprCluster configures the secret lister to only list tickets that are backed by a MapR cluster with the given name.

func WithFilterByMaprUser

func WithFilterByMaprUser(user string) ListerOption

WithFilterByMaprUser configures the secret lister to only list tickets that are for a MapR user with the given name.

func WithFilterByUID

func WithFilterByUID(uid uint32) ListerOption

WithFilterByUID configures the secret lister to only list tickets that are for a user with the given UID.

func WithFilterExpiresBefore

func WithFilterExpiresBefore(expiresBefore time.Duration) ListerOption

WithFilterExpiresAfter configures the secret lister to only list tickets that expire during the given duration or have already expired.

func WithFilterOnlyExpired

func WithFilterOnlyExpired() ListerOption

WithFilterOnlyExpired configures the secret lister to only list tickets that have expired.

func WithFilterOnlyUnexpired

func WithFilterOnlyUnexpired() ListerOption

WithFilterOnlyUnexpired configures the secret lister to only list tickets that have not expired.

func WithShowInUse

func WithShowInUse() ListerOption

WithShowInUse configures the secret lister to show by how many persistent volumes a ticket is in use.

func WithSortBy

func WithSortBy(sortBy []SortOption) ListerOption

WithSortBy configures the secret lister to sort the tickets by the given sort options.

func WithVolumeLister

func WithVolumeLister(volumeLister volumeLister) ListerOption

WithShowVolumes configures the secret lister to make use of the given volume lister to collect information about the persistent volumes that are using tickets.

type SortOption

type SortOption string

SortOption is the type of a sort option, basically a wrapper around a string to provide type safety.

const (
	SortByName        SortOption = "name"
	SortByNamespace   SortOption = "namespace"
	SortByMaprCluster SortOption = "mapr.cluster"
	SortByMaprUser    SortOption = "mapr.user"
	SortByAge         SortOption = "age"
	SortByExpiration  SortOption = "expiration"
	SortByNumPVCs     SortOption = "npvcs"
)

All valid sort options are defined here

func (SortOption) String

func (s SortOption) String() string

String returns the string representation of the sort option.

Jump to

Keyboard shortcuts

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