Skip to content

Split config loading and management into individual internal config package#33

Open
Janni2006 wants to merge 7 commits into
developmentfrom
package_split_config
Open

Split config loading and management into individual internal config package#33
Janni2006 wants to merge 7 commits into
developmentfrom
package_split_config

Conversation

@Janni2006

Copy link
Copy Markdown
Contributor

This pull request refactors the configuration management of the project by moving configuration logic from main.go into a new dedicated internal/config package. The new package provides structured configuration models, serialization (defaulting), and validation logic, leading to cleaner and more maintainable code. The main application now loads, serializes, and validates configuration using this package, and all references to configuration data in main.go are updated accordingly.

Configuration Refactor and Improvements:

  • Introduced a new internal/config package with structured configuration models (Config, OpencastConfig, DisplayConfig, MetricsConfig, etc.), including YAML tags for file parsing.
  • Added serialization logic in serialize.go to set default values (e.g., default listen address, timeout, metrics endpoint) and trim trailing slashes from URLs.
  • Added validation logic in validate.go to ensure required configuration fields are present and valid (e.g., Opencast URL must not be empty, timeout must be positive).
  • Implemented a LoadFromFile method in main.go to load, serialize, and validate configuration from a YAML file, replacing the previous hand-rolled loading logic. [1] [2] [3]

Main Application Updates:

  • Updated all references in main.go to use the new config.Config struct (cConfig) instead of the old inline struct, and removed the old configuration struct definitions and loading logic. [1] [2] [3] [4] [5] [6] [7]

Configuration File Changes:

  • Updated opencast-ca-display.yml example values for Opencast URL, agent, and timeout to reflect new defaults and test values. [1] [2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant