...

Package util

import "k8s.io/cluster-bootstrap/token/util"
Overview
Index

Overview ▾

Variables

var (
    // BootstrapTokenRegexp is a compiled regular expression of TokenRegexpString
    BootstrapTokenRegexp = regexp.MustCompile(api.BootstrapTokenPattern)
    // BootstrapTokenIDRegexp is a compiled regular expression of TokenIDRegexpString
    BootstrapTokenIDRegexp = regexp.MustCompile(api.BootstrapTokenIDPattern)
    // BootstrapGroupRegexp is a compiled regular expression of BootstrapGroupPattern
    BootstrapGroupRegexp = regexp.MustCompile(api.BootstrapGroupPattern)
)

func BootstrapTokenSecretName

func BootstrapTokenSecretName(tokenID string) string

BootstrapTokenSecretName returns the expected name for the Secret storing the Bootstrap Token in the Kubernetes API.

func GenerateBootstrapToken

func GenerateBootstrapToken() (string, error)

GenerateBootstrapToken generates a new, random Bootstrap Token.

func IsValidBootstrapToken

func IsValidBootstrapToken(token string) bool

IsValidBootstrapToken returns whether the given string is valid as a Bootstrap Token. Avoid using BootstrapTokenRegexp.MatchString(token) and instead perform constant-time comparisons on the secret.

func IsValidBootstrapTokenID

func IsValidBootstrapTokenID(tokenID string) bool

IsValidBootstrapTokenID returns whether the given string is valid as a Bootstrap Token ID and in other words satisfies the BootstrapTokenIDRegexp

func TokenFromIDAndSecret

func TokenFromIDAndSecret(id, secret string) string

TokenFromIDAndSecret returns the full token which is of the form "{id}.{secret}"

func ValidateBootstrapGroupName

func ValidateBootstrapGroupName(name string) error

ValidateBootstrapGroupName checks if the provided group name is a valid bootstrap group name. Returns nil if valid or a validation error if invalid. TODO(dixudx): should be moved to util/secrets

func ValidateUsages

func ValidateUsages(usages []string) error

ValidateUsages validates that the passed in string are valid usage strings for bootstrap tokens.