mapper

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

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

Variables

View Source
var (
	DefaultRetryerBackoffFactor float64 = 2.0
	DefaultRetryerBackoffJitter         = true
	UpdateUsernameDefaultValue  bool    = 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 RetriableFunction, args *MapperArguments) (interface{}, error)

Types

type AuthMapper

type AuthMapper struct {
	KubernetesClient kubernetes.Interface
	LoggingEnabled   bool
}

func New

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

func (*AuthMapper) Get added in v0.4.0

func (b *AuthMapper) Get(args *MapperArguments) (AwsAuthData, error)

Upsert update or inserts by rolearn

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 actually 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
	Format         string
	OperationType  OperationType
	MapRoles       bool
	MapUsers       bool
	Force          bool
	Username       string
	RoleARN        string
	UserARN        string
	Groups         []string
	WithRetries    bool
	MinRetryTime   time.Duration
	MaxRetryTime   time.Duration
	MaxRetryCount  int
	IsGlobal       bool
	Append         bool
	UpdateUsername *bool

	AsUser   string
	AsGroups []string
}

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"
	OperationGet    OperationType = "get"
)

type RetriableFunction added in v0.4.0

type RetriableFunction func() (interface{}, error)

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) AppendGroups added in v0.4.0

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

AppendGroups sets the Groups value

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 UpsertOptions added in v0.4.0

type UpsertOptions struct {
	Append         bool
	UpdateUsername bool
}

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) AppendGroups added in v0.4.0

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

AppendGroups sets the Groups value

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