Skip to content

Commit

Permalink
other round linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
renzodavid9 committed May 20, 2024
1 parent e3540fd commit e391065
Show file tree
Hide file tree
Showing 20 changed files with 214 additions and 306 deletions.
2 changes: 1 addition & 1 deletion pkg/artifacts/signable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const (
var ignore = []cmp.Option{cmpopts.IgnoreUnexported(name.Registry{}, name.Repository{}, name.Digest{})}

func TestOCIArtifact_ExtractObjects(t *testing.T) {

tests := []struct {
name string
obj objects.TektonObject
Expand Down Expand Up @@ -808,6 +807,7 @@ func TestExtractBuildArtifactsFromResults(t *testing.T) {
}

func createDigest(t *testing.T, dgst string) name.Digest {
t.Helper()
result, err := name.NewDigest(dgst)
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/chains/formats/slsa/extract/v1beta1/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func SubjectDigests(ctx context.Context, obj objects.TektonObject, slsaconfig *s
return subjects
}

// SubjectsFromPipelineRunV1Beta1 returns software artifacts produced from the PipelineRun object.
func SubjectsFromPipelineRunV1Beta1(ctx context.Context, obj objects.TektonObject, slsaconfig *slsaconfig.SlsaConfig) []*intoto.ResourceDescriptor {
prSubjects := SubjectsFromTektonObjectV1Beta1(ctx, obj)

Expand Down Expand Up @@ -90,6 +91,7 @@ func SubjectsFromPipelineRunV1Beta1(ctx context.Context, obj objects.TektonObjec
return result
}

// SubjectsFromTektonObjectV1Beta1 returns software artifacts produced from the Tekton object.
func SubjectsFromTektonObjectV1Beta1(ctx context.Context, obj objects.TektonObject) []*intoto.ResourceDescriptor {
logger := logging.FromContext(ctx)
var subjects []*intoto.ResourceDescriptor
Expand Down
4 changes: 2 additions & 2 deletions pkg/chains/formats/slsa/internal/metadata/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

func TestMetadata(t *testing.T) {
tr := &v1.TaskRun{ //nolint:staticcheck
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Name: "my-taskrun",
Namespace: "my-namespace",
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestMetadata(t *testing.T) {

func TestMetadataInTimeZone(t *testing.T) {
tz := time.FixedZone("Test Time", int((12 * time.Hour).Seconds()))
tr := &v1.TaskRun{ //nolint:staticcheck
tr := &v1.TaskRun{
ObjectMeta: metav1.ObjectMeta{
Name: "my-taskrun",
Namespace: "my-namespace",
Expand Down
4 changes: 2 additions & 2 deletions pkg/chains/formats/slsa/internal/provenance/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func GetSLSA1Statement(obj objects.TektonObject, sub []*intoto.ResourceDescripto

func getProtoStruct(predicate *slsa.Provenance) (*structpb.Struct, error) {
protoStruct := &structpb.Struct{}
predicateJson, err := protojson.Marshal(predicate)
predicateJSON, err := protojson.Marshal(predicate)
if err != nil {
return nil, err
}

err = protojson.Unmarshal(predicateJson, protoStruct)
err = protojson.Unmarshal(predicateJSON, protoStruct)
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const (

// used to toggle the fields in see AddTektonTaskDescriptor
// and AddSLSATaskDescriptor
type addTaskDescriptorContent func(*objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error) //nolint:staticcheck
type addTaskDescriptorContent func(*objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error)

// ResolveOptions represents the configuration to be use to resolve dependencies.
type ResolveOptions struct {
Expand Down Expand Up @@ -111,7 +111,7 @@ func RemoveDuplicateResolvedDependencies(resolvedDependencies []*intoto.Resource

// AddTektonTaskDescriptor returns the more verbose resolved dependency content. this adds the name, uri, digest
// and content if possible.
func AddTektonTaskDescriptor(tr *objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error) { //nolint:staticcheck
func AddTektonTaskDescriptor(tr *objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error) {
rd := intoto.ResourceDescriptor{}
storedTr, err := json.Marshal(tr)
if err != nil {
Expand All @@ -130,7 +130,7 @@ func AddTektonTaskDescriptor(tr *objects.TaskRunObjectV1) (*intoto.ResourceDescr

// AddSLSATaskDescriptor resolves dependency content for the more generic slsa verifiers. just logs
// the name, uri and digest.
func AddSLSATaskDescriptor(tr *objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error) { //nolint:staticcheck
func AddSLSATaskDescriptor(tr *objects.TaskRunObjectV1) (*intoto.ResourceDescriptor, error) {
if tr.Status.Provenance != nil && tr.Status.Provenance.RefSource != nil {
return &intoto.ResourceDescriptor{
Name: PipelineTaskConfigName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func tektonTaskRuns() map[string][]byte {
func TestTaskRun(t *testing.T) {
tests := []struct {
name string
obj objects.TektonObject //nolint:staticcheck
obj objects.TektonObject
resolveOpts ResolveOptions
want []*intoto.ResourceDescriptor
}{
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestTaskRun(t *testing.T) {
},
{
name: "resolvedDependencies from remote task",
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{ //nolint:staticcheck
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{
Status: v1.TaskRunStatus{
TaskRunStatusFields: v1.TaskRunStatusFields{
Provenance: &v1.Provenance{
Expand All @@ -401,7 +401,7 @@ func TestTaskRun(t *testing.T) {
},
{
name: "git resolvedDependencies from taskrun params",
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{ //nolint:staticcheck
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{
Spec: v1.TaskRunSpec{
Params: []v1.Param{{
Name: "CHAINS-GIT_COMMIT",
Expand All @@ -424,7 +424,7 @@ func TestTaskRun(t *testing.T) {
},
{
name: "resolvedDependencies from step images",
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{ //nolint:staticcheck
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{
Status: v1.TaskRunStatus{
TaskRunStatusFields: v1.TaskRunStatusFields{
Steps: []v1.StepState{{
Expand Down Expand Up @@ -457,7 +457,7 @@ func TestTaskRun(t *testing.T) {
},
{
name: "resolvedDependencies from step and sidecar images",
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{ //nolint:staticcheck
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{
Status: v1.TaskRunStatus{
TaskRunStatusFields: v1.TaskRunStatusFields{
Steps: []v1.StepState{{
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestTaskRun(t *testing.T) {
resolveOpts: ResolveOptions{
WithStepActionsResults: true,
},
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{ //nolint:staticcheck
obj: objects.NewTaskRunObjectV1(&v1.TaskRun{
Status: v1.TaskRunStatus{
TaskRunStatusFields: v1.TaskRunStatusFields{
Steps: []v1.StepState{{
Expand Down
4 changes: 2 additions & 2 deletions pkg/chains/formats/slsa/v1/internal/protos/protos.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import (

// GetPredicateStruct returns a protobuf struct from the given SLSAv0.2 predicate.
func GetPredicateStruct(predicate *slsa.ProvenancePredicate) (*structpb.Struct, error) {
predicateJson, err := json.Marshal(predicate)
predicateJSON, err := json.Marshal(predicate)
if err != nil {
return nil, err
}

predicateStruct := &structpb.Struct{}
err = protojson.Unmarshal(predicateJson, predicateStruct)
err = protojson.Unmarshal(predicateJSON, predicateStruct)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit e391065

Please sign in to comment.