awsauth

package
v0.0.0-...-c1592eb Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ConfigMapName      = "aws-auth"
	ConfigMapNamespace = "kube-system"
)

Variables

This section is empty.

Functions

func CreateAuthMap

func CreateAuthMap(k kubernetes.Interface) (*kcorev1.ConfigMap, error)

func UpdateAuthMap

func UpdateAuthMap(k kubernetes.Interface, authData AwsAuthData, cm *kcorev1.ConfigMap) error

UpdateAuthMap updates a given ConfigMap

func WithRetry

func WithRetry(fn func(*Arguments) error, args *Arguments) error

WithRetry runs the passed operation function with its arguments and retries on failures until success or max number of retry attempts have failed.

Types

type Arguments

type Arguments struct {
	OperationType OperationType
	DataType      DataType
	RoleARN       string
	UserARN       string
	Username      string
	Groups        []string
	WithRetries   bool
	MinRetryTime  time.Duration
	MaxRetryTime  time.Duration
	MaxRetryCount int
}

Arguments are the arguments for management of the auth map.

func (*Arguments) Validate

func (args *Arguments) Validate()

Validate validates if all Arguments fields are valid.

type AwsAuthData

type AwsAuthData struct {
	MapRoles []*MapRole `yaml:"mapRoles"`
	MapUsers []*MapUser `yaml:"mapUsers"`
}

AwsAuthData represents the data of the aws-auth configmap

func ReadAuthMap

ReadAuthMap reads the auth ConfigMap and returns AwsAuthData and the read ConfigMap.

func (*AwsAuthData) SetMapRoles

func (m *AwsAuthData) SetMapRoles(authMap []*MapRole)

SetMapRoles sets the MapRoles element

func (*AwsAuthData) SetMapUsers

func (m *AwsAuthData) SetMapUsers(authMap []*MapUser)

SetMapUsers sets the MapUsers element

type DataType

type DataType string

DataType indicates the auth map management scope.

const (
	MapRoleData DataType = "mapRole"
	MapUserData DataType = "mapUser"
)

type MapRole

type MapRole struct {
	RoleARN  string   `yaml:"rolearn"`
	Username string   `yaml:"username"`
	Groups   []string `yaml:"groups,omitempty"`
}

MapRole is the basic structure of a mapRoles authentication object

func NewMapRole

func NewMapRole(rolearn, username string, groups []string) *MapRole

NewMapRole returns a new NewMapRole

func (*MapRole) SetGroups

func (r *MapRole) SetGroups(g []string) *MapRole

SetGroups sets the Groups value

func (*MapRole) SetRoleARN

func (r *MapRole) SetRoleARN(v string) *MapRole

SetRoleARN sets the Username value

func (*MapRole) String

func (r *MapRole) String() string

type MapUser

type MapUser struct {
	UserARN  string   `yaml:"userarn"`
	Username string   `yaml:"username"`
	Groups   []string `yaml:"groups,omitempty"`
}

MapUser is the basic structure of a mapUsers authentication object

func NewMapUser

func NewMapUser(userarn, username string, groups []string) *MapUser

NewMapUser returns a new NewMapUser

func (*MapUser) SetGroups

func (r *MapUser) SetGroups(g []string) *MapUser

SetGroups sets the Groups value

func (*MapUser) SetUserARN

func (r *MapUser) SetUserARN(v string) *MapUser

SetUserARN sets the UserARN value

func (*MapUser) String

func (r *MapUser) String() string

type Mapper

type Mapper struct {
	KubernetesClient kubernetes.Interface
}

Mapper is responsible for managing the auth map.

func NewMapper

func NewMapper(client kubernetes.Interface, discardLogOutput bool) *Mapper

NewMapper returns a new Mapper object.

func (*Mapper) Remove

func (m *Mapper) Remove(args *Arguments) error

Remove removes a mapRole or mapUser from the auth map.

func (*Mapper) Upsert

func (m *Mapper) Upsert(args *Arguments) error

Upsert updates or inserts a mapRole or mapUser item into the auth map.

type OperationType

type OperationType string

OperationType indicates the auth map management operation.

const (
	UpsertOperation OperationType = "upsert"
	RemoveOperation OperationType = "remove"
)

type Service

type Service interface {
	// UpsertMapRole upserts a MapRole into the configmap keyed by username.
	UpsertMapRole(username string, mapRole MapRole) error

	// RemoveMapRole removes a MapRole from the configmap by keyed by username
	RemoveMapRole(username string) error

	// UpsertMapUser upserts a MapUser into the configmap keyed by username.
	UpsertMapUser(username string, mapUser MapUser) error

	// RemoveMapUser removes a MapUser from the configmap keyed by username
	RemoveMapUser(username string) error
}

Service provides aws-auth configmap management behavior.

func NewService

func NewService(cfg *ServiceConfig) (Service, error)

NewService returns an implementation of the Service interface.

type ServiceConfig

type ServiceConfig struct {
	KubeClient    kubernetes.Interface
	Log           logr.Logger
	MaxRetryCount int
	MaxRetryTime  time.Duration
	MinRetryTime  time.Duration
	WithRetries   bool
}

ServiceConfig is the configuration for a Service object.

Jump to

Keyboard shortcuts

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