config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config loads and exposes application configuration via Viper, including API connection settings, upload tuning, and telemetry options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAttributeLines

func FormatAttributeLines(attrs map[string]string) string

FormatAttributeLines renders attributes as sorted key=value lines.

func MetadataPath

func MetadataPath() (string, error)

MetadataPath exposes the configured metadata file location.

func ParseAttributes

func ParseAttributes(input string) (map[string]string, error)

ParseAttributes converts newline-delimited key=value pairs to a map.

func ParseTags

func ParseTags(input string) ([]string, error)

ParseTags converts a comma-delimited list into normalized tags.

func ReadInConfig

func ReadInConfig(explicitPath string) error

ReadInConfig configures Viper for Astrolabe and reads the active config file. Missing default config files are tolerated; explicit config paths must resolve cleanly.

func SaveMetadata

func SaveMetadata(meta Metadata) (string, error)

SaveMetadata writes the metadata document to disk, ensuring directory creation.

Types

type Config

type Config struct {
	APIURL       string
	ProjectID    string
	AuthToken    string
	OfflineCache string
	Upload       UploadCfg
	Telemetry    TelemetryCfg
}

Config is the top-level application configuration populated from the connection.yml file, environment variables, and CLI flags.

func Load

func Load() (Config, error)

Load returns the active configuration from Viper. Missing values fall back to sensible defaults (e.g. ~/.astrolabe/runs for OfflineCache).

type FileMetadataRepository

type FileMetadataRepository struct {
	// contains filtered or unexported fields
}

FileMetadataRepository persists metadata to disk using a configurable path resolver.

func NewFileMetadataRepository

func NewFileMetadataRepository(resolver MetadataPathResolver) *FileMetadataRepository

NewFileMetadataRepository constructs a repository that resolves its path on demand.

func (*FileMetadataRepository) Load

func (r *FileMetadataRepository) Load() (Metadata, error)

func (*FileMetadataRepository) Path

func (r *FileMetadataRepository) Path() (string, error)

func (*FileMetadataRepository) Save

func (r *FileMetadataRepository) Save(meta Metadata) (string, error)

type Metadata

type Metadata struct {
	Operator   string            `json:"operator,omitempty"`
	Location   string            `json:"location,omitempty"`
	Device     core.DeviceInfo   `json:"device"`
	Test       core.TestInfo     `json:"test"`
	Tags       []string          `json:"tags,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Metadata captures operator, device, and test context common to CLI and TUI workflows.

func LoadMetadata

func LoadMetadata() (Metadata, error)

LoadMetadata reads the persisted metadata file if present, returning defaults otherwise.

func (Metadata) Validate

func (m Metadata) Validate() error

Validate ensures the metadata conforms to simple structural constraints.

type MetadataPathResolver

type MetadataPathResolver func() (string, error)

MetadataPathResolver returns the metadata file path.

type MetadataRepository

type MetadataRepository interface {
	Load() (Metadata, error)
	Save(Metadata) (string, error)
	Path() (string, error)
}

MetadataRepository defines the contract for loading and saving metadata.

type TelemetryCfg

type TelemetryCfg struct {
	Enabled bool   // opt-in for anonymous metrics
	Backend string // "expvar" (default), "prometheus", or "none"
}

TelemetryCfg controls the anonymous metrics collection backend.

type UploadCfg

type UploadCfg struct {
	BatchBytes int64
	MaxRetries int
}

UploadCfg controls batching and retry behaviour for the upload subsystem.

Jump to

Keyboard shortcuts

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