defaults

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package defaults provides functionality for managing default values and configurations.

Package defaults provides functionality for managing default values and configurations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Default

type Default tool.Tool

Default manages the default configuration settings for a single tool. It is a type alias for tool.Tool, providing direct access to tool configuration fields.

func (*Default) FromFile

func (d *Default) FromFile(path string) error

FromFile loads and parses a YAML configuration file into Default. Returns an error if the file cannot be read or contains invalid YAML.

func (*Default) Initialize

func (d *Default) Initialize(platform detect.Platform) error

Initialize detects the current platform and applies platform-specific defaults to the Default struct. It also sets up default extensions based on the detected platform.

func (*Default) MergeWithConfig

func (d *Default) MergeWithConfig(cfg config.Config) error

MergeWithConfig applies configuration overrides from flags and environment variables. Updates default values for output paths, source types, tokens, platform settings, and other configurable options. Returns an error if any values are invalid.

func (*Default) ToTool

func (d *Default) ToTool() tool.Tool

ToToolg converts the Default back to a tool.Tool configuration.

func (*Default) Unmarshal

func (d *Default) Unmarshal(data []byte) error

Unmarshal parses YAML configuration data into the Default. Returns an error if the YAML data is invalid or cannot be parsed.

func (*Default) Validate

func (d *Default) Validate() error

Validate performs structural validation of the Default configuration. Ensures all required fields are properly set and contain valid values.

type Defaults

type Defaults map[string]*Default

Defaults manages a collection of default configurations for various tools.

func Load

func Load(path file.File, embeds config.Embedded, cfg config.Config) (*Defaults, error)

Load creates and configures a new Defaults instance. Handles loading from files or embedded data, applies configuration overrides, and returns the Defaults object and an error if any.

func NewDefaults

func NewDefaults() *Defaults

NewDefaults creates a new Defaults instance.

func (*Defaults) FromFile

func (d *Defaults) FromFile(path string) error

FromFile loads and parses a YAML configuration file into Defaults. Returns an error if the file cannot be read or contains invalid YAML.

func (*Defaults) GetDefault

func (d *Defaults) GetDefault(name string) *Default

GetDefault returns a specific Default configuration by name. If the configuration doesn't exist, it returns nil.

func (*Defaults) Initialize

func (d *Defaults) Initialize() error

Initialize detects the current platform and applies platform-specific defaults to all Default configurations.

func (*Defaults) Load

func (d *Defaults) Load(path file.File, defaults []byte, isSet bool) error

Load loads configuration from a file or falls back to embedded defaults. Initializes the configuration after loading. Returns an error if loading or initialization fails.

func (*Defaults) MergeWithConfig

func (d *Defaults) MergeWithConfig(cfg config.Config) error

MergeWithConfig applies configuration overrides from flags and environment variables. Updates default values for output paths, source types, tokens, platform settings, and other configurable options. Returns an error if any values are invalid.

func (*Defaults) Unmarshal

func (d *Defaults) Unmarshal(data []byte) error

Unmarshal parses YAML configuration data into the Defaults map. Returns an error if the YAML data is invalid or cannot be parsed.

func (*Defaults) Validate

func (d *Defaults) Validate() error

Validate performs structural validation of the Defaults configuration. Ensures all required fields are properly set and contain valid values.

Jump to

Keyboard shortcuts

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