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

Directory+File: add withTimestamps for normalizing file/dir timestamps #4106

Merged
merged 3 commits into from Dec 7, 2022

Conversation

vito
Copy link
Contributor

@vito vito commented Dec 6, 2022

fixes #4104

Adds the following API:

extend type Directory {
  "This directory with all file/dir timestamps set to the given time, in seconds from the Unix epoch"
  withTimestamps(timestamp: Int!): Directory!
}

extend type File {
  "This file with its created/modified timestamps set to the given time, in seconds from the Unix epoch"
  withTimestamps(timestamp: Int!): File!
}

Bikeshedding opportunities:

  • withTimestamps name
  • timestamp param name
  • timestamp param type (should we have a UnixSeconds scalar? or just rename the param to unixSeconds?)

In hindsight there might be a less confusing name - we've got a plural withTimestamps yet a singular timestamp param. The name is plural because it modifies the contents recursively to a single timestamp.

One caveat: when mounting the Directory into a container the mountpoint itself won't have the desired timestamp. So if you do tar -cf - -C /dir . you'll still end up with an unstable tar archive because of the timestamp on /dir. I tried a few tricks with LLB but none of them worked. The workaround in this case is to just target the contents instead (* instead of .).

@vito vito marked this pull request as ready for review December 6, 2022 17:13
@vito
Copy link
Contributor Author

vito commented Dec 6, 2022

I sunk some time into turning timestamp: Int! into a proper date scalar represented by time.Time in Go, Date in JS, and datetime in Python, but I ended up backing out for now as the complexity is pretty high. I can dive back into it though if we're not happy with Int.

Copy link
Contributor

@sipsma sipsma left a comment

Choose a reason for hiding this comment

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

LGTM

core/schema/directory.graphqls Show resolved Hide resolved
fixes dagger#4104

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Alex Suraci <alex@dagger.io>
@vito vito changed the title Directory: add withTimestamps for normalizing file/dir timestamps Directory+File: add withTimestamps for normalizing file/dir timestamps Dec 7, 2022
@vito vito merged commit c26a7f3 into dagger:main Dec 7, 2022
@vito vito deleted the normalize-time branch December 7, 2022 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enforcing stable timestamps
2 participants