roles

package
v0.154.1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeConfig

func DecodeConfig(defaultContentRole string, m map[string]any) (*config.ConfigNamespace[map[string]RoleConfig, RolesInternal], string, error)

Types

type Role

type Role interface {
	Name() string
}

func NewRole

func NewRole(r RoleInternal) Role

type RoleConfig

type RoleConfig struct {
	// The weight of the role.
	// Used to determine the order of the roles.
	// If zero, we use the role name.
	Weight int
}

type RoleInternal

type RoleInternal struct {
	// Name is the name of the role, extracted from the key in the config.
	Name string

	// Whether this role is the default role.
	// This will be rendered in the root.
	// There is only be one default role.
	Default bool

	RoleConfig
}

type Roles

type Roles []Role

type RolesInternal

type RolesInternal struct {
	Sorted []RoleInternal
	// contains filtered or unexported fields
}

func (RolesInternal) ForEachIndex

func (r RolesInternal) ForEachIndex() iter.Seq[int]

ForEachIndex returns an iterator for the indices of the roles.

func (RolesInternal) Has

func (r RolesInternal) Has(role string) bool

func (RolesInternal) IndexDefault

func (r RolesInternal) IndexDefault() int

func (RolesInternal) IndexMatch

func (r RolesInternal) IndexMatch(match predicate.P[string]) (iter.Seq[int], error)

IndexMatch returns an iterator for the roles that match the filter.

func (RolesInternal) Len

func (r RolesInternal) Len() int

func (RolesInternal) ResolveIndex

func (r RolesInternal) ResolveIndex(name string) int

func (RolesInternal) ResolveName

func (r RolesInternal) ResolveName(i int) string