Skip to content

Commit

Permalink
feat(tekton): add run description for pipeline runs
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Gleeson <brian.gleeson@ie.ibm.com>
  • Loading branch information
briangleeson committed Sep 24, 2024
1 parent dce530a commit 73524e3
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ public ServiceCall<PipelineRun> createTektonPipelineRun(CreateTektonPipelineRunO
}
builder.header("Accept", "application/json");
final JsonObject contentJson = new JsonObject();
if (createTektonPipelineRunOptions.description() != null) {
contentJson.addProperty("description", createTektonPipelineRunOptions.description());
}
if (createTektonPipelineRunOptions.triggerName() != null) {
contentJson.addProperty("trigger_name", createTektonPipelineRunOptions.triggerName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
public class CreateTektonPipelineRunOptions extends GenericModel {

protected String pipelineId;
protected String description;
protected String triggerName;
protected Map<String, Object> triggerProperties;
protected Map<String, Object> secureTriggerProperties;
Expand All @@ -34,6 +35,7 @@ public class CreateTektonPipelineRunOptions extends GenericModel {
*/
public static class Builder {
private String pipelineId;
private String description;
private String triggerName;
private Map<String, Object> triggerProperties;
private Map<String, Object> secureTriggerProperties;
Expand All @@ -48,6 +50,7 @@ public static class Builder {
*/
private Builder(CreateTektonPipelineRunOptions createTektonPipelineRunOptions) {
this.pipelineId = createTektonPipelineRunOptions.pipelineId;
this.description = createTektonPipelineRunOptions.description;
this.triggerName = createTektonPipelineRunOptions.triggerName;
this.triggerProperties = createTektonPipelineRunOptions.triggerProperties;
this.secureTriggerProperties = createTektonPipelineRunOptions.secureTriggerProperties;
Expand Down Expand Up @@ -91,6 +94,17 @@ public Builder pipelineId(String pipelineId) {
return this;
}

/**
* Set the description.
*
* @param description the description
* @return the CreateTektonPipelineRunOptions builder
*/
public Builder description(String description) {
this.description = description;
return this;
}

/**
* Set the triggerName.
*
Expand Down Expand Up @@ -164,6 +178,7 @@ protected CreateTektonPipelineRunOptions(Builder builder) {
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.pipelineId,
"pipelineId cannot be empty");
pipelineId = builder.pipelineId;
description = builder.description;
triggerName = builder.triggerName;
triggerProperties = builder.triggerProperties;
secureTriggerProperties = builder.secureTriggerProperties;
Expand Down Expand Up @@ -192,6 +207,17 @@ public String pipelineId() {
return pipelineId;
}

/**
* Gets the description.
*
* Optional description for the created PipelineRun.
*
* @return the description
*/
public String description() {
return description;
}

/**
* Gets the triggerName.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* 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 com.ibm.cloud.continuous_delivery.cd_tekton_pipeline.v2.model;

import com.ibm.cloud.sdk.core.service.model.GenericModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* 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 com.ibm.cloud.continuous_delivery.cd_tekton_pipeline.v2.model;

import java.util.Date;
Expand Down Expand Up @@ -54,6 +53,7 @@ public interface Status {
@SerializedName("definition_id")
protected String definitionId;
protected RunDefinition definition;
protected Object description;
protected PipelineRunWorker worker;
@SerializedName("pipeline_id")
protected String pipelineId;
Expand Down Expand Up @@ -145,6 +145,17 @@ public RunDefinition getDefinition() {
return definition;
}

/**
* Gets the description.
*
* A description of the PipelineRun.
*
* @return the description
*/
public Object getDescription() {
return description;
}

/**
* Gets the worker.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* 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 com.ibm.cloud.continuous_delivery.cd_tekton_pipeline.v2.model;

import java.util.List;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2023.
* (C) Copyright IBM Corp. 2024.
*
* 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
Expand Down Expand Up @@ -47,6 +47,7 @@ public void testCreateTektonPipelineRunOptions() throws Throwable {

CreateTektonPipelineRunOptions createTektonPipelineRunOptionsModel = new CreateTektonPipelineRunOptions.Builder()
.pipelineId("94619026-912b-4d92-8f51-6c74f0692d90")
.description("testString")
.triggerName("start-deploy")
.triggerProperties(java.util.Collections.singletonMap("anyKey", "anyValue"))
.secureTriggerProperties(java.util.Collections.singletonMap("anyKey", "anyValue"))
Expand All @@ -55,6 +56,7 @@ public void testCreateTektonPipelineRunOptions() throws Throwable {
.trigger(pipelineRunTriggerModel)
.build();
assertEquals(createTektonPipelineRunOptionsModel.pipelineId(), "94619026-912b-4d92-8f51-6c74f0692d90");
assertEquals(createTektonPipelineRunOptionsModel.description(), "testString");
assertEquals(createTektonPipelineRunOptionsModel.triggerName(), "start-deploy");
assertEquals(createTektonPipelineRunOptionsModel.triggerProperties(), java.util.Collections.singletonMap("anyKey", "anyValue"));
assertEquals(createTektonPipelineRunOptionsModel.secureTriggerProperties(), java.util.Collections.singletonMap("anyKey", "anyValue"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2023.
* (C) Copyright IBM Corp. 2024.
*
* 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
Expand Down Expand Up @@ -46,6 +46,7 @@ public void testPipelineRun() throws Throwable {
assertNull(pipelineRunModel.getStatus());
assertNull(pipelineRunModel.getDefinitionId());
assertNull(pipelineRunModel.getDefinition());
assertNull(pipelineRunModel.getDescription());
assertNull(pipelineRunModel.getWorker());
assertNull(pipelineRunModel.getPipelineId());
assertNull(pipelineRunModel.getPipeline());
Expand Down

0 comments on commit 73524e3

Please sign in to comment.