cmd/rofl/build: Validate image platform and size#488
Conversation
✅ Deploy Preview for oasisprotocol-cli canceled.
|
153ab78 to
a7ffd24
Compare
a7ffd24 to
8954ce5
Compare
|
The OCI manifest only specifies the compressed layer size, so this is kind of useless at the moment... For The only way to get the uncompressed size is to download and uncompress all the layers, which seems dumb. What to do? 🤔 |
|
OK, so after chatting with Matevž, the summary is that the most popular images, even compressed, exceed the default 512MB storage limit, so having this check is still useful. |
8954ce5 to
f8bf3f9
Compare
|
You could estimate that data is compressed and multiply by some factor. Obviously this will still be incorrect as it depends on entropy and other factors, but it could still be a better estimate. |
f8bf3f9 to
ea0587a
Compare
|
I've multiplied the final size by 2, which seems like a good estimate for the commonly-used images 🤷♂️ |
I can confirm that |
| // Validate platform if given. | ||
| platform := mainDescriptor.Platform | ||
| if platform != nil { | ||
| if platform.Architecture != "amd64" || platform.OS != "linux" { | ||
| return fmt.Errorf("compose file validation failed: image '%s' has incorrect platform (expected linux/amd64, got %s/%s)", imageFull, platform.OS, platform.Architecture) | ||
| } | ||
| } | ||
| platform = mf.Config.Platform | ||
| if platform != nil { | ||
| if platform.Architecture != "amd64" || platform.OS != "linux" { | ||
| return fmt.Errorf("compose file validation failed: image '%s' has incorrect platform (expected linux/amd64, got %s/%s)", imageFull, platform.OS, platform.Architecture) | ||
| } | ||
| } |
There was a problem hiding this comment.
Can't you deduplicate this code with
for platform := range map[string]string{mainDescriptor, mf.Config} {
...
}?
There was a problem hiding this comment.
No, because this code won't work, but I've done it in a similar way :)
ea0587a to
8870d9a
Compare
Closes #416.