mapper

package
v0.0.0-...-fd1a880 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AwsAuthNamespace = "kube-system"
	AwsAuthName      = "aws-auth"
)

Variables

View Source
var (
	DefaultRetryerBackoffFactor float64 = 2.0
	DefaultRetryerBackoffJitter         = true
)

Functions

func CreateAuthMap

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

func UpdateAuthMap

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

UpdateAuthMap updates a given ConfigMap

func WithRetry

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

Types

type AuthMapper

type AuthMapper struct {
	KubernetesClient kubernetes.Interface
	LoggingEnabled   bool
}

func New

func New(client kubernetes.Interface, isCommandline bool) *AuthMapper

func (*AuthMapper) Remove

func (b *AuthMapper) Remove(args *MapperArguments) error

Remove removes by match of provided arguments

func (*AuthMapper) RemoveByUsername

func (b *AuthMapper) RemoveByUsername(args *MapperArguments) error

RemoveByUsername removes all map roles and map users that match provided username

func (*AuthMapper) Upsert

func (b *AuthMapper) Upsert(args *MapperArguments) error

Upsert update or inserts by rolearn

func (*AuthMapper) UpsertMultiple

func (b *AuthMapper) UpsertMultiple(newMapRoles []*RolesAuthMap, newMapUsers []*UsersAuthMap) error

*

  • UpsertMultiple upserts list of mapRoles and mapUsers into the configmap
  • if no changes are required based on new entries, configmap doesn't get updated

type AwsAuthData

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

AwsAuthData represents the data of the aws-auth configmap

func ReadAuthMap

func ReadAuthMap(k kubernetes.Interface) (AwsAuthData, *v1.ConfigMap, error)

ReadAuthMap reads the aws-auth config map and returns an AwsAuthData and the actualy ConfigMap objects

func (*AwsAuthData) SetMapRoles

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

SetMapRoles sets the MapRoles element

func (*AwsAuthData) SetMapUsers

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

SetMapUsers sets the MapUsers element

type MapperArguments

type MapperArguments struct {
	KubeconfigPath string
	OperationType  OperationType
	MapRoles       bool
	MapUsers       bool
	Username       string
	RoleARN        string
	UserARN        string
	Groups         []string
	WithRetries    bool
	MinRetryTime   time.Duration
	MaxRetryTime   time.Duration
	MaxRetryCount  int
	IsGlobal       bool
}

MapperArguments are the arguments for removing a mapRole or mapUsers

func (*MapperArguments) Validate

func (args *MapperArguments) Validate()

type OperationType

type OperationType string
const (
	OperationUpsert OperationType = "upsert"
	OperationRemove OperationType = "remove"
)

type RolesAuthMap

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

RolesAuthMap is the basic structure of a mapRoles authentication object

func NewRolesAuthMap

func NewRolesAuthMap(rolearn, username string, groups []string) *RolesAuthMap

NewRolesAuthMap returns a new NewRolesAuthMap

func (*RolesAuthMap) SetGroups

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

SetGroups sets the Groups value

func (*RolesAuthMap) SetUsername

func (r *RolesAuthMap) SetUsername(v string) *RolesAuthMap

SetUsername sets the Username value

func (*RolesAuthMap) String

func (r *RolesAuthMap) String() string

type UsersAuthMap

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

UsersAuthMap is the basic structure of a mapUsers authentication object

func NewUsersAuthMap

func NewUsersAuthMap(userarn, username string, groups []string) *UsersAuthMap

NewUsersAuthMap returns a new NewUsersAuthMap

func (*UsersAuthMap) SetGroups

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

SetGroups sets the Groups value

func (*UsersAuthMap) SetUsername

func (r *UsersAuthMap) SetUsername(v string) *UsersAuthMap

SetUsername sets the Username value

func (*UsersAuthMap) String

func (r *UsersAuthMap) String() string

Jump to

Keyboard shortcuts

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