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 57cbf2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/chains/storage/grafeas/grafeas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ func TestGrafeasBackend_StoreAndRetrieve(t *testing.T) {

// test attestation storage and retrieval
func testStoreAndRetrieveHelper(ctx context.Context, t *testing.T, test testConfig, backend Backend) {
t.Helper()
if err := backend.StorePayload(ctx, test.args.runObject, test.args.payload, test.args.signature, test.args.opts); (err != nil) != test.wantErr {
t.Fatalf("Backend.StorePayload() failed. error:%v, wantErr:%v", err, test.wantErr)
}
Expand Down Expand Up @@ -448,6 +449,7 @@ func testStoreAndRetrieveHelper(ctx context.Context, t *testing.T, test testConf
// ------------------ occurrences for taskruns and pipelineruns --------------
// BUILD Occurrence for the build taskrun that stores the slsa provenance
func getTaskRunBuildOcc(t *testing.T, identifier string) *pb.Occurrence {
t.Helper()
return &pb.Occurrence{
Name: identifier,
ResourceUri: identifier,
Expand Down Expand Up @@ -511,6 +513,7 @@ func getTaskRunAttestationOcc(t *testing.T, identifier string) *pb.Occurrence {
}

func getPipelineRunBuildOcc(t *testing.T, identifier string) *pb.Occurrence {
t.Helper()
ciPipelineRunProvenance := intoto.Statement{
Subject: buildTaskRunProvenance.Subject,
Predicate: getPredicateStruct(t, &ciPipelineRunPredicate),
Expand Down Expand Up @@ -560,6 +563,7 @@ func getPipelineRunBuildOcc(t *testing.T, identifier string) *pb.Occurrence {
}

func getRawPayload(t *testing.T, in interface{}) []byte {
t.Helper()
rawPayload, err := json.Marshal(in)
if err != nil {
t.Errorf("Unable to marshal the provenance: %v", in)
Expand Down Expand Up @@ -747,6 +751,7 @@ func parseURIFilterString(filter string) []string {
}

func getPredicateStruct(t *testing.T, predicate *slsa.ProvenancePredicate) *structpb.Struct {
t.Helper()
predicateJson, err := json.Marshal(predicate)

Check warning on line 755 in pkg/chains/storage/grafeas/grafeas_test.go

View workflow job for this annotation

GitHub Actions / lint

var-naming: var predicateJson should be predicateJSON (revive)
if err != nil {
t.Fatalf("error getting predicate struct: %v", err)
Expand Down
7 changes: 7 additions & 0 deletions test/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ var simpleTaskRun = v1.TaskRun{

func makeBucket(t *testing.T, client *storage.Client) (string, func()) {
// Make a bucket
t.Helper()
rand.Seed(time.Now().UnixNano())
testBucketName := fmt.Sprintf("tekton-chains-e2e-%d", rand.Intn(1000))

Expand Down Expand Up @@ -161,6 +162,7 @@ func makeBucket(t *testing.T, client *storage.Client) (string, func()) {
}

func readObj(t *testing.T, bucket, name string, client *storage.Client) io.Reader {
t.Helper()
ctx := context.Background()
reader, err := client.Bucket(bucket).Object(name).NewReader(ctx)
if err != nil {
Expand All @@ -170,6 +172,7 @@ func readObj(t *testing.T, bucket, name string, client *storage.Client) io.Reade
}

func setConfigMap(ctx context.Context, t *testing.T, c *clients, data map[string]string) func() {
t.Helper()
// Change the config to be GCS storage with this bucket.
// Note(rgreinho): This comment does not look right...
clean := updateConfigMap(ctx, t, c, data, namespace, "chains-config")
Expand All @@ -183,6 +186,7 @@ func setConfigMap(ctx context.Context, t *testing.T, c *clients, data map[string
}

func setupPipelinesFeatureFlags(ctx context.Context, t *testing.T, c *clients, data map[string]string) func() {
t.Helper()
pipelinesNs := "tekton-pipelines"

clean := updateConfigMap(ctx, t, c, data, pipelinesNs, "feature-flags")
Expand All @@ -196,6 +200,7 @@ func setupPipelinesFeatureFlags(ctx context.Context, t *testing.T, c *clients, d
}

func updateConfigMap(ctx context.Context, t *testing.T, c *clients, data map[string]string, ns, configMapName string) func() {
t.Helper()
cm, err := c.KubeClient.CoreV1().ConfigMaps(ns).Get(ctx, configMapName, metav1.GetOptions{})
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -233,6 +238,7 @@ func updateConfigMap(ctx context.Context, t *testing.T, c *clients, data map[str
}

func printDebugging(t *testing.T, obj objects.TektonObject) {
t.Helper()
kind := obj.GetObjectKind().GroupVersionKind().Kind

t.Logf("============================== %s logs ==============================", obj.GetGVK())
Expand All @@ -249,6 +255,7 @@ func printDebugging(t *testing.T, obj objects.TektonObject) {
}

func verifySignature(ctx context.Context, t *testing.T, c *clients, obj objects.TektonObject) {
t.Helper()
// Retrieve the configuration.
chainsConfig, err := c.KubeClient.CoreV1().ConfigMaps(namespace).Get(ctx, "chains-config", metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit 57cbf2a

Please sign in to comment.