This repository has been archived by the owner on May 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Prevent native packager bin-compat issues #169
Merged
eed3si9n
merged 4 commits into
lightbend:master
from
ignasi35:prevent-bin-compat-issue-from-native-packager
Jan 10, 2019
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/scala/com/lightbend/rp/sbtreactiveapp/NativePackagerCompat.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2017 Lightbend, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.lightbend.rp.sbtreactiveapp | ||
|
||
import com.typesafe.sbt.packager.docker.DockerAlias | ||
|
||
/** | ||
* `sbt-native-packager` is not SemVer compliant and classes like `DockerAlias` break binary compatibility | ||
* in patch releases. This object provides makes all 1.3.x versions of `sbt-native-packager` compatible. | ||
*/ | ||
object NativePackagerCompat { | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def untagged(dockerAlias: DockerAlias): String = | ||
dockerAlias.registryHost.map(_ + "/").getOrElse("") + | ||
dockerAlias.username.map(_ + "/").getOrElse("") + dockerAlias.name | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def versioned(dockerAlias: DockerAlias): String = { | ||
untagged(dockerAlias) + dockerAlias.tag.map(":" + _).getOrElse("") | ||
} | ||
|
||
// removed from `sbt-native-packager` (https://github.com/sbt/sbt-native-packager/pull/1138/files#diff-6aa67d5df515952c884df8bad5ff2ac4L12) | ||
def latest(dockerAlias: DockerAlias) = s"${untagged(dockerAlias)}:latest" | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ package com.lightbend.rp.sbtreactiveapp | |
import com.typesafe.sbt.packager.Keys._ | ||
import com.typesafe.sbt.packager.archetypes.scripts.BashStartScriptPlugin | ||
import com.typesafe.sbt.packager.docker | ||
import com.typesafe.sbt.packager.docker.DockerKeys | ||
import sbt.{ Def, _ } | ||
import sbt.Keys._ | ||
import sbt.plugins.JvmPlugin | ||
|
@@ -92,7 +93,7 @@ object SbtReactiveAppPlugin extends AutoPlugin { | |
} | ||
} | ||
|
||
object localImport extends docker.DockerKeys | ||
val localImport: DockerKeys = docker.DockerPlugin.autoImport | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the original change. The breaking changes in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
override def requires = SbtReactiveAppPluginAll && docker.DockerPlugin && BashStartScriptPlugin && SbtReactiveAppPluginAll | ||
|
||
|
11 changes: 11 additions & 0 deletions
11
src/sbt-test/sbt-reactive-app/native-packager-cross-version-compat/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name := "hello" | ||
scalaVersion := "2.11.12" | ||
|
||
lazy val root = (project in file(".")) | ||
.enablePlugins(SbtReactiveAppPlugin) | ||
.settings( | ||
packageName in Docker := "hello-play", | ||
httpIngressPorts := Seq(9000), | ||
httpIngressPaths := Seq("/") | ||
) | ||
|
7 changes: 7 additions & 0 deletions
7
src/sbt-test/sbt-reactive-app/native-packager-cross-version-compat/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
sys.props.get("plugin.version") match { | ||
case Some(x) => addSbtPlugin("com.lightbend.rp" % "sbt-reactive-app" % x) | ||
case _ => sys.error("""|The system property 'plugin.version' is not defined. | ||
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin) | ||
} | ||
|
||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.15") |
3 changes: 3 additions & 0 deletions
3
src/sbt-test/sbt-reactive-app/native-packager-cross-version-compat/src/main/scala/Main.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object Main extends App { | ||
println("hello") | ||
} |
7 changes: 7 additions & 0 deletions
7
src/sbt-test/sbt-reactive-app/native-packager-cross-version-compat/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This test only checks `sbt` starts successfully into a shell. | ||
# Since Play 2.6.21 there's a dependency issue between Play's sbt-plugin and sbt-reactive-app where both bring in | ||
# incompatible versions of `sbt-native-packager`. Users adding both `sbt-reactive-app` and a direct or transitive | ||
# dependency to an incompatible version of `sbt-native-packager` would be DoS-ing themselves. | ||
# Just starting `sbt` is enough to assert the fixes for compat work. | ||
|
||
> about |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main change in the PR. There's no automated test for it, unfortunately. The issue manifests when running
deploy minikube
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the part that sbt-native-packager participate in
deploy minikube
is just image creation, can we reproduce this by callingDocker/stage
from the scripted test?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually you probably need
Docker/publish
to exercise alias.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good call. We can add that on a separate PR