-
Notifications
You must be signed in to change notification settings - Fork 135
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
Fix default params in attestation invocation #449
Conversation
Hi @lcarva. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
The following is the coverage report on the affected files.
|
if ts := tr.Status.TaskSpec; ts != nil { | ||
for _, p := range ts.Params { | ||
if p.Default != nil { | ||
v := p.Default.StringVal | ||
if v == "" { | ||
// TODO: Consider using p.Default.MarshalJSON() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@priyawadhwa, should I just do this now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I added a commit to do this. Let me know what you think. I can easily drop it if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@priyawadhwa, please take a look when you have a chance 🙏
bfb6482
to
c8a057c
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/retest |
@priyawadhwa, @wlynch ptal 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! Few small things.
@@ -66,10 +66,10 @@ func TestCreatePayload1(t *testing.T) { | |||
}, | |||
Invocation: slsa.ProvenanceInvocation{ | |||
Parameters: map[string]string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should use map[string]ArrayOrString
(https://pkg.go.dev/github.com/tektoncd/pipeline@v0.36.0/pkg/apis/pipeline/v1beta1#ArrayOrString) here instead and not bother with the string encoding. 🤔 wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's a better approach. I'll give that a shot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Here's an example from a dummy task I used:
🐚 cosign download attestation quay.io/lucarval/minimal-container:latest | jq '.payload | @base64d | fromjson | .predicate.invocation.parameters'
{
"BUILDER_IMAGE": "quay.io/buildah/stable:v1.18.0",
"BUILD_EXTRA_ARGS": "",
"CONTEXT": ".",
"DOCKERFILE": "./Dockerfile",
"FORMAT": "oci",
"IMAGE": "quay.io/lucarval/minimal-container:latest",
"PUSH_EXTRA_ARGS": "",
"SKIP_PUSH": "false",
"STORAGE_DRIVER": "vfs",
"SUPER_ARRAY": [
"hello",
"array"
],
"TLSVERIFY": "true"
}
Default parameters should always be overwritten by values from the taskrun spec. This is how Tekton Pipelines behaves. The attestation should also follow the same rule. This also fixes zero-value default value representation, i.e. an empty string or an empty array. The representation of parameter values is now also consistent. Prior to this commit, %v on the Param was used for default values while .StringVal or .ArrayVal was used for non-default values. Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
Tekton Pipeline allows two different types of parameters, string and array of strings. Represent the correct data type in the attestation. Signed-off-by: Luiz Carvalho <lucarval@redhat.com>
c8a057c
to
2dafdfc
Compare
The following is the coverage report on the affected files.
|
/lgtm |
@priyawadhwa, need an approval now 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: priyawadhwa 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 |
Default parameters should always be overwritten by values from the
taskrun spec. This is how Tekton Pipelines behaves. The attestation
should also follow the same rule.
This also fixes zero-value default value representation, i.e. an empty
string or an empty array.
The representation of parameter values is now also consistent. Prior to
this commit, %v on the Param was used for default values while
.StringVal or .ArrayVal was used for non-default values.
Signed-off-by: Luiz Carvalho lucarval@redhat.com