Skip to content

Commit

Permalink
Merge pull request #21556 from ygalblum/quadlet-comment-line
Browse files Browse the repository at this point in the history
Quadlet - do not look for line continuation in comment lines
  • Loading branch information
openshift-merge-bot[bot] authored Feb 8, 2024
2 parents 9011327 + d479797 commit 5311233
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/systemd/parser/unitfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,14 @@ func (f *UnitFile) Parse(data string) error {
var line string
line, data = nextLine(data, 0)

// Handle multi-line continuations
// Note: This doesn't support comments in the middle of the continuation, which systemd does
if lineIsKeyValuePair(line) {
for len(data) > 0 && line[len(line)-1] == '\\' {
line, data = nextLine(origdata, len(line)+1)
nLines++
if !lineIsComment(line) {
// Handle multi-line continuations
// Note: This doesn't support comments in the middle of the continuation, which systemd does
if lineIsKeyValuePair(line) {
for len(data) > 0 && line[len(line)-1] == '\\' {
line, data = nextLine(origdata, len(line)+1)
nLines++
}
}
}

Expand Down
21 changes: 21 additions & 0 deletions test/e2e/quadlet/comment-with-continuation.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## assert-podman-final-args localhost/imagename:latest
## assert-podman-args --publish 9091:9091
## assert-podman-args "--name=greatName"

[Unit]
Wants=network-online.target
After=network-online.target

# -e HOST_WHITELIST= `#optional` \

[Container]
# Image=localhost/otherimagename:latest
Image=localhost/imagename:latest
ContainerName=greatName
# HostName=my-hostname
Label=io.containers.autoupdate=registry
Environment=PUID=1000 PGID=100 SEED_RATIO=1.3 TZ=Europe/Prague
Volume=./.config:/config
Volume=./downloads:/downloads
# -v /path/to/watch/folder:/watch \
PublishPort=9091:9091
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ BOGUS=foo
Entry("basepodman.container", "basepodman.container", 0, ""),
Entry("capabilities.container", "capabilities.container", 0, ""),
Entry("capabilities2.container", "capabilities2.container", 0, ""),
Entry("comment-with-continuation.container", "comment-with-continuation.container", 0, ""),
Entry("devices.container", "devices.container", 0, ""),
Entry("disableselinux.container", "disableselinux.container", 0, ""),
Entry("dns-options.container", "dns-options.container", 0, ""),
Expand Down

0 comments on commit 5311233

Please sign in to comment.