Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

feat: add dynamic_substitutions to BuildOptions, STACKDRIVER_ONLY/CLOUD_LOGGING_ONLY to LoggingMode, name/service_account to Build #246

Merged
merged 5 commits into from Sep 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -17,7 +17,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>9.1.0</version>
<version>10.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -38,7 +38,7 @@ If you are using Maven without BOM, add this to your dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-build</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>

```
Expand Down
Expand Up @@ -289,6 +289,7 @@ protected GrpcCloudBuildStub(
public Map<String, String> extract(ListBuildsRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("project_id", String.valueOf(request.getProjectId()));
params.put("parent", String.valueOf(request.getParent()));
return params.build();
}
})
Expand All @@ -306,21 +307,49 @@ public Map<String, String> extract(ListBuildsRequest request) {
public Map<String, String> extract(CreateBuildRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("project_id", String.valueOf(request.getProjectId()));
params.put("parent", String.valueOf(request.getParent()));
return params.build();
}
})
.build();
GrpcCallSettings<GetBuildRequest, Build> getBuildTransportSettings =
GrpcCallSettings.<GetBuildRequest, Build>newBuilder()
.setMethodDescriptor(getBuildMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<GetBuildRequest>() {
@Override
public Map<String, String> extract(GetBuildRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<CancelBuildRequest, Build> cancelBuildTransportSettings =
GrpcCallSettings.<CancelBuildRequest, Build>newBuilder()
.setMethodDescriptor(cancelBuildMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<CancelBuildRequest>() {
@Override
public Map<String, String> extract(CancelBuildRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<RetryBuildRequest, Operation> retryBuildTransportSettings =
GrpcCallSettings.<RetryBuildRequest, Operation>newBuilder()
.setMethodDescriptor(retryBuildMethodDescriptor)
.setParamsExtractor(
new RequestParamsExtractor<RetryBuildRequest>() {
@Override
public Map<String, String> extract(RetryBuildRequest request) {
ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
params.put("name", String.valueOf(request.getName()));
return params.build();
}
})
.build();
GrpcCallSettings<CreateBuildTriggerRequest, BuildTrigger> createBuildTriggerTransportSettings =
GrpcCallSettings.<CreateBuildTriggerRequest, BuildTrigger>newBuilder()
Expand Down
Expand Up @@ -27,7 +27,9 @@
import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.api.gax.rpc.StatusCode;
import com.google.cloudbuild.v1.Build;
import com.google.cloudbuild.v1.BuildName;
import com.google.cloudbuild.v1.BuildTrigger;
import com.google.cloudbuild.v1.BuildTriggerName;
import com.google.cloudbuild.v1.CancelBuildRequest;
import com.google.cloudbuild.v1.CreateBuildRequest;
import com.google.cloudbuild.v1.CreateBuildTriggerRequest;
Expand All @@ -46,6 +48,7 @@
import com.google.cloudbuild.v1.RepoSource;
import com.google.cloudbuild.v1.RetryBuildRequest;
import com.google.cloudbuild.v1.RunBuildTriggerRequest;
import com.google.cloudbuild.v1.ServiceAccountName;
import com.google.cloudbuild.v1.UpdateBuildTriggerRequest;
import com.google.cloudbuild.v1.UpdateWorkerPoolRequest;
import com.google.cloudbuild.v1.WorkerPool;
Expand Down Expand Up @@ -200,20 +203,24 @@ public void deleteBuildTriggerExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void createBuildTest() throws Exception {
BuildName name = BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]");
String id = "id3355";
String projectId2 = "projectId2939242356";
String statusDetail = "statusDetail2089931070";
String logsBucket = "logsBucket1565363834";
String buildTriggerId = "buildTriggerId1105559411";
String logUrl = "logUrl342054388";
ServiceAccountName serviceAccount = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
Build expectedResponse =
Build.newBuilder()
.setName(name.toString())
.setId(id)
.setProjectId(projectId2)
.setStatusDetail(statusDetail)
.setLogsBucket(logsBucket)
.setBuildTriggerId(buildTriggerId)
.setLogUrl(logUrl)
.setServiceAccount(serviceAccount.toString())
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -263,20 +270,24 @@ public void createBuildExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void getBuildTest() {
BuildName name = BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]");
String id2 = "id23227150";
String projectId2 = "projectId2939242356";
String statusDetail = "statusDetail2089931070";
String logsBucket = "logsBucket1565363834";
String buildTriggerId = "buildTriggerId1105559411";
String logUrl = "logUrl342054388";
ServiceAccountName serviceAccount = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
Build expectedResponse =
Build.newBuilder()
.setName(name.toString())
.setId(id2)
.setProjectId(projectId2)
.setStatusDetail(statusDetail)
.setLogsBucket(logsBucket)
.setBuildTriggerId(buildTriggerId)
.setLogUrl(logUrl)
.setServiceAccount(serviceAccount.toString())
.build();
mockCloudBuild.addResponse(expectedResponse);

Expand Down Expand Up @@ -318,20 +329,24 @@ public void getBuildExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void cancelBuildTest() {
BuildName name = BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]");
String id2 = "id23227150";
String projectId2 = "projectId2939242356";
String statusDetail = "statusDetail2089931070";
String logsBucket = "logsBucket1565363834";
String buildTriggerId = "buildTriggerId1105559411";
String logUrl = "logUrl342054388";
ServiceAccountName serviceAccount = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
Build expectedResponse =
Build.newBuilder()
.setName(name.toString())
.setId(id2)
.setProjectId(projectId2)
.setStatusDetail(statusDetail)
.setLogsBucket(logsBucket)
.setBuildTriggerId(buildTriggerId)
.setLogUrl(logUrl)
.setServiceAccount(serviceAccount.toString())
.build();
mockCloudBuild.addResponse(expectedResponse);

Expand Down Expand Up @@ -373,20 +388,24 @@ public void cancelBuildExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void retryBuildTest() throws Exception {
BuildName name = BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]");
String id2 = "id23227150";
String projectId2 = "projectId2939242356";
String statusDetail = "statusDetail2089931070";
String logsBucket = "logsBucket1565363834";
String buildTriggerId = "buildTriggerId1105559411";
String logUrl = "logUrl342054388";
ServiceAccountName serviceAccount = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
Build expectedResponse =
Build.newBuilder()
.setName(name.toString())
.setId(id2)
.setProjectId(projectId2)
.setStatusDetail(statusDetail)
.setLogsBucket(logsBucket)
.setBuildTriggerId(buildTriggerId)
.setLogUrl(logUrl)
.setServiceAccount(serviceAccount.toString())
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down Expand Up @@ -438,14 +457,14 @@ public void retryBuildExceptionTest() throws Exception {
public void createBuildTriggerTest() {
String id = "id3355";
String description = "description-1724546052";
String name = "name3373707";
BuildTriggerName name = BuildTriggerName.of("[PROJECT]", "[TRIGGER]");
String filename = "filename-734768633";
boolean disabled = true;
BuildTrigger expectedResponse =
BuildTrigger.newBuilder()
.setId(id)
.setDescription(description)
.setName(name)
.setName(name.toString())
.setFilename(filename)
.setDisabled(disabled)
.build();
Expand Down Expand Up @@ -491,14 +510,14 @@ public void createBuildTriggerExceptionTest() throws Exception {
public void getBuildTriggerTest() {
String id = "id3355";
String description = "description-1724546052";
String name = "name3373707";
BuildTriggerName name = BuildTriggerName.of("[PROJECT]", "[TRIGGER]");
String filename = "filename-734768633";
boolean disabled = true;
BuildTrigger expectedResponse =
BuildTrigger.newBuilder()
.setId(id)
.setDescription(description)
.setName(name)
.setName(name.toString())
.setFilename(filename)
.setDisabled(disabled)
.build();
Expand Down Expand Up @@ -592,14 +611,14 @@ public void listBuildTriggersExceptionTest() throws Exception {
public void updateBuildTriggerTest() {
String id = "id3355";
String description = "description-1724546052";
String name = "name3373707";
BuildTriggerName name = BuildTriggerName.of("[PROJECT]", "[TRIGGER]");
String filename = "filename-734768633";
boolean disabled = true;
BuildTrigger expectedResponse =
BuildTrigger.newBuilder()
.setId(id)
.setDescription(description)
.setName(name)
.setName(name.toString())
.setFilename(filename)
.setDisabled(disabled)
.build();
Expand Down Expand Up @@ -646,20 +665,24 @@ public void updateBuildTriggerExceptionTest() throws Exception {
@Test
@SuppressWarnings("all")
public void runBuildTriggerTest() throws Exception {
BuildName name = BuildName.ofProjectBuildName("[PROJECT]", "[BUILD]");
String id = "id3355";
String projectId2 = "projectId2939242356";
String statusDetail = "statusDetail2089931070";
String logsBucket = "logsBucket1565363834";
String buildTriggerId = "buildTriggerId1105559411";
String logUrl = "logUrl342054388";
ServiceAccountName serviceAccount = ServiceAccountName.of("[PROJECT]", "[SERVICE_ACCOUNT]");
Build expectedResponse =
Build.newBuilder()
.setName(name.toString())
.setId(id)
.setProjectId(projectId2)
.setStatusDetail(statusDetail)
.setLogsBucket(logsBucket)
.setBuildTriggerId(buildTriggerId)
.setLogUrl(logUrl)
.setServiceAccount(serviceAccount.toString())
.build();
Operation resultOperation =
Operation.newBuilder()
Expand Down
8 changes: 8 additions & 0 deletions proto-google-cloud-build-v1/pom.xml
Expand Up @@ -21,6 +21,14 @@
<groupId>com.google.api.grpc</groupId>
<artifactId>proto-google-common-protos</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>
</dependencies>

<build>
Expand Down