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

Allow custom templates to be provided separately for each template #938

Merged
merged 4 commits into from
Feb 8, 2017

Conversation

ANorwell
Copy link
Contributor

@ANorwell ANorwell commented Feb 3, 2017

This is a proposed fix for to #937.

Unfortunately, this is a breaking change to the templates directory layout, but it seems to be necessary to allow the different templates to be set independently.

Also, I'm not familiar with the sbt-native-packager codebase. This seems to be the right change, but it's possible this will have unintended consequences.

Copy link
Contributor

@muuki88 muuki88 left a comment

Choose a reason for hiding this comment

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

Thanks @ANorwell for your PR. The fix is correct, thanks for catching and fixing this.

Can you correct the failing tests? It should be just moving the files to the correct folder.

We should probably add some tests for overriding the loader functions too. If you have time, this would be awesome. You can put these all into one test and use sbt scripted test commands copy-file and delete to check if the files are picked up correctly.

@@ -71,5 +71,5 @@ package object systemloader {
loader.toString + "/" + name

private def overrideFromFile(sourceDirectory: File, loader: ServerLoader, name: String): Option[URL] =
Option(sourceDirectory / "templates" / "systemloader" / loader.toString).filter(_.exists).map(_.toURI.toURL)
Option(sourceDirectory / "templates" / "systemloader" / loader.toString / name).filter(_.exists).map(_.toURI.toURL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this. This quite some bug. Along with 6 tests that tested the wrong implementation:

[error] (*:scripted) Failed tests:
[error] 	rpm / override-start-script-systemd
[error] 	rpm / override-start-script-systemv
[error] 	rpm / override-start-script-upstart
[error] 	debian / override-start-script-systemd
[error] 	debian / override-start-script-systemv
[error] 	debian / override-start-script-upstart

@lightbend-cla-validator
Copy link

Hi @ANorwell,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@ANorwell
Copy link
Contributor Author

ANorwell commented Feb 6, 2017

I fixed the tests, and also added two new tests for overriding loader-scripts, one for deb and one for rpm.

Copy link
Contributor

@muuki88 muuki88 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for your time and qualitative work :)


val script = IO.read(extracted / "postinst")

assert(script.contains("# right systemd template"), s"override script wasn't picked, script is\n$script")
Copy link
Contributor

Choose a reason for hiding this comment

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

This checks that the loader-functions has be correctly inserted. I think this check is enough, even though I wouldn't my checking that the wrong systemd template isn't contained in the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added such an assertion

@muuki88 muuki88 merged commit 7f2c617 into sbt:master Feb 8, 2017
@muuki88
Copy link
Contributor

muuki88 commented Feb 8, 2017

Thanks again for your time and work 😊
I'll release this ASAP

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

Successfully merging this pull request may close these issues.

3 participants