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

Support for SOURCE_DATE_EPOCH in tkn bundle push #2137

Merged
merged 3 commits into from Oct 5, 2023

Conversation

zregvart
Copy link
Contributor

Changes

First commit is a refactoring commit to move the code from PreRunE to parseArgsAndFlags, this is something that in full honesty should have been done on #2133. This way is easier to test the implementation.

Second commit introduces support for SOURCE_TIME_EPOCH environment variable in tkn bundle push.

Fixes #2136

Submitter Checklist

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

  • Includes tests (if functionality changed/added)
  • Run the code checkers with make check
  • Regenerate the manpages, docs and go formatting with make generated
  • Commit messages follow commit message best practices

See the contribution guide
for more details.

Release Notes

Created time in OCI Image Configuration in `tkn bundle push` can be provided using the SOURCE_TIME_EPOCH environment variable

This refactor should make it easier to test setting ctime.
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 28, 2023
@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 28, 2023
@tekton-robot
Copy link
Contributor

Hi @zregvart. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 28, 2023
@chmouel
Copy link
Member

chmouel commented Sep 28, 2023

any chance you can explain why this is needed ? and what is this needed to be a flag ? is it expected to be used by a large number of users?

i am afraid having more and more flags in CLI with no clear explanation of what it does will just end up confusing and a burden for the maintainers.

@zregvart zregvart changed the title Support for SOURCE_TIME_EPOCH in tkn bundle push Support for SOURCE_DATE_EPOCH in tkn bundle push Sep 28, 2023
@zregvart
Copy link
Contributor Author

any chance you can explain why this is needed ? and what is this needed to be a flag ? is it expected to be used by a large number of users?

This is not adding another flag but allowing the existing flag (--ctime) to be specified with the SOURCE_DATE_EPOCH environment variable. This is in accordance with the specification from reproducible builds project.

i am afraid having more and more flags in CLI with no clear explanation of what it does will just end up confusing and a burden for the maintainers.

Oh, for sure, but we're not adding one here :)

@chmouel
Copy link
Member

chmouel commented Sep 28, 2023

Oh, for sure, but we're not adding one here :)

ah i misread the PR sorry about that, this is fine by me if it's following the spec

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 28, 2023
@chmouel
Copy link
Member

chmouel commented Sep 28, 2023

but another thing, what about making ctime the default? as discussed on another issue i don't believe there is breakage that could happen by changing the behaviour...

@zregvart
Copy link
Contributor Author

but another thing, what about making ctime the default? as discussed on another issue i don't believe there is breakage that could happen by changing the behaviour...

Yeah, I plan on doing that, chose this to do first because of the refactoring that I did here. The followup in #2135 should be just a couple of lines following this PR :)

@zregvart
Copy link
Contributor Author

I see the tests fail, I'm going to investigate a bit, most likely something to do with the time zones...

@zregvart
Copy link
Contributor Author

Took me a minute to realize that the test runner is setting SOURCE_DATE_EPOCH, and that interfered with the tests.

When the `SOURCE_DATE_EPOCH` environment variable is set and the
`--ctime` parameter is not provided, the unix timestamp from
`SOURCE_DATE_EPOCH` will be used for setting the created time of the OCI
Tekton bundle image.
@zregvart
Copy link
Contributor Author

zregvart commented Oct 2, 2023

/retest-required

func init() {
// fixed time to ease testing
now = func() time.Time {
return time.Date(2023, 9, 22, 1, 2, 3, 0, time.UTC)
Copy link
Member

Choose a reason for hiding this comment

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

we usually use fakeclock/clockwork for that

@zregvart
Copy link
Contributor Author

zregvart commented Oct 4, 2023

/retest-required

@chmouel
Copy link
Member

chmouel commented Oct 4, 2023

/lgtm

Thanks!

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 4, 2023
@@ -22,6 +23,7 @@ import (
"time"

"github.com/google/go-containerregistry/pkg/name"
"github.com/jonboulle/clockwork"
Copy link
Member

@chmouel chmouel Oct 4, 2023

Choose a reason for hiding this comment

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

thanks addressing other parts of the code

@vdemeester
Copy link
Member

/approve

@tekton-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

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 Oct 5, 2023
@tekton-robot tekton-robot merged commit 1c52522 into tektoncd:main Oct 5, 2023
8 checks passed
@zregvart zregvart deleted the issue/2136 branch October 6, 2023 20:13
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SOURCE_DATE_EPOCH in tkn bundle push
4 participants