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

add cnb in LifecycleType #1244

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
import java.nio.charset.Charset;
import java.time.Duration;
import java.util.Collections;
import org.cloudfoundry.client.v3.BuildpackData;
import org.cloudfoundry.client.v3.Checksum;
import org.cloudfoundry.client.v3.ChecksumType;
import org.cloudfoundry.client.v3.KpackData;
import org.cloudfoundry.client.v3.Lifecycle;
import org.cloudfoundry.client.v3.LifecycleType;
import org.cloudfoundry.client.v3.Link;
import org.cloudfoundry.client.v3.Pagination;
import org.cloudfoundry.client.v3.Relationship;
import org.cloudfoundry.client.v3.ToOneRelationship;
import org.cloudfoundry.client.v3.*;
import org.cloudfoundry.client.v3.droplets.Buildpack;
import org.cloudfoundry.client.v3.droplets.DropletResource;
import org.cloudfoundry.client.v3.droplets.DropletState;
Expand Down Expand Up @@ -497,7 +488,7 @@ void listDroplets() {
ListPackageDropletsResponse.builder()
.pagination(
Pagination.builder()
.totalResults(3)
.totalResults(4)
.totalPages(1)
.first(
Link.builder()
Expand Down Expand Up @@ -627,6 +618,61 @@ void listDroplets() {
.method("PATCH")
.build())
.build())
.resource(
DropletResource.builder()
.id("e351a2f2-dfc6-454b-8777-60ed2ff98edb")
.state(DropletState.STAGED)
.error(null)
.lifecycle(
Lifecycle.builder()
.type(LifecycleType.CNB)
.data(CnbData.builder().build())
.build())
.image(null)
.executionMetadata("PRIVATE DATA HIDDEN")
.processType(
"redacted_message",
"[PRIVATE DATA HIDDEN IN LISTS]")
.checksum(
Checksum.builder()
.type(ChecksumType.SHA256)
.value(
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
.build())
.buildpack(
Buildpack.builder()
.name("ruby_buildpack")
.detectOutput("ruby 1.6.14")
.build())
.stack("cflinuxfs2")
.createdAt("2016-03-28T23:39:34Z")
.updatedAt("2016-03-28T23:39:47Z")
.link(
"self",
Link.builder()
.href(
"https://api.example.org/v3/droplets/e351a2f2-dfc6-454b-8777-60ed2ff98edb")
.build())
.link(
"package",
Link.builder()
.href(
"https://api.example.org/v3/packages/45c63fe0-f5f4-4f23-963e-a8311193d11e")
.build())
.link(
"app",
Link.builder()
.href(
"https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398")
.build())
.link(
"assign_current_droplet",
Link.builder()
.href(
"https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398/relationships/current_droplet")
.method("PATCH")
.build())
.build())
.resource(
DropletResource.builder()
.id("fdf3851c-def8-4de1-87f1-6d4543189e22")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pagination": {
"total_results": 3,
"total_results": 4,
"total_pages": 1,
"first": {
"href": "https://api.example.org/v3/packages/7b34f1cf-7e73-428a-bb5a-8a17a8058396/droplets?page=1&per_page=50"
Expand Down Expand Up @@ -98,6 +98,48 @@
}
}
},
{
"guid": "e351a2f2-dfc6-454b-8777-60ed2ff98edb",
"state": "STAGED",
"error": null,
"lifecycle": {
"type": "cnb",
"data": {}
},
"image": null,
"execution_metadata": "PRIVATE DATA HIDDEN",
"process_types": {
"redacted_message": "[PRIVATE DATA HIDDEN IN LISTS]"
},
"checksum": {
"type": "sha256",
"value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
},
"buildpacks": [
{
"name": "ruby_buildpack",
"detect_output": "ruby 1.6.14"
}
],
"stack": "cflinuxfs2",
"created_at": "2016-03-28T23:39:34Z",
"updated_at": "2016-03-28T23:39:47Z",
"links": {
"self": {
"href": "https://api.example.org/v3/droplets/e351a2f2-dfc6-454b-8777-60ed2ff98edb"
},
"package": {
"href": "https://api.example.org/v3/packages/45c63fe0-f5f4-4f23-963e-a8311193d11e"
},
"app": {
"href": "https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398"
},
"assign_current_droplet": {
"href": "https://api.example.org/v3/apps/7b34f1cf-7e73-428a-bb5a-8a17a8058398/relationships/current_droplet",
"method": "PATCH"
}
}
},
{
"guid": "fdf3851c-def8-4de1-87f1-6d4543189e22",
"state": "STAGED",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public enum LifecycleType {

DOCKER("docker"),

KPACK("kpack");
KPACK("kpack"),

CNB("cnb");

private final String value;

Expand All @@ -41,6 +43,8 @@ public static LifecycleType from(String s) {
return DOCKER;
case "kpack":
return KPACK;
case "cnb":
return CNB;
default:
throw new IllegalArgumentException(String.format("Unknown lifecycle type: %s", s));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2013-2021 the original author or authors.
*
* 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 org.cloudfoundry.client.v3;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.cloudfoundry.Nullable;
import org.immutables.value.Value;

import java.util.List;

/**
* Data type for the Buildpack
*/
@JsonDeserialize
@Value.Immutable
abstract class _CnbData implements LifecycleData {

/**
* The buildpack
*/
@JsonProperty("buildpacks")
@Nullable
abstract List<String> getBuildpacks();

/**
* The stack
*/
@JsonProperty("stack")
@Nullable
abstract String getStack();

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ abstract class _Lifecycle {
@JsonSubTypes({
@JsonSubTypes.Type(name = "buildpack", value = BuildpackData.class),
@JsonSubTypes.Type(name = "docker", value = DockerData.class),
@JsonSubTypes.Type(name = "kpack", value = KpackData.class)
@JsonSubTypes.Type(name = "kpack", value = KpackData.class),
@JsonSubTypes.Type(name = "cnb", value = CnbData.class)
})
@JsonProperty("data")
abstract LifecycleData getData();
Expand Down
Loading