config

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

README

internal/config

Responsibility

  • Loads and manages the application configuration.
  • Provides a singleton instance of the configuration.
  • Validates the configuration for missing or invalid fields.

Scope

  • Configuration struct definition.
  • Loading configuration from YAML file using spf13/viper.
  • Validation of configuration fields.

Test Suite Overview

  • Tests should cover configuration loading and validation.

Decisions & Potential Gotchas

  • Uses spf13/viper for configuration loading.
  • Configuration file is located at config.yaml.
  • Validation logic ensures that required fields are present and valid.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name    string `mapstructure:"name"`
	Version string `mapstructure:"version"`
}

App represents the application configuration.

type Atmosphere

type Atmosphere struct {
	ISAConfiguration ISAConfiguration `mapstructure:"isa_configuration"`
}

Atmosphere represents the atmosphere configuration.

type BenchmarkEntry added in v0.3.5

type BenchmarkEntry struct {
	Name        string `mapstructure:"name" validate:"required"`
	Description string `mapstructure:"description"` // Added missing field
	DesignFile  string `mapstructure:"design_file" validate:"required,file"`
	DataDir     string `mapstructure:"data_dir" validate:"required,dir"`
	Enabled     bool   `mapstructure:"enabled" validate:"boolean"`
}

BenchmarkEntry defines the configuration for a single benchmark.

type Config

type Config struct {
	Setup      Setup                     `mapstructure:"setup"`
	Server     Server                    `mapstructure:"server"`
	Engine     Engine                    `mapstructure:"engine"`
	Benchmarks map[string]BenchmarkEntry `mapstructure:"benchmarks"`
}

Config represents the overall application configuration.

func GetConfig

func GetConfig() (*Config, error)

GetConfig reads configuration, validates it, resolves paths, and returns the singleton instance.

func (*Config) Bytes

func (c *Config) Bytes() []byte

Bytes returns the configuration as bytes

func (*Config) String

func (c *Config) String() map[string]string

String returns the configuration as a map of strings, useful for testing.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks the config for missing or invalid fields.

type Engine

type Engine struct {
	External   External   `mapstructure:"external"`
	Options    Options    `mapstructure:"options"`
	Simulation Simulation `mapstructure:"simulation"`
}

Engine represents the engine configuration (simulation specific).

type External

type External struct {
	OpenRocketVersion string `mapstructure:"openrocket_version"`
}

External represents the external configuration.

type ISAConfiguration

type ISAConfiguration struct {
	SpecificGasConstant  float64 `mapstructure:"specific_gas_constant"`
	GravitationalAccel   float64 `mapstructure:"gravitational_accel"`
	SeaLevelDensity      float64 `mapstructure:"sea_level_density"`
	SeaLevelTemperature  float64 `mapstructure:"sea_level_temperature"`
	SeaLevelPressure     float64 `mapstructure:"sea_level_pressure"`
	RatioSpecificHeats   float64 `mapstructure:"ratio_specific_heats"`
	TemperatureLapseRate float64 `mapstructure:"temperature_lapse_rate"`
}

ISAConfiguration represents the ISA configuration.

type Launchrail

type Launchrail struct {
	Length      float64 `mapstructure:"length"`
	Angle       float64 `mapstructure:"angle"`
	Orientation float64 `mapstructure:"orientation"`
}

Launchrail represents the launchrail configuration.

type Launchsite

type Launchsite struct {
	Latitude   float64    `mapstructure:"latitude"`
	Longitude  float64    `mapstructure:"longitude"`
	Altitude   float64    `mapstructure:"altitude"`
	Atmosphere Atmosphere `mapstructure:"atmosphere"`
}

Launchsite represents the launchsite configuration.

type Logging

type Logging struct {
	Level string `mapstructure:"level"`
}

Logging represents the logging configuration.

type Options

type Options struct {
	MotorDesignation string     `mapstructure:"motor_designation"`
	OpenRocketFile   string     `mapstructure:"openrocket_file"`
	Launchrail       Launchrail `mapstructure:"launchrail"`
	Launchsite       Launchsite `mapstructure:"launchsite"`
}

Options represents the application options.

type Plugins

type Plugins struct {
	Paths []string `mapstructure:"paths"`
}

Plugins represents runtime plugins to enrich the simulation

type Server

type Server struct {
	Port int `mapstructure:"port"`
}

Server represents the server configuration.

type Setup

type Setup struct {
	App     App     `mapstructure:"app"`
	Logging Logging `mapstructure:"logging"`
	Plugins Plugins `mapstructure:"plugins"`
}

Setup represents the setup configuration.

type Simulation

type Simulation struct {
	Step            float64 `mapstructure:"step"`
	MaxTime         float64 `mapstructure:"max_time"`
	GroundTolerance float64 `mapstructure:"ground_tolerance"` // Add ground tolerance
}

Simulation represents the simulation configuration.

Jump to

Keyboard shortcuts

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