-
Notifications
You must be signed in to change notification settings - Fork 12
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
Commit history matching Buildkit's Dockerfile2LLB logic #235
Conversation
codegen/builtin_fs.go
Outdated
img.History = append(img.History, specs.History{ | ||
CreatedBy: fmt.Sprintf(format, a...), | ||
Comment: HistoryComment, | ||
EmptyLayer: true, |
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.
Is it correct for EmptyLayer
to always be true? Is the implication that the downstream tools don't really pay attention to it? (Still, wondering if false
would be safer.)
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.
EmptyLayer should be false
for RUN
, COPY
, ADD
, but true
for everything else. Let me see if I can add history for copy
as well.
codegen/builtin_fs.go
Outdated
|
||
numHistory := len(fs.Image.History) | ||
if numHistory > 0 && strings.HasPrefix(fs.Image.History[numHistory-1].CreatedBy, "LABEL") { | ||
fs.Image.History[numHistory-1].CreatedBy = fmt.Sprintf("%s %s=%s", fs.Image.History[numHistory-1].CreatedBy, key, value) |
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.
Can you explain why we replace rather than append the label in this case? It might be worth a comment in the code.
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.
In Dockerfile it is LABEL key=value key2=value2 ...
whereas in HLB it is fs label(string key, string value)
singular. So we need to merge to produce the same history.
I also tested LABEL samekey=foo samekey=bar
with Dockerfile and it does show up as is in the history without deduplication.
Will add a comment.
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.
Ah, I missed that we were including the existing contents. How about this to make it slightly more obvious and succinct:
fs.Image.History[numHistory-1].CreatedBy = fmt.Sprintf("%s %s=%s", fs.Image.History[numHistory-1].CreatedBy, key, value) | |
fs.Image.History[numHistory-1].CreatedBy += fmt.Sprintf(" %s=%s", key, value) |
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.
LGTM
Only other thought is whether there's a convenient place to add test assertions that the correct history entries are generate...
Filed an issue tracking history tests: #236 |
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.
lgtm
Some external systems depends on history to exist for things like labels.
For context, the history comment from buildkit is
buildkit.dockerfile.v0
.Example: