Skip to content

Commit

Permalink
Merge pull request #18981 from rhatdan/quadlet
Browse files Browse the repository at this point in the history
Trim whitespace from unit files while parsing
  • Loading branch information
openshift-merge-robot authored Jun 26, 2023
2 parents 3a013b6 + bc5269f commit 6a742cb
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: end-of-file-fixer
exclude: test/buildah-bud/buildah-tests.diff
- id: trailing-whitespace
exclude: test/buildah-bud/buildah-tests.diff
exclude: test/buildah-bud/buildah-tests.diff|test/e2e/quadlet/remap-keep-id2.container
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ help: ## (Default) Print listing of key targets with their descriptions
.PHONY: .gitvalidation
.gitvalidation:
@echo "Validating vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'"
GIT_CHECK_EXCLUDE="./vendor:./test/tools/vendor:docs/make.bat:test/buildah-bud/buildah-tests.diff" ./test/tools/build/git-validation -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD)
GIT_CHECK_EXCLUDE="./vendor:./test/tools/vendor:docs/make.bat:test/buildah-bud/buildah-tests.diff:test/e2e/quadlet/remap-keep-id2.container" ./test/tools/build/git-validation -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD)

.PHONY: lint
lint: golangci-lint
Expand Down
2 changes: 1 addition & 1 deletion pkg/systemd/parser/unitfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (p *UnitFileParser) flushPendingComments(toComment bool) {
func nextLine(data string, afterPos int) (string, string) {
rest := data[afterPos:]
if i := strings.Index(rest, "\n"); i >= 0 {
return data[:i+afterPos], data[i+afterPos+1:]
return strings.TrimSpace(data[:i+afterPos]), data[i+afterPos+1:]
}
return data, ""
}
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/quadlet/remap-keep-id2.container
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[Container]
Image=localhost/imagename
RemapUsers=keep-id
# The added three spaces to keep-id are necessary for test of trimwhitespace
RemapUsers=keep-id
RemapUid=200
RemapGid=210

0 comments on commit 6a742cb

Please sign in to comment.