-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support to ; for comments in unit files as per systemd documentation #24987
add support to ; for comments in unit files as per systemd documentation #24987
Conversation
f00d9c7
to
2528334
Compare
LGTM |
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.
It might be good to add one full e2e test (see test/e2e/quadlet) for such comment as well to ensure it actually works with the real binary.
pkg/systemd/parser/unitfile.go
Outdated
@@ -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] == ':' || line[0] == ';' |
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.
was the colon char here maybe intended to be ;
originally. Why would we allow :
as comment line?Systemd does not seem to documented that value.
cc @ygalblum
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.
This is actually @alexlarsson's code. It could be just a typo. All the tests use #
for comments. So, I can't know for sure if we meant to support :
.
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.
:
is not a valid comment in systemd (per documentation). @AhmedMoalla could you please drop the line[0] == ':'
case here?
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.
Ok will do. I initially did not do it to prevent it from breaking quadlet files for users using :
to comment. But removing it is the right thing to do.
Will look into that |
2528334
to
b61d406
Compare
…ation Signed-off-by: Ahmed Moalla <[email protected]>
b61d406
to
75b4a1b
Compare
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.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AhmedMoalla, rhatdan, ygalblum The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Currently the unit file parser supports
#
and:
characters to define comments. But, the documentation states that the characters used for comments are#
and;
Systemd DocumentationThis PR aims to add support to
;
for comments in unit files as per systemd documentation.without breaking changes by leaving:
as a supported character for commenting.The character:
should eventually not be supported anymore and does not cause problems at the moment because systemd ignores lines with wrong syntax.An example of a systemd service:
By checking logs with
journalctl -u hello-world -e
I get this in the logs as a warning but the service runs correctly:Does this PR introduce a user-facing change?