Add the ability to populate State from metadata #1454
Labels
feature
New feature or request
investigate
Needs further investigation - do we want to do this?
testing
Related to ops.testing
The
State
could have some default components based on theContext
metadata, or perhaps there could be afill_from_context
method or similar.For example, this could add:
Container
for each container in the metadata (although you'd probably want to be able to specify whethercan_connect
should beTrue
orFalse
, or it seems like there might be a lot of awkwarddataclasses.replace
afterwards)config
that's the same as the defaults in the metadataNetwork
(there's essentially always a Juju network, right?)Storage
for each storage in the metadata (to the minimum side of themultiple
value if provided)StoredState
for eachops.StoredState
attribute on theContext
's charm class (not perfect since these can exist elsewhere, particularly in libs, but maybe a useful base?)I don't think it could have relations (even if we do make it possible to have data-inaccessible relations, e.g. #1452) since there's a practical difference between a relation existing (from the point of view of the unit) and not existing, wider than just the data being available.
I don't think it could include resources, even though they're in the metadata and always (?) available, because it doesn't seem like there's any way to have a sensible default location for the content.
See this Matrix discussion for more background.
The text was updated successfully, but these errors were encountered: