Open kessibi opened 11 months ago
I think we can support this. We already do for pack build
, it can work similarly for pack rebase
. All we would need to do is set SOURCE_DATE_EPOCH
in the lifecycle's execution environment.
--creation-time string Desired create time in the output image config. Accepted values are Unix timestamps (e.g., '1641013200'), or 'now'.
Maybe while rebasing it could be good to at least remember the creation time of the pack build
phase. Right now, building with --creation-time
and then rebasing just nulls the creation time.
Thank you for considering this addition either way.
@kessibi that's a great point! Maybe we could introduce a special value preserve
(or something) for rebase that preserves the original creation time, whatever it was. We already have special value now
for pack build
so this would be an extension of that.
Hey I want to work on this issue! @natalieparellano can you please suggest me the files where I can improve to make it work.
I think the sourceDateEpochEnv
in the lifecycle's execution environment is already set by this:
withEnv := NullOp()
if l.opts.CreationTime != nil && l.platformAPI.AtLeast("0.9") {
withEnv = WithEnv(fmt.Sprintf("%s=%s", sourceDateEpochEnv, strconv.Itoa(int(l.opts.CreationTime.Unix()))))
}
can you guide me about rebase? or needed file where change should be made?
I think the
sourceDateEpochEnv
in the lifecycle's execution environment is already set by this:
Yes, but as you can see, we are setting the environment variable when running:
In this case the idea is to add a new behavior for the rebase
command.
I will try to keep checking and guide you through the process.
Checking a little bit the code, here are my thoughts (this is just my initial understanding), @natalieparellano give me a hand if I am wrong!
createdAt
attribute, we need to do it there. Maybe we need a new FetchOptions
for rebase operation? createdAt
value, and internally mutate the workingImage with that value?Again, these are just some ideas, but I am not 100% sure about it.
@jjbustamante , @natalieparellano can you point me where this particular rebase method is : https://github.com/buildpacks/lifecycle/blob/33c5b890044980b25810c0719801af0398fe9b3b/phase/rebaser.go#L61
// rebase
if err = workingImage.Rebase(origMetadata.RunImage.TopLayer, newBaseImage); err != nil {
return files.RebaseReport{}, fmt.Errorf("rebase app image: %w", err)
}
Hi @PratikforCoding
Apologies for the slow reply - since pack is using the lifecycle as a library (see here) I think if you just set SOURCE_DATE_EPOCH
in pack's execution environment it should just work without any code changes. If I'm right, maybe all we need to do is provide helpers for a better UX when the desired value is now
or keep
/preserve
or whatever.
Edit: this is not true. We need to instantiate the image with WithCreatedAt
or call SetCreatedAt
as mentioned in the following comments.
Hey @jjbustamante @natalieparellano, after inspecting the files and imgutil library , I think the feature can be implemented by this:
RebaseOption
struct here containing CreationTime variable.SetCreatedAt
setter function in local and remote file that is local.go
and remote.go
.SetCreatedAt
function using Image interface here.appImage
using the setter and getter method of imgutil
library here.I guess this should work, help me to understand if my approach is wrong.
Hi @PratikforCoding
I will try to go through your comment.
- Implementing a
RebaseOption
struct here containing CreationTime variable.
Yes, actually here the rebase client options structure.
- Implementing
SetCreatedAt
setter function in local and remote file that islocal.go
andremote.go
.
What we do to set the CreatedAt
is, we do it during Image creation using the ImageOption.
Remote: when a remote image instance is created we use this option
Local: similar to remote, we have an option to do this.
Basically we need to pass through the option when the remote or local image is created. Now, our problem is to find where this is happening during the rebase operation. Checking Natalie's comment.
When we run pack build --creation-time
:
I think we need to do a similar logic for rebase. Checking the code in the lifecycle, we are creating the Image instances here, as you can see, it is very similar to what we do in the exporter
phase, we need to have available the custom creation time.
An option to do this will be:
SOURCE_DATE_EPOCH
on pack side with the value provided by the end-userI am not sure, but I think we try to avoid those setters/getters on values that we don't expect to change on a Image, that's why I think the way will be to set the value during the image creation time.
Hi @PratikforCoding
Are you still interest in working on this issue? I asked because I am planning next release and I want to see if I can add it into the scope of 0.34.0?
Hi @jjbustamante sir,
I want to work on this issue but I was struggling and my university exam started. I am still interested to work in this issue, can you tell me in how many days the 0.34.0 will be released?
Hi @PratikforCoding, well, my plan is to have some release candidate version ready for next KubeCon EU, March 18 - 22
Okay @jjbustamante , can I take time till start of march? I will try to implement this.
Good day, has their been progress on this issue? Thanks.
Hi @kessibi I don't believe so, but we would welcome a PR for this. The guidance provided here seems fine to me, although I'd recommend instantiating the image with the WithCreatedAt
option instead of modifying it after-the-fact.
Description
One of the key feature in my use of buildpack is the ability to effortlessly rebase. One of the great pillar stone missing is the ability to provide a timestamp just like the
--creation-time
on build. If this has been discussed in the past, what is the reason behind not implementing it?Proposed solution
Add the possibility to give a proper timestamp/string as a date to a rebased image. Example:
--rebase-time
or just--creation-time
to stay consistent with podman/docker output standards.Describe alternatives you've considered
I have looked into doing it manually fell short. I think changing the creation time would change the image signature sha.
Thank you.