feat(systemd): add resource plugin for systemd unit files - #8970
Conversation
Adds a systemd resource plugin capable of reading, checking, and updating options in systemd unit files using go-systemd Refs updatecli#8951
There was a problem hiding this comment.
Pull request overview
Adds a new systemd resource plugin so Updatecli can read, check, and update options in systemd-style unit files, including Quadlet .container files.
Changes:
- Introduces
systemdresource implementation for source, condition, target, validation, and report config. - Registers the
systemdresource kind in the resource factory and schema mapping. - Adds unit tests and the
go-systemddependency.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/plugins/resources/systemd/main.go |
Defines the resource, defaults, config reporting, and unit option parsing. |
pkg/plugins/resources/systemd/spec.go |
Defines and validates the systemd resource spec. |
pkg/plugins/resources/systemd/source.go |
Reads configured option values from unit files. |
pkg/plugins/resources/systemd/condition.go |
Checks configured option values against expected values. |
pkg/plugins/resources/systemd/target.go |
Updates configured option values in unit files. |
pkg/plugins/resources/systemd/*_test.go |
Adds tests for construction, validation, source, condition, and target behavior. |
pkg/core/pipeline/resource/main.go |
Registers the new systemd resource kind. |
go.mod |
Adds github.com/coreos/go-systemd/v22. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I tested the pullrequest with the following example, where /tmp/wg.container is the file mentioned in the issue. Another question that I am wondering in the case of the example shared in the linked issue. |
Hmm, good point. I think a safer approach might be: update normally when there is only one match, but return an error when multiple matching options are found unless the user provides an explicit selector like |
What do you think about this @olblak |
|
sorry I missed the ball, to align the behavior with other plugins like the YAML one cfr documentindex in the yaml documentation |
|
@ScMofeoluwa Do you need some help to finalize this pullrequest? |
Sorry, this got buried in my mail. Thanks for the clarification. I’ll update the resource to follow that behavior and push an update shortly. |
|
@olblak updated this now. I also addressed copilot's review but I left the target write path using |
Also bring the following fixes * fix target result description * cleanup spec comment * fix default workingdir Signed-off-by: Olblak <me@olblak.com>
|
While doing some manual testing, I spotted a few issues that I fixed in my last commit. |
|
I also forgot to specify in my comment, I removed the default value for section, and option as I think this plugin should be generic to any systemd configuration |
|
Tick the box to add this pull request to the merge queue (same as
|
Thanks for the fixes. The explicit |
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Adds a systemd resource plugin for reading and updating options in systemd unit files using go-systemd. Defaults to Container/Image for Quadlet compat.
Test
go test ./pkg/plugins/resources/systemd/Checklist
Refs #8951