Documentation
¶
Overview ¶
Package config manages grant application configuration.
Index ¶
- Constants
- func AddFavorite(cfg *Config, name string, fav Favorite) error
- func ConfigDir() (string, error)
- func ConfigPath() (string, error)
- func ParseCacheTTL(cfg *Config) time.Duration
- func RemoveFavorite(cfg *Config, name string) error
- func Save(cfg *Config, path string) error
- type Config
- type Favorite
- type FavoriteEntry
Constants ¶
const ( FavoriteTypeCloud = "cloud" FavoriteTypeGroups = "groups" )
const DefaultCacheTTL = 4 * time.Hour
DefaultCacheTTL is the default eligibility cache TTL.
Variables ¶
This section is empty.
Functions ¶
func AddFavorite ¶
AddFavorite adds a named favorite to the config. Returns an error if the name already exists. Defaults provider to "azure" if empty.
func ConfigPath ¶
ConfigPath returns the config file path, respecting the GRANT_CONFIG env var.
func ParseCacheTTL ¶ added in v0.3.0
ParseCacheTTL returns the configured cache TTL duration. Falls back to DefaultCacheTTL if the config value is empty or unparseable.
func RemoveFavorite ¶
RemoveFavorite removes a named favorite. Returns an error if not found.
Types ¶
type Config ¶
type Config struct {
Profile string `yaml:"profile"`
DefaultProvider string `yaml:"default_provider"`
CacheTTL string `yaml:"cache_ttl,omitempty"`
Favorites map[string]Favorite `yaml:"favorites"`
}
Config holds the grant application configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a Config with default values.
func Load ¶
Load reads a config file from the given path. If the file does not exist, it returns the default config.
func LoadDefaultWithPath ¶ added in v0.2.0
LoadDefaultWithPath resolves the config path via ConfigPath() and loads the config. Returns the config, the resolved path, and any error.
type Favorite ¶
type Favorite struct {
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Provider string `yaml:"provider" json:"provider"`
Target string `yaml:"target" json:"target"`
Role string `yaml:"role" json:"role"`
Group string `yaml:"group,omitempty" json:"group,omitempty"`
DirectoryID string `yaml:"directory_id,omitempty" json:"directoryId,omitempty"`
}
Favorite represents a saved elevation target.
func GetFavorite ¶
GetFavorite retrieves a favorite by name. Returns an error if not found.
func (Favorite) ResolvedType ¶ added in v0.3.0
ResolvedType returns the effective favorite type. Empty Type defaults to "cloud" for backward compatibility.
type FavoriteEntry ¶
FavoriteEntry pairs a favorite name with its data, used for sorted listing.
func ListFavorites ¶
func ListFavorites(cfg *Config) []FavoriteEntry
ListFavorites returns all favorites sorted alphabetically by name.