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

fix: remove empty lines from docker-compose.varnish_extras.yaml, fixes #24 #28

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

stasadev
Copy link
Member

@stasadev stasadev commented Jul 4, 2024

The Issue

How This PR Solves The Issue

Removes empty lines using go templates {{- -}}
Renames docker-compose.varnish-extras.yaml to docker-compose.varnish_extras.yaml

Manual Testing Instructions

ddev get https://github.com/ddev/ddev-varnish/tarball/20240704_stasadev_remove_empty_lines

Automated Testing Overview

Related Issue Link(s)

Release/Deployment Notes

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

For reasons of evaluation precedence, IMO docker-compose.varnish_extras.yaml works better as a recommendation. I can't remember what the issue was. But that's the format I always recommend.

@stasadev
Copy link
Member Author

stasadev commented Jul 5, 2024

This PR does not affect the functionality of docker-compose.varnish-extras.yaml at all, it just makes it more presentable.

We have the same empty lines in the .ddev/.ddev-docker-compose-base.yaml and ~/.ddev/.router-compose.yaml files generated by DDEV, which doesn't matter because those files are not committed.

But it matters here because you are committing this file.

@jedubois
Copy link
Collaborator

jedubois commented Jul 5, 2024

For reasons of evaluation precedence, IMO docker-compose.varnish_extras.yaml works better as a recommendation. I can't remember what the issue was. But that's the format I always recommend.

@rfay, are you referring to this recommendation ?

@rfay
Copy link
Member

rfay commented Jul 5, 2024

Yes, didn't realize it made it into the docs :)

@stasadev
Copy link
Member Author

stasadev commented Jul 5, 2024

Ah, this talk about _ and -, I didn't see that at first. Okay, let's rename it here.

@stasadev stasadev changed the title fix: remove empty lines from docker-compose.varnish-extras.yaml, fixes #24 fix: remove empty lines from docker-compose.varnish_extras.yaml, fixes #24 Jul 5, 2024
@rfay
Copy link
Member

rfay commented Jul 5, 2024

Well, the tests are improved! Don't know if the result is improved :)

@stasadev
Copy link
Member Author

stasadev commented Jul 5, 2024

I leave the testing to the experts 🙂.

To be honest, I don't understand how this add-on works, even after reading README.md and Varnish docs.

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

The way to get rid of all the extra lines is to use better go templating.
For example

    {{- $project_tld := "ddev.site" -}}
    {{- if .DdevGlobalConfig.project_tld }}{{ $project_tld = .DdevGlobalConfig.project_tld }}{{ end }}

The mysterious {{- and -}} are new discoveries for me, and I usually have some trouble getting them to work the first time. But this is where all the lines come from, and this is how to clean it up.

@stasadev stasadev requested a review from rfay July 23, 2024 09:49
Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

This is certainly looking great to solve the problem at hand. There's just a bit of cleanup now I think.

  • In pre_install_actions we should remove the old docker-compose.varnish-extra.yaml if it exists and contains #ddev-generated
  • In removal_actions we should remove docker_compose.varnish_extras.yaml if it exists and has #ddev-generated

Note that to see this in action, do a curl -I <site> to see the header that shows varnish has injected itself:

rfay@rfay-tag1-m1:~/workspace/d10$ curl -I https://d10.ddev.site
HTTP/2 200
accept-ranges: bytes
age: 0
cache-control: must-revalidate, no-cache, private
content-language: en
content-type: text/html; charset=UTF-8
date: Tue, 09 Jul 2024 21:09:47 GMT
expires: Sun, 19 Nov 1978 05:00:00 GMT
server: nginx
vary: Accept-Encoding
via: 1.1 varnish (Varnish/6.0)
x-content-type-options: nosniff
x-drupal-cache: HIT
x-drupal-dynamic-cache: MISS
x-frame-options: SAMEORIGIN
x-generator: Drupal 10 (https://www.drupal.org)
x-varnish: 163852

Copy link
Member

@rfay rfay left a comment

Choose a reason for hiding this comment

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

You did loads more than was casually asked in the issue! Thanks.

@rfay rfay merged commit a3ee718 into main Aug 2, 2024
2 checks passed
@rfay rfay deleted the 20240704_stasadev_remove_empty_lines branch August 2, 2024 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants