forked from canonical/pebble
-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(planstate): add extension support #17
Draft
flotter
wants to merge
9
commits into
plan-section-support
Choose a base branch
from
plan-manager-sections
base: plan-section-support
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains 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
flotter
force-pushed
the
plan-section-support
branch
9 times, most recently
from
August 8, 2024 18:05
084f087
to
16d6dc9
Compare
flotter
force-pushed
the
plan-manager-sections
branch
from
August 13, 2024 14:14
2b30244
to
10a1398
Compare
flotter
force-pushed
the
plan-section-support
branch
2 times, most recently
from
August 19, 2024 18:44
5ff2951
to
e55b435
Compare
flotter
force-pushed
the
plan-manager-sections
branch
2 times, most recently
from
August 19, 2024 21:53
bfab837
to
ac9bf66
Compare
flotter
force-pushed
the
plan-section-support
branch
from
August 20, 2024 06:54
58f54e6
to
662fd6a
Compare
flotter
force-pushed
the
plan-manager-sections
branch
3 times, most recently
from
August 26, 2024 14:04
843bca0
to
38da84a
Compare
flotter
force-pushed
the
plan-section-support
branch
from
August 26, 2024 14:35
d3ae02c
to
8de6590
Compare
flotter
force-pushed
the
plan-manager-sections
branch
from
August 26, 2024 14:36
38da84a
to
f5eff8e
Compare
flotter
force-pushed
the
plan-section-support
branch
from
August 28, 2024 14:38
743147c
to
9a51cfe
Compare
flotter
force-pushed
the
plan-manager-sections
branch
from
August 28, 2024 19:21
f5eff8e
to
a1d6300
Compare
…nical#493) This means that not every request/response needs to acquire the state lock, as shown by the removal of the custom response type in the /v1/health endpoint. Note that there's a test, TestHealthStateLockNotHeldSuccess, that specifically tests that the state lock is not held during /v1/health requests. If we accidentally introduce locking again, that will fail. Fixes canonical#366.
flotter
force-pushed
the
plan-manager-sections
branch
from
August 30, 2024 06:51
5d9bef2
to
37d9be4
Compare
The plan library was originally written as a configuration schema for the services manager (servstate). Over time the need arose to support configurations for other managers such as checks (checkstate) and log-targets (logstate). The configuration schema for these managers, closely related to the services manager, has since also been built in to the plan library. The services manager and its related checks and log-targets functionality will always be part of the Pebble core. However, as Pebble is getting more functionality (additional managers) and also used as a core in derivative projects, a more modular and dynamic approach to extending the schema is needed. Add an the ```SectionExtension``` interface for use by managers who wishes to register a schema extension during Pebble startup. Inside each layer, top level entries are now referred to as ```sections``` (built-in sections includes ```summary```, ```description```, ```services```, ```log-targets``` and ```checks```). Each section has an associated ```field``` that is the top level key, and if supplied by an extension, an opaque backing type ```Section```. **SectionExtension interface:** ``` // SectionExtension allows the plan layer schema to be extended without // adding centralised schema knowledge to the plan library. type SectionExtension interface { // ParseSection returns a newly allocated concrete type containing the // unmarshalled section content. ParseSection(data yaml.Node) (LayerSection, error) // CombineSections returns a newly allocated concrete type containing the // result of combining the supplied sections in order. CombineSections(sections ...LayerSection) (LayerSection, error) // ValidatePlan takes the complete plan as input, and allows the // extension to validate the plan. This can be used for cross section // dependency validation. ValidatePlan(plan *Plan) error } type Section interface { // Validate checks whether the section is valid, returning an error if not. Validate() error // IsZero reports whether the section is empty. IsZero() bool } ``` **Example usage:** ``` // New SectionExtension type type fooExtension struct{} func (f *fooExtension) ParseSection(data yaml.Node) (LayerSection, error) {...} func (f *fooExtension) CombineSections(sections ...LayerSection) (LayerSection, error) {...} func (f *fooExtension) ValidatePlan(plan *Plan) error {...} // New Section type type FooSection struct { Entries map[string]Bar `yaml:",inline,omitempty"` } type Bar struct { Name string `yaml:"name,omitempty"` } func (s *FooSection) Validate() error {...} func (s *FooSection) IsZero() bool {...} ``` ``` // Early startup plan.RegisterExtension("foo", &fooExtension{}) : // Load layers containing new section newPlan := plan.ReadDir(layersDir) : // Show plan yaml.Marshal(newPlan) ``` Example YAML output: ``` foo: bar1: name: test1 bar2: name: test2 ```
flotter
force-pushed
the
plan-manager-sections
branch
from
August 30, 2024 06:55
37d9be4
to
5966f30
Compare
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.
No description provided.