Polish
This commit is contained in:
parent
bb38ee38a6
commit
685b045c3d
|
@ -211,6 +211,7 @@ public class BuildRequest {
|
|||
* Return a new {@link BuildRequest} with an updated buildpacks setting.
|
||||
* @param buildpacks a collection of buildpacks to use when building the image
|
||||
* @return an updated build request
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public BuildRequest withBuildpacks(BuildpackReference... buildpacks) {
|
||||
Assert.notEmpty(buildpacks, "Buildpacks must not be empty");
|
||||
|
@ -221,6 +222,7 @@ public class BuildRequest {
|
|||
* Return a new {@link BuildRequest} with an updated buildpacks setting.
|
||||
* @param buildpacks a collection of buildpacks to use when building the image
|
||||
* @return an updated build request
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public BuildRequest withBuildpacks(List<BuildpackReference> buildpacks) {
|
||||
Assert.notNull(buildpacks, "Buildpacks must not be null");
|
||||
|
@ -232,6 +234,7 @@ public class BuildRequest {
|
|||
* Return a new {@link BuildRequest} with updated bindings.
|
||||
* @param bindings a collection of bindings to mount to the build container
|
||||
* @return an updated build request
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public BuildRequest withBindings(Binding... bindings) {
|
||||
Assert.notEmpty(bindings, "Bindings must not be empty");
|
||||
|
@ -242,6 +245,7 @@ public class BuildRequest {
|
|||
* Return a new {@link BuildRequest} with updated bindings.
|
||||
* @param bindings a collection of bindings to mount to the build container
|
||||
* @return an updated build request
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public BuildRequest withBindings(List<Binding> bindings) {
|
||||
Assert.notNull(bindings, "Bindings must not be null");
|
||||
|
@ -343,6 +347,7 @@ public class BuildRequest {
|
|||
/**
|
||||
* Return the collection of bindings to mount to the build container.
|
||||
* @return the bindings
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public List<Binding> getBindings() {
|
||||
return this.bindings;
|
||||
|
|
|
@ -34,7 +34,25 @@ public final class Binding {
|
|||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Binding)) {
|
||||
return false;
|
||||
}
|
||||
Binding binding = (Binding) obj;
|
||||
return Objects.equals(this.value, binding.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
|
@ -72,26 +90,4 @@ public final class Binding {
|
|||
return new Binding(source + ":" + destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Binding)) {
|
||||
return false;
|
||||
}
|
||||
Binding binding = (Binding) obj;
|
||||
return Objects.equals(this.value, binding.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ContainerConfig {
|
|||
labels.forEach(labelsNode::put);
|
||||
ObjectNode hostConfigNode = node.putObject("HostConfig");
|
||||
ArrayNode bindsNode = hostConfigNode.putArray("Binds");
|
||||
bindings.forEach((binding) -> bindsNode.add(binding.getValue()));
|
||||
bindings.forEach((binding) -> bindsNode.add(binding.toString()));
|
||||
this.json = objectMapper.writeValueAsString(node);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class BindingTests {
|
|||
@Test
|
||||
void ofReturnsValue() {
|
||||
Binding binding = Binding.of("host-src:container-dest:ro");
|
||||
assertThat(binding.getValue()).isEqualTo("host-src:container-dest:ro");
|
||||
assertThat(binding).hasToString("host-src:container-dest:ro");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -43,7 +43,7 @@ class BindingTests {
|
|||
@Test
|
||||
void fromReturnsValue() {
|
||||
Binding binding = Binding.from("host-src", "container-dest");
|
||||
assertThat(binding.getValue()).isEqualTo("host-src:container-dest");
|
||||
assertThat(binding).hasToString("host-src:container-dest");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -61,7 +61,7 @@ class BindingTests {
|
|||
@Test
|
||||
void fromVolumeNameSourceReturnsValue() {
|
||||
Binding binding = Binding.from(VolumeName.of("host-src"), "container-dest");
|
||||
assertThat(binding.getValue()).isEqualTo("host-src:container-dest");
|
||||
assertThat(binding).hasToString("host-src:container-dest");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.springframework.boot.buildpack.platform.docker.type.ImageName;
|
|||
import org.springframework.boot.buildpack.platform.docker.type.ImageReference;
|
||||
import org.springframework.boot.buildpack.platform.io.Owner;
|
||||
import org.springframework.boot.buildpack.platform.io.TarArchive;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
@ -182,11 +183,11 @@ public class Image {
|
|||
if (this.publish != null) {
|
||||
request = request.withPublish(this.publish);
|
||||
}
|
||||
if (this.buildpacks != null && !this.buildpacks.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(this.buildpacks)) {
|
||||
request = request
|
||||
.withBuildpacks(this.buildpacks.stream().map(BuildpackReference::of).collect(Collectors.toList()));
|
||||
}
|
||||
if (this.bindings != null && !this.bindings.isEmpty()) {
|
||||
if (!CollectionUtils.isEmpty(this.bindings)) {
|
||||
request = request.withBindings(this.bindings.stream().map(Binding::of).collect(Collectors.toList()));
|
||||
}
|
||||
return request;
|
||||
|
|
Loading…
Reference in New Issue