mirror of
https://github.com/containers/podman.git
synced 2025-06-24 11:28:24 +08:00
Merge pull request #21112 from ygalblum/quadlet-multiline-trailing-whitespaces
Quadlet - fix trailing whitespaces handling
This commit is contained in:
@ -12,7 +12,7 @@ repos:
|
|||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
exclude: test/buildah-bud/buildah-tests.diff
|
exclude: test/buildah-bud/buildah-tests.diff
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
exclude: test/buildah-bud/buildah-tests.diff|test/e2e/quadlet/remap-keep-id2.container
|
exclude: test/buildah-bud/buildah-tests.diff|test/e2e/quadlet/remap-keep-id2.container|test/e2e/quadlet/line-continuation-whitespace.container
|
||||||
- id: mixed-line-ending
|
- id: mixed-line-ending
|
||||||
- id: check-byte-order-marker
|
- id: check-byte-order-marker
|
||||||
- id: check-executables-have-shebangs
|
- id: check-executables-have-shebangs
|
||||||
|
@ -378,12 +378,23 @@ func nextLine(data string, afterPos int) (string, string) {
|
|||||||
return data, ""
|
return data, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func trimSpacesFromLines(data string) string {
|
||||||
|
lines := strings.Split(data, "\n")
|
||||||
|
for i, line := range lines {
|
||||||
|
lines[i] = strings.TrimSpace(line)
|
||||||
|
}
|
||||||
|
return strings.Join(lines, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
// Parse an already loaded unit file (in the form of a string)
|
// Parse an already loaded unit file (in the form of a string)
|
||||||
func (f *UnitFile) Parse(data string) error {
|
func (f *UnitFile) Parse(data string) error {
|
||||||
p := &UnitFileParser{
|
p := &UnitFileParser{
|
||||||
file: f,
|
file: f,
|
||||||
lineNr: 1,
|
lineNr: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data = trimSpacesFromLines(data)
|
||||||
|
|
||||||
for len(data) > 0 {
|
for len(data) > 0 {
|
||||||
origdata := data
|
origdata := data
|
||||||
nLines := 1
|
nLines := 1
|
||||||
|
9
test/e2e/quadlet/line-continuation-whitespace.container
Normal file
9
test/e2e/quadlet/line-continuation-whitespace.container
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## assert-podman-final-args localhost/imagename "/some/binary file" "--arg1" "arg 2"
|
||||||
|
## assert-podman-args "--publish" "80:80"
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
Image=localhost/imagename
|
||||||
|
# Keep whitespace at the end of the following line
|
||||||
|
Exec="/some/binary file" --arg1 \
|
||||||
|
"arg 2"
|
||||||
|
PublishPort=80:80
|
@ -776,6 +776,7 @@ BOGUS=foo
|
|||||||
Entry("install.container", "install.container", 0, ""),
|
Entry("install.container", "install.container", 0, ""),
|
||||||
Entry("ip.container", "ip.container", 0, ""),
|
Entry("ip.container", "ip.container", 0, ""),
|
||||||
Entry("label.container", "label.container", 0, ""),
|
Entry("label.container", "label.container", 0, ""),
|
||||||
|
Entry("line-continuation-whitespace.container", "line-continuation-whitespace.container", 0, ""),
|
||||||
Entry("logdriver.container", "logdriver.container", 0, ""),
|
Entry("logdriver.container", "logdriver.container", 0, ""),
|
||||||
Entry("mask.container", "mask.container", 0, ""),
|
Entry("mask.container", "mask.container", 0, ""),
|
||||||
Entry("mount.container", "mount.container", 0, ""),
|
Entry("mount.container", "mount.container", 0, ""),
|
||||||
|
Reference in New Issue
Block a user