| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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.
Adds a new systemd resource plugin so Updatecli can read, check, and update options in systemd-style unit files, including Quadlet .container files.
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.
Sorry, something went wrong.
|
I tested the pullrequest with the following example, sources:
default:
kind: systemd
spec:
file: "/tmp/wg.container"
section: "Container"
option: Image
conditions:
default:
kind: systemd
spec:
file: "/tmp/wg.container"
section: "Container"
option: Image
targets:
default:
kind: systemd
disablesourceinput: true
spec:
file: "/tmp/wg.container"
section: "Container"
option: Volume
value: "xxx"
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. |
Sorry, something went wrong.
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 index (would need to add that). If needed later, we could also add an explicit all: true, but I don’t think that should be the default |
Sorry, something went wrong.
What do you think about this @olblak |
Sorry, something went wrong.
|
sorry I missed the ball, to align the behavior with other plugins like the YAML one cfr documentindex in the yaml documentation |
Sorry, something went wrong.
|
@ScMofeoluwa Do you need some help to finalize this pullrequest? |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
@olblak updated this now. I also addressed copilot's review but I left the target write path using go-systemd serialization for now rather than adding custom line/regex handling just to preserve comments, since that felt more fragile. Happy to adjust if you’d prefer a different approach |
Sorry, something went wrong.
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. |
Sorry, something went wrong.
|
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 |
Sorry, something went wrong.
|
Tick the box to add this pull request to the merge queue (same as @mergifyio queue).
|
Sorry, something went wrong.
Thanks for the fixes. The explicit section / option requirement makes sense for keeping this generic |
Sorry, something went wrong.
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
| Back | FazBrowse Home | New Git URL |
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