config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config resolves the wazuh-cli configuration from multiple sources in priority order: CLI flags > environment variables > .env file > config file.

Index

Constants

View Source
const (
	// DefaultConfigDir is the XDG-compliant config directory.
	DefaultConfigDir = ".config/wazuh"
	// DefaultConfigFile is the config file name inside DefaultConfigDir.
	DefaultConfigFile = "config.json"
	// DefaultTokenFile is the JWT token cache file name.
	DefaultTokenFile = "token"
	// DefaultTimeout is the default HTTP timeout in seconds.
	DefaultTimeout = 30
	// DefaultOutput is the default output format.
	DefaultOutput = "json"
)

Variables

This section is empty.

Functions

func DefaultConfigPath

func DefaultConfigPath() string

DefaultConfigPath returns the full path to the default config file.

func DefaultTokenPath

func DefaultTokenPath() string

DefaultTokenPath returns the full path to the JWT token cache.

Types

type Config

type Config struct {
	// Connection
	URL      string `json:"url"`
	User     string `json:"user"`
	Password string `json:"password"`

	// TLS
	Insecure   bool   `json:"insecure"`
	CACert     string `json:"ca_cert"`
	ClientCert string `json:"client_cert"`
	ClientKey  string `json:"client_key"`

	// Indexer (OpenSearch)
	IndexerURL      string `json:"indexer_url"`
	IndexerUser     string `json:"indexer_user"`
	IndexerPassword string `json:"indexer_password"`
	IndexerIndex    string `json:"indexer_index"`

	// Behavior
	Timeout int    `json:"timeout"`
	Output  string `json:"output"`
	Pretty  bool   `json:"pretty"`
	Debug   bool   `json:"debug"`
	Quiet   bool   `json:"quiet"`

	// Auth token (runtime only, not persisted)
	RawToken string `json:"-"`
}

Config holds all wazuh-cli runtime configuration.

func Load

func Load(configPath string, overrides *Config) (*Config, error)

Load builds a Config by merging all sources in priority order. configPath is the path to the JSON config file (from flag or default). overrides contains values set by CLI flags (non-zero values win).

func (*Config) Save

func (c *Config) Save(path string) error

Save writes the config to the given path with 0600 permissions. Creates parent directories as needed.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks that required fields are present.

Jump to

Keyboard shortcuts

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