Documentation
¶
Overview ¶
Package naming applies the username rule of a normalized config.UsernameConfig: validation, derivation, renames and former names.
Index ¶
- Constants
- func CheckRename(c config.UsernameConfig, lastRenamedAt *time.Time, now time.Time) error
- func Cooldown(c config.UsernameConfig) time.Duration
- func Derive(c config.UsernameConfig, s string) string
- func FormerNameExpiresAt(c config.UsernameConfig, now time.Time) *time.Time
- func Validate(c config.UsernameConfig, username string) error
- func ValidateImport(c config.UsernameConfig, username string) error
- func WithSuffix(c config.UsernameConfig, base, suffix string) string
- type Alias
- type PolicyInfo
- type State
Constants ¶
const UsernamePattern = "^[A-Za-z][A-Za-z0-9_]*$"
UsernamePattern is the fixed character rule for interactive usernames, compatible with Go RE2 and JavaScript `u`/`v` regular expressions and HTML `pattern`. Length is governed separately.
Variables ¶
This section is empty.
Functions ¶
func CheckRename ¶
CheckRename runs under the account lock. Callers authorize and detect a same-canonical-name no-op first. Trusted import updates skip it, never namespace ownership checks.
func Cooldown ¶
func Cooldown(c config.UsernameConfig) time.Duration
Cooldown is the least time between two renames.
func Derive ¶
func Derive(c config.UsernameConfig, s string) string
Derive turns arbitrary text into a username that satisfies Validate.
func FormerNameExpiresAt ¶
FormerNameExpiresAt is the promise made at rename time: nil means forever, and immediate returns now (lookups and claims use the same strict now.Before(deadline)). Later policy changes never rewrite it.
func Validate ¶
func Validate(c config.UsernameConfig, username string) error
Validate checks a trimmed username against the length rule and UsernamePattern. Length failures carry min_length/max_length metadata.
func ValidateImport ¶
func ValidateImport(c config.UsernameConfig, username string) error
ValidateImport checks a host-provisioned username: the configured minimum, a maximum of at least 64, and hyphens are also allowed.
func WithSuffix ¶
func WithSuffix(c config.UsernameConfig, base, suffix string) string
WithSuffix appends suffix to a derived username, trimming base (and, under a very small maximum, suffix) so the result still satisfies Validate.
Types ¶
type PolicyInfo ¶
type PolicyInfo struct {
Enabled bool `json:"enabled"`
FormerNameRetentionMode config.FormerNamesMode `json:"former_name_retention_mode"`
FormerNameRetentionSeconds int64 `json:"former_name_retention_seconds"`
}
PolicyInfo is the rename policy account UIs show. Timing is reported by State.NextRenameAt and RetryAfterSeconds.