Skip to content

feat(systemd): add resource plugin for systemd unit files#8970

Open
ScMofeoluwa wants to merge 2 commits into
updatecli:mainfrom
ScMofeoluwa:feat/systemd-resource
Open

feat(systemd): add resource plugin for systemd unit files#8970
ScMofeoluwa wants to merge 2 commits into
updatecli:mainfrom
ScMofeoluwa:feat/systemd-resource

Conversation

@ScMofeoluwa

Copy link
Copy Markdown

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

ScMofeoluwa and others added 2 commits May 28, 2026 18:40
Adds a systemd resource plugin capable of reading, checking, and
updating options in systemd unit files using go-systemd

Refs updatecli#8951
@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 AI left a comment

Copy link
Copy Markdown
Contributor

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.


opt.Value = expected

reader := unit.Serialize(opts)
Comment on lines +15 to +18
expected := source
if expected == "" {
expected = s.spec.Value
}
Comment on lines +12 to +15
expected := source
if expected == "" {
expected = s.spec.Value
}
@olblak

olblak commented May 29, 2026

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

@ScMofeoluwa

Copy link
Copy Markdown
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request resource-systemd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants