Beispiel #1
0
func GenerateToken(d *kubeadmapi.TokenDiscovery) error {
	tokenID, err := RandBytes(TokenIDBytes)
	if err != nil {
		return err
	}

	token, err := RandBytes(TokenBytes)
	if err != nil {
		return err
	}

	d.ID = tokenID
	d.Secret = token
	return nil
}
Beispiel #2
0
// GenerateToken generates a new token with a token ID that is valid as a
// Kubernetes DNS label.
// For more info, see kubernetes/pkg/util/validation/validation.go.
func GenerateToken(d *kubeadmapi.TokenDiscovery) error {
	tokenID, err := randBytes(TokenIDBytes)
	if err != nil {
		return err
	}

	token, err := randBytes(TokenSecretBytes)
	if err != nil {
		return err
	}

	d.ID = strings.ToLower(tokenID)
	d.Secret = strings.ToLower(token)
	return nil
}