diff --git a/internal/sidecarlogresults/sidecarlogresults.go b/internal/sidecarlogresults/sidecarlogresults.go index 72f961de894..1b8516c3a7f 100644 --- a/internal/sidecarlogresults/sidecarlogresults.go +++ b/internal/sidecarlogresults/sidecarlogresults.go @@ -289,7 +289,7 @@ func parseResults(resultBytes []byte, maxResultLimit int) (result.RunResult, err case stepArtifactType: resultType = result.StepArtifactsResultType default: - return result.RunResult{}, fmt.Errorf("invalid sidecar result type %v. Must be %v or %v", res.Type, taskResultType, stepResultType) + return result.RunResult{}, fmt.Errorf("invalid sidecar result type %v. Must be %v or %v or %v", res.Type, taskResultType, stepResultType, stepArtifactType) } runResult = result.RunResult{ Key: res.Name, diff --git a/internal/sidecarlogresults/sidecarlogresults_test.go b/internal/sidecarlogresults/sidecarlogresults_test.go index ff81e1aca1a..ffe2660c773 100644 --- a/internal/sidecarlogresults/sidecarlogresults_test.go +++ b/internal/sidecarlogresults/sidecarlogresults_test.go @@ -305,6 +305,38 @@ func TestParseResults(t *testing.T) { Name: "step-foo.result3", Value: `["hello","world"]`, Type: "step", + }, { + Name: "step-artifacts-result", + Value: `{ + "inputs":[ + { + "name":"input-artifacts", + "values":[ + { + "uri":"pkg:example.github.com/inputs", + "digest":{ + "sha256":"b35cacccfdb1e24dc497d15d553891345fd155713ffe647c281c583269eaaae0" + } + } + ] + } + ], + "outputs":[ + { + "name":"image", + "values":[ + { + "uri":"pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c", + "digest":{ + "sha256":"df85b9e3983fe2ce20ef76ad675ecf435cc99fc9350adc54fa230bae8c32ce48", + "sha1":"95588b8f34c31eb7d62c92aaa4e6506639b06ef2" + } + } + ] + } + ] + }`, + Type: "stepArtifact", }, } podLogs := []string{} @@ -336,6 +368,38 @@ func TestParseResults(t *testing.T) { Key: "step-foo.result3", Value: `["hello","world"]`, ResultType: result.StepResultType, + }, { + Key: "step-artifacts-result", + Value: `{ + "inputs":[ + { + "name":"input-artifacts", + "values":[ + { + "uri":"pkg:example.github.com/inputs", + "digest":{ + "sha256":"b35cacccfdb1e24dc497d15d553891345fd155713ffe647c281c583269eaaae0" + } + } + ] + } + ], + "outputs":[ + { + "name":"image", + "values":[ + { + "uri":"pkg:github/package-url/purl-spec@244fd47e07d1004f0aed9c", + "digest":{ + "sha256":"df85b9e3983fe2ce20ef76ad675ecf435cc99fc9350adc54fa230bae8c32ce48", + "sha1":"95588b8f34c31eb7d62c92aaa4e6506639b06ef2" + } + } + ] + } + ] + }`, + ResultType: result.StepArtifactsResultType, }} stepResults := []result.RunResult{} for _, plog := range podLogs { @@ -354,7 +418,7 @@ func TestParseResults_InvalidType(t *testing.T) { results := []SidecarLogResult{{ Name: "result1", Value: "foo", - Type: "not task or step", + Type: "invalid", }} podLogs := []string{} for _, r := range results { @@ -363,7 +427,7 @@ func TestParseResults_InvalidType(t *testing.T) { } for _, plog := range podLogs { _, err := parseResults([]byte(plog), 4096) - wantErr := errors.New("invalid sidecar result type not task or step. Must be task or step") + wantErr := errors.New("invalid sidecar result type invalid. Must be task or step or stepArtifact") if d := cmp.Diff(wantErr.Error(), err.Error()); d != "" { t.Fatal(diff.PrintWantGot(d)) }