GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(systemd): add resource plugin for systemd unit files by ScMofeoluwa · Pull Request #8970 · updatecli/updatecli

Conversation

@ScMofeoluwa

@ScMofeoluwa ScMofeoluwa commented May 28, 2026

Copy link
Copy Markdown
Contributor

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

  • Tests pass
  • Documentation update needed (will do with autodiscovery plugin)

Refs #8951

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olblak reacted with heart emoji
All reactions
  • ❤️ 1 reaction
ScMofeoluwa and others added 2 commits May 28, 2026 18:40
@ScMofeoluwa
feat(systemd): add resource plugin for systemd unit files
0174b5a
Adds a systemd resource plugin capable of reading, checking, and
updating options in systemd unit files using go-systemd

Refs updatecli#8951
@ScMofeoluwa
Merge branch 'main' into feat/systemd-resource
c8cbdcc
@olblak
olblak requested a review from Copilot May 29, 2026 13:05
@olblak olblak added the enhancement New feature or request label May 29, 2026
Copilot started reviewing on behalf of olblak May 29, 2026 13:05
View session
@olblak olblak added the resource-systemd label May 29, 2026
Copilot AI reviewed May 29, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 systemd resource implementation for source, condition, target, validation, and report config.
  • Registers the systemd resource kind in the resource factory and schema mapping.
  • Adds unit tests and the go-systemd dependency.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/plugins/resources/systemd/target.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/plugins/resources/systemd/target.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/plugins/resources/systemd/condition.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented May 29, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.
One of things that I am wondering is how to handle multiple option like Volume or PublishPort

Another question that I am wondering in the case of the example shared in the linked issue.
Because right now it will update the first option it find

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ScMofeoluwa

ScMofeoluwa commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

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. One of things that I am wondering is how to handle multiple option like Volume or PublishPort

Another question that I am wondering in the case of the example shared in the linked issue. Because right now it will update the first option it find

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ScMofeoluwa

ScMofeoluwa commented Jun 21, 2026

Copy link
Copy Markdown
Contributor Author

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. One of things that I am wondering is how to handle multiple option like Volume or PublishPort
Another question that I am wondering in the case of the example shared in the linked issue. Because right now it will update the first option it find

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

What do you think about this @olblak

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented Jun 23, 2026

Copy link
Copy Markdown
Member

sorry I missed the ball, to align the behavior with other plugins like the YAML one
I think the default should be to update only the first occurence unless an index value is defined

cfr documentindex in the yaml documentation

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented Jun 26, 2026

Copy link
Copy Markdown
Member

@ScMofeoluwa Do you need some help to finalize this pullrequest?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ScMofeoluwa

ScMofeoluwa commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ScMofeoluwa added 2 commits June 27, 2026 11:21
@ScMofeoluwa
fix(systemd): support indexed options
d2c0ad4
@ScMofeoluwa
Merge branch 'main' of https://github.com/updatecli/updatecli into fe…
0cc262a
…at/systemd-resource
@ScMofeoluwa

ScMofeoluwa commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olblak and others added 4 commits June 29, 2026 13:05
@olblak
Merge branch 'main' into feat/systemd-resource
cab56b0
@olblak
Merge branch 'main' into feat/systemd-resource
8aee808
@olblak
feat: update all option unless index is specified
b0a1797
Also bring the following fixes

* fix target result description
* cleanup spec comment
* fix default workingdir

Signed-off-by: Olblak <[email protected]>
@olblak
Merge branch 'main' into feat/systemd-resource
9cd744b
@olblak

olblak commented Jul 1, 2026

Copy link
Copy Markdown
Member

While doing some manual testing, I spotted a few issues that I fixed in my last commit.
On top of this I also implemented the default index which update all options if unset

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented Jul 1, 2026

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mergify

mergify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ScMofeoluwa

ScMofeoluwa commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

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

Thanks for the fixes. The explicit section / option requirement makes sense for keeping this generic

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

olblak and others added 2 commits July 1, 2026 19:48
@olblak
Merge branch 'main' into feat/systemd-resource
f76c4b6
@olblak
chore: add missing comment
f6fe933
Signed-off-by: Olblak <[email protected]>
@olblak
olblak requested a review from Copilot July 1, 2026 17:57
Copilot started reviewing on behalf of olblak July 1, 2026 17:58
View session
Copilot AI reviewed Jul 1, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/plugins/resources/systemd/main.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/plugins/resources/systemd/target.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/plugins/resources/systemd/target.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pkg/plugins/resources/systemd/source.go Resolved

Uh oh!

There was an error while loading. Please reload this page.

@olblak
fix: various cleanup
97de751
Signed-off-by: Olblak <[email protected]>
@olblak
olblak merged commit 463c40a into updatecli:main Jul 1, 2026
8 of 9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@olblak olblak mentioned this pull request Jul 8, 2026
Add systemd documentation updatecli/website#3468
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement New feature or request resource-systemd

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ScMofeoluwa @olblak
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.