Skip to content

Commit

Permalink
Rename PipelineResourceResult to RunResult
Browse files Browse the repository at this point in the history
This commit renames PipelineResourceResult Golang struct to PipelineInternalResult. No functional changes.
  • Loading branch information
JeromeJu committed Apr 4, 2023
1 parent ecb11fc commit 758b16a
Show file tree
Hide file tree
Showing 30 changed files with 309 additions and 307 deletions.
143 changes: 71 additions & 72 deletions docs/pipeline-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3298,7 +3298,7 @@ string
<p>ResultsType indicates the type of a result;
Used to distinguish between a single string and an array of strings.
Note that there is ResultType used to find out whether a
PipelineResourceResult is from a task result or not, which is different from
RunResult is from a task result or not, which is different from
this ResultsType.</p>
</div>
<table>
Expand Down Expand Up @@ -9795,72 +9795,6 @@ string
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.PipelineResourceResult">PipelineResourceResult
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.TaskRunStatusFields">TaskRunStatusFields</a>)
</p>
<div>
<p>PipelineResourceResult is used to write key/value pairs to TaskRun pod termination messages.
The key/value pairs may come from the entrypoint binary, or represent a TaskRunResult.
If they represent a TaskRunResult, the key is the name of the result and the value is the
JSON-serialized value of the result.
TODO(#6197): Rename this struct</p>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>key</code><br/>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>value</code><br/>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>resourceName</code><br/>
<em>
string
</em>
</td>
<td>
<p>ResourceName may be used in tests, but it is not populated in termination messages.
It is preserved here for backwards compatibility and will not be ported to v1.</p>
</td>
</tr>
<tr>
<td>
<code>type</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ResultType">
ResultType
</a>
</em>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.PipelineResult">PipelineResult
</h3>
<p>
Expand Down Expand Up @@ -11424,10 +11358,10 @@ string
<h3 id="tekton.dev/v1beta1.ResultType">ResultType
(<code>int</code> alias)</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.PipelineResourceResult">PipelineResourceResult</a>)
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.RunResult">RunResult</a>)
</p>
<div>
<p>ResultType used to find out whether a PipelineResourceResult is from a task result or not
<p>ResultType used to find out whether a RunResult is from a task result or not
Note that ResultsType is another type which is used to define the data type
(e.g. string, array, etc) we used for Results</p>
</div>
Expand All @@ -11440,14 +11374,79 @@ Note that ResultsType is another type which is used to define the data type
<p>ResultsType indicates the type of a result;
Used to distinguish between a single string and an array of strings.
Note that there is ResultType used to find out whether a
PipelineResourceResult is from a task result or not, which is different from
RunResult is from a task result or not, which is different from
this ResultsType.</p>
</div>
<h3 id="tekton.dev/v1beta1.RunObject">RunObject
</h3>
<div>
<p>RunObject is implemented by CustomRun and Run</p>
</div>
<h3 id="tekton.dev/v1beta1.RunResult">RunResult
</h3>
<p>
(<em>Appears on:</em><a href="#tekton.dev/v1beta1.TaskRunStatusFields">TaskRunStatusFields</a>)
</p>
<div>
<p>RunResult is used to write key/value pairs to TaskRun pod termination messages.
The key/value pairs may come from the entrypoint binary, or represent a TaskRunResult.
If they represent a TaskRunResult, the key is the name of the result and the value is the
JSON-serialized value of the result.</p>
</div>
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>key</code><br/>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>value</code><br/>
<em>
string
</em>
</td>
<td>
</td>
</tr>
<tr>
<td>
<code>resourceName</code><br/>
<em>
string
</em>
</td>
<td>
<p>ResourceName may be used in tests, but it is not populated in termination messages.
It is preserved here for backwards compatibility and will not be ported to v1.</p>
</td>
</tr>
<tr>
<td>
<code>type</code><br/>
<em>
<a href="#tekton.dev/v1beta1.ResultType">
ResultType
</a>
</em>
</td>
<td>
</td>
</tr>
</tbody>
</table>
<h3 id="tekton.dev/v1beta1.Sidecar">Sidecar
</h3>
<p>
Expand Down Expand Up @@ -13894,8 +13893,8 @@ All TaskRunStatus stored in RetriesStatus will have no date within the RetriesSt
<td>
<code>resourcesResult</code><br/>
<em>
<a href="#tekton.dev/v1beta1.PipelineResourceResult">
[]PipelineResourceResult
<a href="#tekton.dev/v1beta1.RunResult">
[]RunResult
</a>
</em>
</td>
Expand Down
2 changes: 1 addition & 1 deletion hack/ignored-openapi-violations.list
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# They are in the specific order they are printed out by k8s.io/kube-openapi/cmd/openapi-gen.
# No additional violations should be added to this ignored list.
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,CloudEventDeliveryState,Error
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,PipelineResourceResult,ResultType
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,RunResult,ResultType
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,PipelineTask,WhenExpressions
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,SidecarState,ContainerName
API rule violation: names_match,github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1,StepState,ContainerName
Expand Down
12 changes: 6 additions & 6 deletions internal/sidecarlogresults/sidecarlogresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func LookForResults(w io.Writer, runDir string, resultsDir string, resultNames [
}

// GetResultsFromSidecarLogs extracts results from the logs of the results sidecar
func GetResultsFromSidecarLogs(ctx context.Context, clientset kubernetes.Interface, namespace string, name string, container string, podPhase corev1.PodPhase) ([]v1beta1.PipelineResourceResult, error) {
sidecarLogResults := []v1beta1.PipelineResourceResult{}
func GetResultsFromSidecarLogs(ctx context.Context, clientset kubernetes.Interface, namespace string, name string, container string, podPhase corev1.PodPhase) ([]v1beta1.RunResult, error) {
sidecarLogResults := []v1beta1.RunResult{}
if podPhase == corev1.PodPending {
return sidecarLogResults, nil
}
Expand All @@ -153,7 +153,7 @@ func GetResultsFromSidecarLogs(ctx context.Context, clientset kubernetes.Interfa
return extractResultsFromLogs(sidecarLogs, sidecarLogResults, maxResultLimit)
}

func extractResultsFromLogs(logs io.Reader, sidecarLogResults []v1beta1.PipelineResourceResult, maxResultLimit int) ([]v1beta1.PipelineResourceResult, error) {
func extractResultsFromLogs(logs io.Reader, sidecarLogResults []v1beta1.RunResult, maxResultLimit int) ([]v1beta1.RunResult, error) {
scanner := bufio.NewScanner(logs)
buf := make([]byte, maxResultLimit)
scanner.Buffer(buf, maxResultLimit)
Expand All @@ -174,8 +174,8 @@ func extractResultsFromLogs(logs io.Reader, sidecarLogResults []v1beta1.Pipeline
return sidecarLogResults, nil
}

func parseResults(resultBytes []byte, maxResultLimit int) (v1beta1.PipelineResourceResult, error) {
result := v1beta1.PipelineResourceResult{}
func parseResults(resultBytes []byte, maxResultLimit int) (v1beta1.RunResult, error) {
result := v1beta1.RunResult{}
if len(resultBytes) > maxResultLimit {
return result, ErrSizeExceeded
}
Expand All @@ -184,7 +184,7 @@ func parseResults(resultBytes []byte, maxResultLimit int) (v1beta1.PipelineResou
if err := json.Unmarshal(resultBytes, &res); err != nil {
return result, fmt.Errorf("Invalid result %w", err)
}
result = v1beta1.PipelineResourceResult{
result = v1beta1.RunResult{
Key: res.Name,
Value: res.Value,
ResultType: v1beta1.TaskRunResultType,
Expand Down
10 changes: 5 additions & 5 deletions internal/sidecarlogresults/sidecarlogresults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ func TestExtractResultsFromLogs(t *testing.T) {
}
logs := strings.NewReader(podLogs)

results, err := extractResultsFromLogs(logs, []v1beta1.PipelineResourceResult{}, 4096)
results, err := extractResultsFromLogs(logs, []v1beta1.RunResult{}, 4096)
if err != nil {
t.Error(err)
}
want := []v1beta1.PipelineResourceResult{
want := []v1beta1.RunResult{
{
Key: "result1",
Value: "foo",
Expand Down Expand Up @@ -181,7 +181,7 @@ func TestExtractResultsFromLogs_Failure(t *testing.T) {
}
logs := strings.NewReader(podLogs)

_, err := extractResultsFromLogs(logs, []v1beta1.PipelineResourceResult{}, 4096)
_, err := extractResultsFromLogs(logs, []v1beta1.RunResult{}, 4096)
if !errors.Is(err, ErrSizeExceeded) {
t.Fatalf("Expected error %v but got %v", ErrSizeExceeded, err)
}
Expand All @@ -205,7 +205,7 @@ func TestParseResults(t *testing.T) {
res, _ := json.Marshal(&r)
podLogs = append(podLogs, string(res))
}
want := []v1beta1.PipelineResourceResult{{
want := []v1beta1.RunResult{{
Key: "result1",
Value: "foo",
ResultType: v1beta1.TaskRunResultType,
Expand All @@ -218,7 +218,7 @@ func TestParseResults(t *testing.T) {
Value: `["hello","world"]`,
ResultType: v1beta1.TaskRunResultType,
}}
stepResults := []v1beta1.PipelineResourceResult{}
stepResults := []v1beta1.RunResult{}
for _, plog := range podLogs {
res, err := parseResults([]byte(plog), 4096)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1/result_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type ResultValue = ParamValue
// ResultsType indicates the type of a result;
// Used to distinguish between a single string and an array of strings.
// Note that there is ResultType used to find out whether a
// PipelineResourceResult is from a task result or not, which is different from
// RunResult is from a task result or not, which is different from
// this ResultsType.
type ResultsType string

Expand Down
Loading

0 comments on commit 758b16a

Please sign in to comment.