config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFavorite

func AddFavorite(cfg *Config, name string, fav Favorite) error

AddFavorite adds a named favorite to the config. Returns an error if the name already exists. Defaults provider to "azure" if empty.

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the default config directory path.

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the config file path, respecting the GRANT_CONFIG env var.

func RemoveFavorite

func RemoveFavorite(cfg *Config, name string) error

RemoveFavorite removes a named favorite. Returns an error if not found.

func Save

func Save(cfg *Config, path string) error

Save writes a config to the given path, creating parent directories as needed.

Types

type Config

type Config struct {
	Profile         string              `yaml:"profile"`
	DefaultProvider string              `yaml:"default_provider"`
	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

func Load(path string) (*Config, error)

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

func LoadDefaultWithPath() (*Config, string, error)

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 {
	Provider string `yaml:"provider"`
	Target   string `yaml:"target"`
	Role     string `yaml:"role"`
}

Favorite represents a saved elevation target.

func GetFavorite

func GetFavorite(cfg *Config, name string) (Favorite, error)

GetFavorite retrieves a favorite by name. Returns an error if not found.

type FavoriteEntry

type FavoriteEntry struct {
	Name string
	Favorite
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL