util

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const ExecCredentialObject = `` /* 148-byte string literal not displayed */

ExecCredentialObject - when run as a an exec credential plugin - which is the common mode of operation, the output is printed to stdout and captured by kubectl who will know what to do with the token

Variables

This section is empty.

Functions

func ClusterCaCert added in v1.2.0

func ClusterCaCert(context string) string

ClusterCaCert provides the CA cert for the given cluster, or "unknown" if not in map of known clusters

func ContextToEnv

func ContextToEnv(context string) (env string)

ContextToEnv translates any known context to it's corresponding environment, or dev if not found

func ExtractTeams added in v1.0.1

func ExtractTeams(claims *IdentityClaims) (teams []string)

ExtractTeams returns all teams from groups as found in ID token

func Join

func Join(items []string, prefix, suffix string) string

Join with both prefix and suffix

func LoadConfigFromContext

func LoadConfigFromContext(context string) *api.Config

LoadConfigFromContext loads config object for provided context

func RandomString

func RandomString(length int) string

RandomString returns a semi-random string of variable length

func ReadToken added in v1.1.0

func ReadToken(context string) string

ReadToken returns token or empty string if missing or failure to read it (likely due to it not being written yet)

func Whoami

func Whoami(user string, groups []string, teams []string) string

Whoami prints username, groups and team membership

func WriteToken added in v1.1.0

func WriteToken(token string, context string) error

WriteToken writes token to ~/.kube/kubectl-login/${env}/token.jwt

Types

type IdentityClaims

type IdentityClaims struct {
	Username string    `json:"email"`
	Groups   *[]string `json:"groups"`
	jwt.StandardClaims
}

IdentityClaims - token claims of interest for our use case

func JwtToIdentityClaims added in v1.0.1

func JwtToIdentityClaims(rawToken string) *IdentityClaims

JwtToIdentityClaims retrieves user info (name and group belongings) from stored token

type Issuer

type Issuer struct {
	Name              string
	AuthorizeEndpoint string
}

Issuer is the name / authorize endpoint mapping for our Common Login environments

func ClusterIssuer

func ClusterIssuer(context string) Issuer

ClusterIssuer provides relevant issuer details given a context

Jump to

Keyboard shortcuts

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