Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add config property to ops.CharmMeta #1493

Open
MichaelThamm opened this issue Dec 9, 2024 · 0 comments
Open

Feature: Add config property to ops.CharmMeta #1493

MichaelThamm opened this issue Dec 9, 2024 · 0 comments

Comments

@MichaelThamm
Copy link

There are situations where we want to compare against or set the default config values of a charm config option.

E.g. A user sets an invalid log level and so the charm sets the default value.

if some_config not in allowed_list:
    some_config = self.meta.config["some_config"]["default"]

If we we have string literals scattered throughout code that are supposed to "track" the config defaults then this is code duplication and could be solved by adding a config property to ops.CharmMeta. This currently supports most of the top-level keys of a charmcraft.yaml file and Scenario already effectively has this, so it's quite viable.

Currently this is achievable with loading the charmcraft.yaml yourself. Another way is to use stored state but both options enable varying coding styles across charms which could be solved with the self.meta.

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

No branches or pull requests

1 participant