Allow pulling partial layer chains from an image - #2795
Conversation
| } | ||
|
|
||
| if ll := info.layerLimit; ll != nil { | ||
| attrs[pb.AttrImageLayerLimit] = strconv.FormatInt(int64(*ll), 10) |
There was a problem hiding this comment.
Probably worth setting this as a uint or just enforcing that it's not negative.
There was a problem hiding this comment.
In attrs it is a string. I don't want to set WithLayerLimit to uint as then it will require casting on every usage. I've added validation on the server-side to make sure the value is positive.
| require.Equal(t, exbi.Sources[0].Ref, "docker.io/library/busybox:latest") | ||
| } | ||
|
|
||
| func testPullWithLayerLimit(t *testing.T, sb integration.Sandbox) { |
There was a problem hiding this comment.
Worth adding a quick test in here that setting the limit to 0 doesn't break anything, also some of the other corner cases like that an error is returned when limit is greater than layers in the image.
| OS string | ||
| Arch string | ||
| Variant string `json:",omitempty"` | ||
| Limit *int `json:",omitempty"` |
There was a problem hiding this comment.
a nil Limit will be encoded as a json null value, so does that mean that anyone upgrading to a Buildkit with this feature will get cache misses on already pulled images due to the fact that the cache key changed here? Not exactly the end of the world if so, just making sure that's alright.
There was a problem hiding this comment.
"omitempty" in here takes care of that. Key only changes if the limit is set.
Adds a new `WithLayerLimit` option to `llb.Image` only pulls specified number of layers instead of full image. This can be used in combination with DiffOp/MergeOp to pull any subset of layers from an image in any order. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Adds a new
WithLayerLimitoption tollb.Imageonly pulls specified number of layers instead of
full image.
This can be used in combination with DiffOp/MergeOp
to pull any subset of layers from an image in any order.
Signed-off-by: Tonis Tiigi tonistiigi@gmail.com