Skip to content

Commit

Permalink
use json encoding for resolvedDepencies content
Browse files Browse the repository at this point in the history
  • Loading branch information
joejstuart committed Aug 8, 2023
1 parent 3500ac1 commit 37f309b
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ limitations under the License.
package builddefinitions

import (
"bytes"
"context"
"encoding/gob"
"encoding/json"

"github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/common"
Expand Down Expand Up @@ -52,21 +50,21 @@ type addTaskDescriptorContent func(*v1beta1.TaskRun) (v1.ResourceDescriptor, err
// and content if possible.
func AddTektonTaskDescriptor(tr *v1beta1.TaskRun) (v1.ResourceDescriptor, error) {
rd := v1.ResourceDescriptor{}
buf := bytes.Buffer{}
enc := gob.NewEncoder(&buf)
err := enc.Encode(tr)
storedTr, err := json.Marshal(tr)
if err != nil {
return rd, err
}
logger := logging.FromContext(context.TODO())
logger.Infof("logging taskRun %v", tr)
// add remote task configsource information in materials
if tr.Status.Provenance != nil && tr.Status.Provenance.RefSource != nil {
rd.Name = pipelineTaskConfigName
rd.URI = tr.Status.Provenance.RefSource.URI
rd.Digest = tr.Status.Provenance.RefSource.Digest
rd.Content = buf.Bytes()
rd.Content = storedTr
} else {
rd.Name = pipelineTaskConfigName
rd.Content = buf.Bytes()
rd.Content = storedTr
}
return rd, nil
}
Expand Down

0 comments on commit 37f309b

Please sign in to comment.