436 Commits

Author SHA1 Message Date
Scott Frederick
4f1b4c98ae Fail on Docker image load with empty response
In some cases, a call to the Docker image load API will fail but
return a 200 OK response status code and an empty response. This
commit detects that the response from this call is empty and
treats this condition as an error instead of a silent failure.

Fixes gh-23130
2020-08-28 15:18:02 -05:00
dreis2211
33cd875cb8 Simplify InputStream assertions
See gh-23052
2020-08-24 11:35:17 +02:00
Scott Frederick
ee41d71ea8 Merge branch '2.3.x'
Closes gh-23016
2020-08-19 16:12:44 -05:00
Scott Frederick
56bc0eb9e0 Use canonical path for CNB builder lifecycle binaries
This commit changes the path used to invoke lifecycle binaries in
CNB builders from `/lifecycle` to `/cnb/lifecycle` to conform to
the CNB spec. This will ensure the build plugin image-building
goals and tasks are compatible with future versions of builders
that may not support both paths.

See gh-23009
2020-08-19 16:11:59 -05:00
Scott Frederick
6b15822cb1 Polish "Add pullPolicy option for image building"
See gh-22736
2020-08-12 15:16:38 -05:00
anshlykov
c7449b57ce Add pullPolicy option for image building
This commit adds a pullPolicy option to the configuration of the Maven
plugin spring-boot:build-image goal and the Gradle plugin bootBuildImage
task. The new option gives users control over pulling the builder image
and run image from a remote image registry to the local Docker daemon.

See gh-22736
2020-08-12 15:16:38 -05:00
Andy Wilkinson
969dd35e45 Upgrade to Mockito 3.4.6
Closes gh-22838
2020-08-10 15:22:03 +01:00
Scott Frederick
f247fec310 Merge branch '2.3.x'
Closes gh-22735
2020-08-04 15:30:17 -05:00
Scott Frederick
21b2dd2740 Allow empty env entries when building an image
Prior to this commit, an entry in the environment map provided to the
build plugin image building goal or task that had a null value would
result in a failure with a message that was difficult to diagnose.

This commit treats env map entries with a null value as an empty
entry to prevent the failure and also make it easier to provide an
explicit empty entry in the Maven XML.

Fixes gh-22703
2020-08-04 15:29:29 -05:00
dreis2211
e49e2dfff1 Use Supplier variants of Assert methods
See gh-22699
2020-08-03 15:06:13 +02:00
Phillip Webb
da69286838 Merge branch '2.3.x' 2020-07-22 17:39:27 -07:00
Phillip Webb
d2a7808098 Polish 2020-07-22 17:25:04 -07:00
Scott Frederick
e6318f83b2 Merge branch '2.3.x'
Closes gh-22349
2020-07-15 15:17:16 -05:00
Scott Frederick
bc88af8e53 Restore accidentally deleted line 2020-07-15 15:14:23 -05:00
Scott Frederick
210282260e Fail on bootBuildImage with launch script
This commit adds a check to the support code for the Gradle plugin
bootBuildImage task to ensure that the jar file that will be passed
to a builder is readable and has a valid directory. This prevents a
situation where the jar file cannot be read because it is prepended
with a launch script, and the builder does not receive any files to
process.

Notes have also been added to the Gradle plugin documentation to warn
against using a bootJar launchScript configuration and bootBuildImage
together, as well as caveats about launchScript that match the Maven
plugin documentation.

Fixes gh-22223
2020-07-15 14:58:11 -05:00
Andy Wilkinson
3d2f67f0be Merge branch '2.3.x'
Closes gh-22304
2020-07-10 15:36:49 +01:00
Andy Wilkinson
f18b657ff9 Fix handling of DOCKER_HOST that begins with unix://
Fixes gh-22300
2020-07-10 15:31:55 +01:00
Andy Wilkinson
160d8e49e3 Merge branch '2.3.x'
Closes gh-22180
2020-07-01 11:44:00 +01:00
Andy Wilkinson
9317135690 Improve error handling when builder image isn't a builder
Fixes gh-22179
2020-07-01 11:42:36 +01:00
Phillip Webb
301ec12a0c Merge branch '2.3.x' 2020-06-22 22:37:25 -07:00
Phillip Webb
f296f57401 Rename ImageReferenceParser to Regex
Rename `ImageReferenceParser` to `Regex` and remove state. The regular
expressions are now used directly by the `ImageName` and
`ImageReference` classes with the values accessed directly from the
`Matcher`.

See gh-21495
2020-06-22 22:36:46 -07:00
Scott Frederick
39b2d01541 Merge branch '2.3.x'
Closes gh-22037
2020-06-19 15:43:59 -05:00
dreis2211
a6e8561391 Catch more generic FileSystemException in NamedPipeSocket
See gh-22035
2020-06-19 15:41:20 -05:00
Scott Frederick
73b737c7d8 Merge branch '2.3.x'
Closes gh-22017
2020-06-18 15:11:07 -05:00
Scott Frederick
28643e4d2d Validate image references before passing to CNB builder
Prior to this commit, an image name or run image name derived from
the project name or provided by the user would be passed to the CNB
builder without validation by the Maven plugin build-image goal or
Gradle plugin bootBuildImage task. This could lead to error messages
from the plugins that are difficult to understand and diagnose.

This commit makes parsing of the image names more strict, based on
the grammar implemented by the Docker go library. This provides
validation of the image names before passing them to the builder,
with a more descriptive error message when parsing and validation
fails.

Fixes gh-21495
2020-06-18 15:09:57 -05:00
Andy Wilkinson
07fb4b065d Merge branch '2.3.x'
Closes gh-21940
2020-06-16 10:10:38 +01:00
Andy Wilkinson
0de466e06e Require dependency on s-b-dependencies to use its constraints
Previously, Spring Boot's modules published Gradle Module Metadata
(GMM) the declared a platform dependency on spring-boot-dependencies.
This provided versions for each module's own dependencies but also had
they unwanted side-effect of pulling in spring-boot-dependencies
constraints which would influence the version of other dependencies
declared in the same configuration. This was undesirable as users
should be able to opt in to this level of dependency management, either
by using the dependency management plugin or by using Gradle's built-in
support via a platform dependency on spring-boot-dependencies.

This commit reworks how Spring Boot's build uses
spring-boot-dependencies and spring-boot-parent to provide its own
dependency management. Configurations that aren't seen by consumers are
configured to extend a dependencyManagement configuration that has an
enforced platform dependency on spring-boot-parent. This enforces
spring-boot-parent's version constraints on Spring Boot's build without
making them visible to consumers. To ensure that the versions that
Spring Boot has been built against are visible to consumers, the
Maven publication that produces pom files and GMM for the published
modules is configured to use the resolved versions from the module's
runtime classpath.

Fixes gh-21911
2020-06-16 08:50:21 +01:00
Scott Frederick
838cfc529f Merge branch '2.3.x'
Closes gh-21933
2020-06-15 16:17:39 -05:00
Scott Frederick
6119d69679 Add runImage option for image building
This commit adds a runImage property to the Maven plugin build-image
goal and the Gradle bootBuildImage task. The property allows the user
to override the run image reference provided in the builder metadata
with an alternate run image. The runImage property can be specified
in the build file or on the command line.

Fixes gh-21534
2020-06-15 16:08:56 -05:00
Phillip Webb
3892f4402a Merge branch '2.3.x'
Closes gh-21895
2020-06-11 12:32:41 -07:00
Phillip Webb
1e7da4d3ca Allow digest builder references
Update `BuildRequest` to also allow digest based references.

Closes gh-21879
2020-06-11 12:31:29 -07:00
Scott Frederick
9d9a501b17 Merge branch '2.3.x'
Closes gh-21892
2020-06-11 11:55:20 -05:00
Scott Frederick
7a2939f129 Use non-blocking I/O for Docker API
This commit changes the NamedPipeSocket used for communication with
a local Docker daemon to use a non-blocking AsynchronousByteChannel
instead of a blocking RandomAccessFile, modeled after a similar
change to the docker-java project. This eliminates the potential for
a blocking call to hang indefinitely.

Fixes gh-21672
2020-06-11 11:53:52 -05:00
Phillip Webb
5f79bd2a09 Merge branch '2.3.x'
Closes gh-21734
2020-06-06 11:08:30 -07:00
dreis2211
2b5569f054 Polish
See gh-21732
2020-06-06 11:07:21 -07:00
Scott Frederick
87f5894a9a Merge branch '2.3.x'
Closes gh-21685
2020-06-03 16:54:37 -05:00
Scott Frederick
29253264b4 Improve Docker API 5xx error messages
This commit improves the error messages returned by the Spring Boot
build plugins when a 5xx status code is returned from the Docker
API while attempting to build an image. If the error response has
contents containing a JSON structure with a "message" key, the value
associated with that key will be included in the exception message
and in the build plugin output error.

Fixes gh-21515
2020-06-03 16:53:44 -05:00
Phillip Webb
502e2a4c64 Polish 2020-06-01 14:27:39 -07:00
Scott Frederick
7722394e19 Provide better error message if Docker is not running
Previously, if the Spring Boot build plugins got a connection error
when attempting to communicate with a Docker daemon (for example,
when the daemon isn't running), the error message made it appear that
the daemon returned an HTTP error code. This commit makes a connection
error distinct from an HTTP error response code to make it easier for
the user to diagnose the root cause of the problem.

Fixes gh-21554
2020-05-29 12:37:06 -05:00
Scott Frederick
ed4a7d4ba0 Use default tag when pulling run image
Prior to this commit, a default tag of 'latest' was used when no tag
was included in the builder image name used when building an image in
the Maven and Gradle plugins, but the tag for the run image was left
empty if it was not provided. This resulted in errors when pulling
the run image from an image repository. This commit applies the
same tag defaulting logic to the run image name.

Fixes gh-21532
2020-05-21 17:28:59 -05:00
Phillip Webb
12381467da Polish 2020-05-13 16:48:51 -07:00
Scott Frederick
90ce472252 Support local socket path in DOCKER_HOST
Prior to this commit, if a DOCKER_HOST environment variable was present
when attempting to communicate with a Docker daemon, it was assumed
that the value of that variable was an address that could be used to
create an HTTP connection to a remote daemon. In some cases, the value
of the variable is the path to a local socket file, which would cause
the HTTP connection to fail.

This commit adds additional validation of the value of the DOCKER_HOST
environment variable to determine whether it is a remote address or
a local socket file and create the appropriate connection type.

Fixes gh-21173
2020-05-12 16:11:27 -05:00
Scott Frederick
35bc82a693 Use CNB creator all-in-one lifecycle
This commit modifies the buildpack platform invocation logic used by
the build plugins to invoke the single creator lifecycle introduced in
the CNB API 0.3, instead of invoking discrete lifecycle phases
separately. It also removes support for CNB API 0.2.

Fixes gh-21273
2020-05-08 17:03:47 -05:00
Scott Frederick
0cb090766f Fix typos in mock tests data 2020-04-29 18:08:34 -05:00
Scott Frederick
f3d717e97a Use paketo-buildpacks/builder as default builder
This commit changes the default builder image from
`cloudfoundry/cnb:bionic-platform-api-0.2` to
`gcr.io/paketo-buildpacks/builder:base-platform-api-0.3`. It also
uses a `paketo-buildpacks/builder` image instead of a
`cloudfoundry/cnb` image to test compatibility with lifecycle v2
and uses paketo naming instead of cloudfoundry when mocking builder
interactions.

Some adjustments to lifecycle phases were also made to align more
closely with the pack CLI.

Fixes gh-21066
2020-04-29 14:28:25 -05:00
Phillip Webb
ad1248e4ec Replace "folder" with "directory"
Consistently use the term "directory" instead of "folder"

Closes gh-21218
2020-04-28 19:20:24 -07:00
dreis2211
4b0a31acf8 Delete Toml class
See gh-21129
2020-04-28 11:01:00 +01:00
dreis2211
5eb5bf0a2d Polish
See gh-21009
2020-04-25 08:54:47 +02:00
Johnny Lim
29717423a3 Remove this keyword on member method invocations
See gh-21007
2020-04-25 08:49:44 +02:00
dreis2211
4b9986d790 Remove unused fields in tests
See gh-20926
2020-04-13 13:46:43 +02:00