Skip to content

Commit dd6fbf3

Browse files
Merge pull request #1244 from s-yonkov-yonkov/add-cnb
add cnb in LifecycleType
2 parents 0e3d9ab + f4e48ad commit dd6fbf3

File tree

5 files changed

+154
-14
lines changed

5 files changed

+154
-14
lines changed

cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/packages/ReactorPackagesTest.java

+57-11
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,7 @@
2929
import java.nio.charset.Charset;
3030
import java.time.Duration;
3131
import java.util.Collections;
32-
import org.cloudfoundry.client.v3.BuildpackData;
33-
import org.cloudfoundry.client.v3.Checksum;
34-
import org.cloudfoundry.client.v3.ChecksumType;
35-
import org.cloudfoundry.client.v3.KpackData;
36-
import org.cloudfoundry.client.v3.Lifecycle;
37-
import org.cloudfoundry.client.v3.LifecycleType;
38-
import org.cloudfoundry.client.v3.Link;
39-
import org.cloudfoundry.client.v3.Pagination;
40-
import org.cloudfoundry.client.v3.Relationship;
41-
import org.cloudfoundry.client.v3.ToOneRelationship;
32+
import org.cloudfoundry.client.v3.*;
4233
import org.cloudfoundry.client.v3.droplets.Buildpack;
4334
import org.cloudfoundry.client.v3.droplets.DropletResource;
4435
import org.cloudfoundry.client.v3.droplets.DropletState;
@@ -497,7 +488,7 @@ void listDroplets() {
497488
ListPackageDropletsResponse.builder()
498489
.pagination(
499490
Pagination.builder()
500-
.totalResults(3)
491+
.totalResults(4)
501492
.totalPages(1)
502493
.first(
503494
Link.builder()
@@ -627,6 +618,61 @@ void listDroplets() {
627618
.method("PATCH")
628619
.build())
629620
.build())
621+
.resource(
622+
DropletResource.builder()
623+
.id("e351a2f2-dfc6-454b-8777-60ed2ff98edb")
624+
.state(DropletState.STAGED)
625+
.error(null)
626+
.lifecycle(
627+
Lifecycle.builder()
628+
.type(LifecycleType.CNB)
629+
.data(CnbData.builder().build())
630+
.build())
631+
.image(null)
632+
.executionMetadata("PRIVATE DATA HIDDEN")
633+
.processType(
634+
"redacted_message",
635+
"[PRIVATE DATA HIDDEN IN LISTS]")
636+
.checksum(
637+
Checksum.builder()
638+
.type(ChecksumType.SHA256)
639+
.value(
640+
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
641+
.build())
642+
.buildpack(
643+
Buildpack.builder()
644+
.name("ruby_buildpack")
645+
.detectOutput("ruby 1.6.14")
646+
.build())
647+
.stack("cflinuxfs2")
648+
.createdAt("2016-03-28T23:39:34Z")
649+
.updatedAt("2016-03-28T23:39:47Z")
650+
.link(
651+
"self",
652+
Link.builder()
653+
.href(
654+
"https://api.example.org/v3/droplets/e351a2f2-dfc6-454b-8777-60ed2ff98edb")
655+
.build())
656+
.link(
657+
"package",
658+
Link.builder()
659+
.href(
660+
"https://api.example.org/v3/packages/45c63fe0-f5f4-4f23-963e-a8311193d11e")
661+
.build())
662+
.link(
663+
"app",
664+
Link.builder()
665+
.href(
666+
"https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398")
667+
.build())
668+
.link(
669+
"assign_current_droplet",
670+
Link.builder()
671+
.href(
672+
"https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398/relationships/current_droplet")
673+
.method("PATCH")
674+
.build())
675+
.build())
630676
.resource(
631677
DropletResource.builder()
632678
.id("fdf3851c-def8-4de1-87f1-6d4543189e22")

cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/packages/GET_{id}_droplets_response.json

+43-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pagination": {
3-
"total_results": 3,
3+
"total_results": 4,
44
"total_pages": 1,
55
"first": {
66
"href": "https://api.example.org/v3/packages/7b34f1cf-7e73-428a-bb5a-8a17a8058396/droplets?page=1&per_page=50"
@@ -98,6 +98,48 @@
9898
}
9999
}
100100
},
101+
{
102+
"guid": "e351a2f2-dfc6-454b-8777-60ed2ff98edb",
103+
"state": "STAGED",
104+
"error": null,
105+
"lifecycle": {
106+
"type": "cnb",
107+
"data": {}
108+
},
109+
"image": null,
110+
"execution_metadata": "PRIVATE DATA HIDDEN",
111+
"process_types": {
112+
"redacted_message": "[PRIVATE DATA HIDDEN IN LISTS]"
113+
},
114+
"checksum": {
115+
"type": "sha256",
116+
"value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
117+
},
118+
"buildpacks": [
119+
{
120+
"name": "ruby_buildpack",
121+
"detect_output": "ruby 1.6.14"
122+
}
123+
],
124+
"stack": "cflinuxfs2",
125+
"created_at": "2016-03-28T23:39:34Z",
126+
"updated_at": "2016-03-28T23:39:47Z",
127+
"links": {
128+
"self": {
129+
"href": "https://api.example.org/v3/droplets/e351a2f2-dfc6-454b-8777-60ed2ff98edb"
130+
},
131+
"package": {
132+
"href": "https://api.example.org/v3/packages/45c63fe0-f5f4-4f23-963e-a8311193d11e"
133+
},
134+
"app": {
135+
"href": "https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398"
136+
},
137+
"assign_current_droplet": {
138+
"href": "https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398/relationships/current_droplet",
139+
"method": "PATCH"
140+
}
141+
}
142+
},
101143
{
102144
"guid": "fdf3851c-def8-4de1-87f1-6d4543189e22",
103145
"state": "STAGED",

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/LifecycleType.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ public enum LifecycleType {
2424

2525
DOCKER("docker"),
2626

27-
KPACK("kpack");
27+
KPACK("kpack"),
28+
29+
CNB("cnb");
2830

2931
private final String value;
3032

@@ -41,6 +43,8 @@ public static LifecycleType from(String s) {
4143
return DOCKER;
4244
case "kpack":
4345
return KPACK;
46+
case "cnb":
47+
return CNB;
4448
default:
4549
throw new IllegalArgumentException(String.format("Unknown lifecycle type: %s", s));
4650
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2013-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.cloudfoundry.client.v3;
18+
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
21+
import org.cloudfoundry.Nullable;
22+
import org.immutables.value.Value;
23+
24+
import java.util.List;
25+
26+
/**
27+
* Data type for the Buildpack
28+
*/
29+
@JsonDeserialize
30+
@Value.Immutable
31+
abstract class _CnbData implements LifecycleData {
32+
33+
/**
34+
* The buildpack
35+
*/
36+
@JsonProperty("buildpacks")
37+
@Nullable
38+
abstract List<String> getBuildpacks();
39+
40+
/**
41+
* The stack
42+
*/
43+
@JsonProperty("stack")
44+
@Nullable
45+
abstract String getStack();
46+
47+
}

cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/_Lifecycle.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ abstract class _Lifecycle {
3636
@JsonSubTypes({
3737
@JsonSubTypes.Type(name = "buildpack", value = BuildpackData.class),
3838
@JsonSubTypes.Type(name = "docker", value = DockerData.class),
39-
@JsonSubTypes.Type(name = "kpack", value = KpackData.class)
39+
@JsonSubTypes.Type(name = "kpack", value = KpackData.class),
40+
@JsonSubTypes.Type(name = "cnb", value = CnbData.class)
4041
})
4142
@JsonProperty("data")
4243
abstract LifecycleData getData();

0 commit comments

Comments
 (0)