func (s *ProvisioningService) UpsertToken(token string, roles teleport.Roles, ttl time.Duration) error {
	if ttl < time.Second {
		ttl = defaults.ProvisioningTokenTTL
	}
	t := services.ProvisionToken{
		Roles:   roles,
		Expires: time.Now().UTC().Add(ttl),
		Token:   token,
	}
	out, err := json.Marshal(t)
	if err != nil {
		return trace.Wrap(err)
	}

	err = s.backend.UpsertVal([]string{"tokens"}, token, out, ttl)
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
// UpsertToken adds provisioning tokens for the auth server
UpsertToken adds provisioning tokens for the auth server
// UpsertToken adds provisioning tokens for the auth server
func (s *ProvisioningService) UpsertToken(token string, roles teleport.Roles, ttl time.Duration) error {
	if ttl < time.Second {
		ttl = defaults.ProvisioningTokenTTL
	}
	t := services.ProvisionToken{
		Roles:   roles,
		Expires: time.Now().UTC().Add(ttl),
		Token:   token,
	}
	out, err := json.Marshal(t)
	if err != nil {
		return trace.Wrap(err)
	}
	err = s.backend.UpsertVal([]string{"tokens"}, token, out, ttl)
	if err != nil {
		return trace.Wrap(err)
	}
	return nil
}
func ( s * ProvisioningService ) UpsertToken ( token string , roles teleport . Roles , ttl time . Duration ) error { if ttl < time . Second { ttl = defaults . ProvisioningTokenTTL } t := services . ProvisionToken { Roles : roles , Expires : time . Now ( ) . UTC ( ) . Add ( ttl ) , Token : token , } out , err := json . Marshal ( t ) if err != nil { return trace . Wrap ( err ) } err = s . backend . UpsertVal ( [ ] string { " " } , token , out , ttl ) if err != nil { return trace . Wrap ( err ) } return nil }
UpsertToken adds provisioning tokens for the auth server
UpsertToken adds provisioning tokens for the auth server