config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPath = errors.New("invalid config path")

ErrInvalidPath is returned when the config path is invalid.

View Source
var ErrNotFound = fmt.Errorf("configuration not found")

ErrNotFound is returned when the config file doesn't exist.

Functions

func GlobalPath

func GlobalPath() (string, error)

GlobalPath returns the global configuration file path.

func LocalPath

func LocalPath() (string, error)

LocalPath returns the nearest local configuration file path. It walks up from the current directory to find the nearest .gplay/config.json, stopping at a .git boundary or the filesystem root.

func Path

func Path() (string, error)

Path returns the active configuration file path.

func SaveAt

func SaveAt(path string, cfg *Config) error

SaveAt writes configuration to a specific path.

Types

type Config

type Config struct {
	DefaultProfile       string        `json:"default_profile"`
	Profiles             []Profile     `json:"profiles,omitempty"`
	PackageName          string        `json:"package_name,omitempty"`
	Timeout              DurationValue `json:"timeout"`
	TimeoutSeconds       DurationValue `json:"timeout_seconds"`
	UploadTimeout        DurationValue `json:"upload_timeout"`
	UploadTimeoutSeconds DurationValue `json:"upload_timeout_seconds"`
	MaxRetries           int           `json:"max_retries,omitempty"`
	RetryDelay           string        `json:"retry_delay,omitempty"`
	Debug                string        `json:"debug"`
}

Config holds the application configuration.

func Load

func Load() (*Config, error)

Load reads the active configuration file.

func LoadAt

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

LoadAt reads configuration from a specific path.

func (*Config) Validate added in v0.4.8

func (c *Config) Validate() error

Validate checks the configuration for invalid values.

type DurationValue

type DurationValue struct {
	Duration time.Duration
	Raw      string
}

DurationValue stores a duration with its raw string representation. It marshals to/from JSON as a string to preserve config compatibility.

func ParseDurationValue

func ParseDurationValue(raw string) (DurationValue, error)

ParseDurationValue parses a duration string or seconds value into a DurationValue.

func (DurationValue) MarshalJSON

func (d DurationValue) MarshalJSON() ([]byte, error)

MarshalJSON stores the raw string when available, preserving the config format.

func (DurationValue) String

func (d DurationValue) String() string

String returns the raw string when available, falling back to the duration value.

func (*DurationValue) UnmarshalJSON

func (d *DurationValue) UnmarshalJSON(data []byte) error

UnmarshalJSON parses duration strings or seconds values from JSON.

func (DurationValue) Value

func (d DurationValue) Value() (time.Duration, bool)

Value returns the parsed duration if it's positive.

type Profile

type Profile struct {
	Name         string `json:"name"`
	Type         string `json:"type"`
	KeyPath      string `json:"key_path,omitempty"`
	TokenPath    string `json:"token_path,omitempty"`
	ClientID     string `json:"client_id,omitempty"`
	ClientSecret string `json:"client_secret,omitempty"`
}

Profile stores a named auth profile in config.json.

Jump to

Keyboard shortcuts

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