-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 methods for setting file timestamps #1613
Conversation
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildConfiguration.java
Outdated
Show resolved
Hide resolved
jib-core/src/test/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilderTest.java
Outdated
Show resolved
Hide resolved
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.
This looks good to me.
One thing for a thought: previously the file timestamp was part of LayerConfiguration
, which makes sense as it is a property of a file like permissions which is still in LayerConfiguration
. Now the timestamp provider is set in BuildConfiguration
. I think this is fine, but I wonder if others have different opinions.
jib-core/src/test/java/com/google/cloud/tools/jib/api/JibContainerBuilderTest.java
Outdated
Show resolved
Hide resolved
jib-core/src/main/java/com/google/cloud/tools/jib/frontend/TimestampProvider.java
Outdated
Show resolved
Hide resolved
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.
Thanks for prototyping this. It seems to a bit more complicated than I imagined. Here are my thoughts:
- I think we should probably make the file-permissions configurable too (so the below should extend to
FilePermissions
) - I think we want to use a provider rather than single value, so
Function<Path,Instant>
; we should probably have this on theJib
class so that it's easy to reference (class Jib { static Function<Path,Long> defaultFileModificationTimeProvider = path -> 1000; }
)- if someone wants to use real timestamps set to current then they can just use
p -> Files.getLastModifiedTime(p)
- if someone wants to use real timestamps set to current then they can just use
LayerConfiguration.Builder
would require a file modification time provider to be used for subsequent calls toaddEntry
without an explicit file modification timeLayerConfiguration.builder()
would use the our default epoch+1s providerJibContainerBuilder
andJavaContainerBuilder
would take and cascade a provider down — soLayerConfiguration.builder()
would just be a convenience for Jib Core users, whereas our plugins should always explicitly pass down the provider
The PR uses a provider (effectively |
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/LayerConfiguration.java
Outdated
Show resolved
Hide resolved
Weird — I must have somehow looking from an earlier commit. This current state looks way better. But I think we should use this provider to provide defaults which can still be explicitly over-ridden in addEntry(...). |
If we do allow setting a timestamp provider on a per- Edit: Actually, source path might be more useful for something like git commit history / getting the actual mod time of the file. |
jib-core/src/main/java/com/google/cloud/tools/jib/image/LayerEntry.java
Outdated
Show resolved
Hide resolved
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/LayerConfiguration.java
Outdated
Show resolved
Hide resolved
jib-core/src/main/java/com/google/cloud/tools/jib/frontend/FileTimestampProvider.java
Outdated
Show resolved
Hide resolved
jib-core/src/main/java/com/google/cloud/tools/jib/image/LayerEntry.java
Outdated
Show resolved
Hide resolved
Sorry to keep changing this so much. Trying this now:
|
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/LayerConfiguration.java
Outdated
Show resolved
Hide resolved
jib-core/src/main/java/com/google/cloud/tools/jib/configuration/LayerConfiguration.java
Outdated
Show resolved
Hide resolved
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.
Generally looks good to me.
Adds overloads for
LayerConfiguration.Builder#addEntryRecursive
that take providers for file permissions/file modification timestamps to apply permissions and timestamps on a per-file basis.Fixes #1607.