Conversation
Co-authored-by: a-dubs <37227576+a-dubs@users.noreply.github.com>
Co-authored-by: a-dubs <37227576+a-dubs@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] implement a brand new way of configuring pycloudlib. allow for configuring any setting available at runtime to a class via the toml config. look at @canonical/pycloudlib/issues/457 for more context on this issue. and another related issue: @canonical/py...
Implement comprehensive TOML configuration system with validation and constructor parameter alignment
Jul 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a brand new TOML configuration system for pycloudlib that addresses long-standing configuration inconsistencies and limitations identified in issues canonical#457 and canonical#466.
Problem Statement
The existing configuration system had several critical issues:
Issue [enhancement] Update handling of "required_values" in cloud class canonical/pycloudlib#466: If all required values were provided to a cloud constructor, the TOML file was completely ignored, preventing users from using TOML as a base configuration with runtime overrides.
Issue feature request: completely align toml and class instantiation configuration options canonical/pycloudlib#457: Inconsistent configuration options between TOML and constructor parameters. SSH keys could not be passed at runtime and had to be configured in TOML or set after instantiation using the
use_keymethod.No validation: TOML configuration errors were only discovered at runtime when attempting to use cloud services.
Solution
🔧 Fixed Issue canonical#466 - TOML Always Parsed
_check_and_get_configto always parse TOML configuration when availableif all required values provided: ignore TOML completelyalways parse TOML + merge with constructor parameters🔧 Fixed Issue canonical#457 - Complete Configuration Alignment
✨ Added TOML Validation
🛠️ Enhanced Configuration System
validate_cloud_config()function for immediate error detectionmerge_configs()function for proper parameter merging with None value handlingparse_config()with optional validation supportKey Changes
Demonstration
A comprehensive demonstration script (
demo_new_config_system.py) shows all features working:Testing
Files Changed
config.py,cloud.py- Enhanced configuration systemconfig_schemas.py- JSON schemas for validationec2/cloud.py,azure/cloud.py- Parameter passingpycloudlib.toml.template- Updated documentationdemo_new_config_system.py- Comprehensive examplesBackward Compatibility
✅ Fully maintained - All existing code continues to work unchanged. The new features are additive and the configuration behavior is enhanced rather than replaced.
Closes canonical#457
Closes canonical#466
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.