mirror of
https://github.com/containers/podman.git
synced 2025-10-15 02:06:42 +08:00
add support to ;
for comments in unit files as per systemd documentation
Signed-off-by: Ahmed Moalla <ahmed.moalla@gmail.com>
This commit is contained in:
@ -204,7 +204,7 @@ func (f *UnitFile) Dup() *UnitFile {
|
||||
}
|
||||
|
||||
func lineIsComment(line string) bool {
|
||||
return len(line) == 0 || line[0] == '#' || line[0] == ':'
|
||||
return len(line) == 0 || line[0] == '#' || line[0] == ';'
|
||||
}
|
||||
|
||||
func lineIsGroup(line string) bool {
|
||||
|
@ -314,6 +314,33 @@ func TestUnitDropinPaths_Search(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommentsIgnored(t *testing.T) {
|
||||
unitWithComments := `[Container]
|
||||
# comment
|
||||
Name=my-container
|
||||
; another comment
|
||||
`
|
||||
f := NewUnitFile()
|
||||
if e := f.Parse(unitWithComments); e != nil {
|
||||
panic(e)
|
||||
}
|
||||
|
||||
groups := f.ListGroups()
|
||||
assert.Len(t, groups, 1)
|
||||
assert.Equal(t, "Container", groups[0])
|
||||
|
||||
comments := make([]string, 0, 2)
|
||||
for _, line := range f.groups[0].lines {
|
||||
if line.isComment {
|
||||
comments = append(comments, line.value)
|
||||
}
|
||||
}
|
||||
|
||||
assert.Len(t, comments, 2)
|
||||
assert.Equal(t, "# comment", comments[0])
|
||||
assert.Equal(t, "; another comment", comments[1])
|
||||
}
|
||||
|
||||
func FuzzParser(f *testing.F) {
|
||||
for _, sample := range samples {
|
||||
f.Add([]byte(sample))
|
||||
|
@ -11,11 +11,14 @@ After=network-online.target
|
||||
[Container]
|
||||
# Image=localhost/otherimagename:latest
|
||||
Image=localhost/imagename:latest
|
||||
; Image=localhost/image:latest
|
||||
ContainerName=greatName
|
||||
; ContainerName=otherName
|
||||
# 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 \
|
||||
; -v /other/path/to/watch/folder:/watch \
|
||||
PublishPort=9091:9091
|
||||
|
Reference in New Issue
Block a user