Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cherry-pick] Port CEL fixes for release v0.6.1 #665

Merged
merged 3 commits into from
Jul 8, 2020

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Jul 7, 2020

Changes

This cherry-picks two PRs for v0.6.1:

  1. Fix issue with list results. #652
  2. Fix the declarations for compareSecret. #658

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

There was a bug in the handling of list results, where they weren't being marshaled correctly, resulting in an error.

This change identifies list results, and marshals them accordingly.

This also bumps the version of cel to the latest 0.5.1
compareSecret in both its forms was declared as returning a String not a
Bool.

This fixes both of these.
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 7, 2020
@dibyom
Copy link
Member Author

dibyom commented Jul 7, 2020

@bigkevmcd A unit test fails when I cherry-pick #652 . Any ideas on what to fix here?
It also fails in #661: https://tekton-releases.appspot.com/build/tekton-prow/pr-logs/pull/tektoncd_triggers/661/pull-tekton-triggers-unit-tests/1280616596846415872/

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/cel/cel.go 87.9% 87.5% -0.4
pkg/interceptors/cel/triggers.go 88.3% 87.2% -1.1

@bigkevmcd
Copy link
Member

bigkevmcd commented Jul 8, 2020

t> @bigkevmcd A unit test fails when I cherry-pick #652 . Any ideas on what to fix here?

It also fails in #661: https://tekton-releases.appspot.com/build/tekton-prow/pr-logs/pull/tektoncd_triggers/661/pull-tekton-triggers-unit-tests/1280616596846415872/

I ran into this earlier, and my gut feeling is that it's a bug in protojson, sometimes it puts a space between list elements in the JSON output, and sometimes it doesn't.

Unfortunately the JSON marshaling that was used before is now deprecated, and the PR checks failed because of this.

The - 32 in the error log is basically saying there's no space char (ascii 32) in the output where one is expected.

Spaces clearly don't affect the parsing of the result, but lemme see if I can improve the parsing of the test.

@bigkevmcd
Copy link
Member

This is the issue golang/protobuf#1121

@bigkevmcd
Copy link
Member

diff --git a/pkg/interceptors/cel/cel_test.go b/pkg/interceptors/cel/cel_test.go
index 3dd13303..ddd597fa 100644
--- a/pkg/interceptors/cel/cel_test.go
+++ b/pkg/interceptors/cel/cel_test.go
@@ -18,6 +18,7 @@ package cel

 import (
        "bytes"
+       "encoding/json"
        "io"
        "io/ioutil"
        "net/http"
@@ -242,7 +243,8 @@ func TestInterceptor_ExecuteTrigger(t *testing.T) {
                                rt.Fatalf("error reading response body: %v", err)
                        }
                        defer resp.Body.Close()
-                       if diff := cmp.Diff(tt.want, got); diff != "" {
+
+                       if diff := cmp.Diff(mustUnmarshal(t, tt.want), mustUnmarshal(t, got)); diff != "" {
                                rt.Errorf("Interceptor.ExecuteTrigger (-want, +got) = %s", diff)
                        }
                })
@@ -635,3 +637,13 @@ func makeSecret() *corev1.Secret {
                },
        }
 }
+
+func mustUnmarshal(t *testing.T, b []byte) map[string]interface{} {
+       t.Helper()
+       v := map[string]interface{}{}
+       err := json.Unmarshal(b, &v)
+       if err != nil {
+               t.Fatalf("failed to unmarshal the body '%s': %s", b, err)
+       }
+       return v
+}

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/cel/cel.go 87.9% 87.5% -0.4
pkg/interceptors/cel/triggers.go 88.3% 87.2% -1.1

The marshaled JSON output is flaky, this ensures that it matches after parsing.
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/interceptors/cel/cel.go 87.9% 87.5% -0.4
pkg/interceptors/cel/triggers.go 88.3% 87.2% -1.1

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2020
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlynch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2020
@tekton-robot tekton-robot merged commit 322acc3 into tektoncd:release-v0.6.x Jul 8, 2020
@dibyom dibyom deleted the cp branch July 8, 2020 17:22
@dibyom dibyom mentioned this pull request Jul 8, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants