-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add source timestamp field for source result #1471
Conversation
@@ -188,14 +211,16 @@ var _ = Describe("Bundle Loader", func() { | |||
}) | |||
|
|||
AfterEach(func() { | |||
ref, err := name.ParseReference(testImage) | |||
Expect(err).ToNot(HaveOccurred()) | |||
if testImage != "" { |
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.
When certain tests are skipped, the testImage
string can actually be empty and therefore would cause a panic.
@@ -35,12 +35,12 @@ func PackAndPush(ref name.Reference, directory string, options ...remote.Option) | |||
return name.Digest{}, err | |||
} | |||
|
|||
image, err := mutate.AppendLayers(empty.Image, bundleLayer) | |||
image, err := mutate.Time(empty.Image, time.Unix(0, 0)) |
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.
Mutating the empty image before using it with AppendLayers
makes sure that the image has timestamp 0, but the layer that is later added is not mutated as well.
1cc6f3f
to
414bd83
Compare
414bd83
to
594deeb
Compare
pipelineapi.TaskResult{ | ||
Name: fmt.Sprintf("%s-source-%s-source-timestamp", prefixParamsResultsVolumes, name), | ||
Description: "The timestamp of the most recent source file.", | ||
}, |
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 this should be rather declared in sources.go generically.
sourceResult.Bundle = &build.BundleSourceResult{Digest: imageDigest} | ||
} | ||
|
||
sourceTimestamp := findResultValue(results, fmt.Sprintf("%s-source-%s-source-timestamp", prefixParamsResultsVolumes, name)) |
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.
Same here, should that be in sources.go, updateBuildRunStatusWithSourceResult
?
branchName = "branch-name" | ||
commitSHAResult = "commit-sha" | ||
commitAuthorResult = "commit-author" | ||
commitTimestampResult = "commit-timestamp" |
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.
Consider using a common result as suggested in bundle.go. This will help us when we want to consume the result from another step (image-processing). Ideally we there need no check which result to read but rely on a common name independent of the source type.
594deeb
to
8492b27
Compare
8492b27
to
08956ed
Compare
TypeMeta: metav1.TypeMeta{ | ||
Kind: string(build.ClusterBuildStrategyKind), | ||
}, |
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.
Using ClusterBuildStrategy
caused issues since the BuildRuns created using this strategy in the test code did not have the kind and therefore failed to be usable.
for _, result := range results { | ||
if result.Name == name { | ||
return result.Value.StringVal | ||
return strings.TrimSpace(result.Value.StringVal) |
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.
Why ? If for example a commit message ends with a space then we can be accurate by not trimming.
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.
Let me put that trim back on the other side.
Fix issue with empty string when test cases are skipped.
Extend Git step CLI to write a result file containing the source timestamp of the commit that is checked out.
08956ed
to
420c8f9
Compare
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.
/approve
/lgtm
420c8f9
to
4eb9791
Compare
Add flag to write source timestamp into result file. Fix `PackAndPush` function to set timestamp of the base image and not for all files in the main layer of the image to keep the timestamps of the files in the bundle layer.
Update CRDs to include timestamp fields. Add timestamp fields for Git and Bundle results.
4eb9791
to
f181f4c
Compare
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.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: SaschaSchwarze0 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 |
Changes
Extend the API fields and CRD files to include the source timestamp in the source result.
Update Git step code to write commit timestamp result file.
Update Bundle step code to write source timestamp, which is the the most recent source file timestamp.
Extend task run setup logic to include respective command line flags for the Git and Bundle step CLIs to write the result files, which then can be used to extend the status sources fields of the BuildRun.
Fix timestamp issue in Bundle pack and push code so that only the image gets a neutral timestamp, but the packaged source files retain their respective filesystem modification timestamps.
Add integration test cases to verify the new status sources fields.
Fixes #1446
Submitter Checklist
See the contributor guide
for details on coding conventions, github and prow interactions, and the code review process.
Release Notes