Skip to content
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

Docs: Use the correct YAML text block indicator to prevent formatting issues #11552

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

neodon
Copy link

@neodon neodon commented Nov 14, 2024

In the Spark Quickstart guide, the initial docker-compose example specifies an entrypoint script in a multi-line string. The string is mistakenly started with the 'folded style' indicator >, which causes formatters to collapse it into one line.

Changing to the 'literal style' indicator | resolves the issue and preserves formatting.

Folded Style: https://yaml.org/spec/1.2.2/#813-folded-style
Literal Style: https://yaml.org/spec/1.2.2/#812-literal-style

… issues.

In the Spark Quickstart guide, the initial docker-compose example specifies an
entrypoint script in a multi-line string. The string is mistakenly started with
the 'folded style' indicator `>`, which causes formatters to collapse it into
one line.

Changing to the 'literal style' indicator `|` resolves the issue and preserves
formatting.

Folded Style: <https://yaml.org/spec/1.2.2/#813-folded-style>
Literal Style: <https://yaml.org/spec/1.2.2/#812-literal-style>
@github-actions github-actions bot added the docs label Nov 14, 2024
@neodon
Copy link
Author

neodon commented Nov 15, 2024

Pardon the (probably) unnecessary merge.

entrypoint: >
entrypoint: |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, > collapses the code into one line, but do we need one or multi-line here? IMHO it's one line because it's one command (/bin/sh -c "...")

Copy link
Author

@neodon neodon Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree with you on "one line for one command". In this case, however, there is one outer command that contains multiple inner commands. So applying your criteria, would the inner commands be on separate lines?

There's also the issue of readability when my editor tries to format it. With >, it doesn't change anything because the overall value is a valid multiline block. With | and formatting, though, it becomes:

/bin/sh -c "      until (/usr/bin/mc config host add minio http://minio:9000 admin password) do echo '...waiting...' && sleep 1; done;      /usr/bin/mc rm -r --force minio/warehouse;      /usr/bin/mc mb minio/warehouse;      /usr/bin/mc policy set public minio/warehouse;      tail -f /dev/null      "

I have trouble following that result. I have to work around the problem somehow and fight my editor to keep it from changing that line. It's not a concern for everyone, but most of my projects use format-on-save.

Edit: I hope I understood your point correctly. I'll add that the block is still a valid entrypoint script and runs successfully when multiline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants