Skip to content

Commit

Permalink
create build type constants
Browse files Browse the repository at this point in the history
  • Loading branch information
joejstuart committed Aug 7, 2023
1 parent 98fc220 commit d9f0026
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package builddefinitions

const (
SlsaBuildType = "https://tekton.dev/chains/v2/slsa"
TektonBuildType = ""
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ import (
const (
pipelineRunResults = "pipelineRunResults/%s"
// JsonMediaType is the media type of json encoded content used in resource descriptors
JsonMediaType = "application/json"
slsaBuildType = "https://tekton.dev/chains/v2/slsa"
tektonBuildType = ""
JsonMediaType = "application/json"
)

// GenerateAttestation generates a provenance statement with SLSA v1.0 predicate for a pipeline run.
Expand Down Expand Up @@ -110,14 +108,14 @@ func byproducts(pro *objects.PipelineRunObject) ([]slsa.ResourceDescriptor, erro

func getBuildDefinition(buildType string, pro *objects.PipelineRunObject) (builddefinitions.PipelineBuildType, error) {
switch buildType {
case slsaBuildType:
case builddefinitions.SlsaBuildType:
return builddefinitions.PipelineBuildType{
BuildType: buildType,
Pro: pro,
InternalParameters: builddefinitions.SLSAPipelineInternalParameters,
AddTaskDescriptorContent: builddefinitions.AddSLSATaskDescriptor,
}, nil
case tektonBuildType:
case builddefinitions.TektonBuildType:
return builddefinitions.PipelineBuildType{
BuildType: buildType,
Pro: pro,
Expand Down
4 changes: 2 additions & 2 deletions pkg/chains/formats/slsa/v2alpha2/internal/taskrun/taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ func byproducts(tro *objects.TaskRunObject) ([]slsa.ResourceDescriptor, error) {

func getBuildDefinition(buildType string, tro *objects.TaskRunObject) (builddefinitions.TaskBuildType, error) {
switch buildType {
case "https://tekton.dev/chains/v2/slsa":
case builddefinitions.SlsaBuildType:
return builddefinitions.TaskBuildType{
BuildType: buildType,
Tro: tro,
InternalParameters: builddefinitions.SLSATaskInternalParameters,
}, nil
case "tekton-build-type":
case builddefinitions.TektonBuildType:
return builddefinitions.TaskBuildType{
BuildType: buildType,
Tro: tro,
Expand Down

0 comments on commit d9f0026

Please sign in to comment.