-
Notifications
You must be signed in to change notification settings - Fork 242
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
Create bindles from Spin apps #90
Conversation
For those who want to have a go, the command is |
Looking at the generated parcel for [[parcel]]
[parcel.label]
sha256 = "b3bfcb3d92b9c2663a4f9c81e52720e6a68957ff40cd2fd55894fb2d67e3187b"
mediaType = "application/vnd.fermyon.spin+toml"
name = "/private/var/folders/rs/7g5937rn0sq1vyrtwf0_48140000gn/T/.tmpvaCd7h/manifests/spin.b3bfcb3d92b9c2663a4f9c81e52720e6a68957ff40cd2fd55894fb2d67e3187b.toml"
size = 181 |
Bumping into the following serialization issue:
Here is the full application manifest: name = "fermyon.com"
apiVersion = "0.1.0"
version = "1.0.0"
description = "The Fermyon website running on Spin."
authors = [ "Fermyon Engineering <engineering@fermyon.com>" ]
trigger = {type = "http", base = "/" }
[[component]]
source = "spin-bartholomew.wasm"
id = "bartholomew"
files = [ "content/**/*" , "templates/*", "scripts/*", "config/*"]
[component.trigger]
route = "/..."
[[component]]
source = "ffs.wasm"
id = "fileserver"
files = ["static/**/*"]
environment = { PATH_PREFIX = "static/" }
[component.trigger]
route = "/static/..." |
Effing Re the invoice - the |
The Rust client requires us to provide a parcel name (even though the spec says it's optional). And the BindleWriter (which has been moderately battle tested as part of Hippo) currently relies on the name to locate the source file. So this might be a slightly fiddly fix. |
The other one is because |
Trying to push the template application after the latest changes (accommodating for the missing ➜ spin bindle push --app spin.toml
Error: Failed to push bindle to server
Caused by:
Error pushing bindle to server: Error creating request (this worked previously) |
76cc930
to
2da0d0a
Compare
.with_context(|| format!("Failed to collect file mounts for {}", pattern)) | ||
}); | ||
let collections = results.into_iter().collect::<Result<Vec<_>>>()?; | ||
let collection = collections.into_iter().flatten().collect(); |
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 there a way to avoid the three iterations over the patterns here?
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.
- There probably is, but I haven't found it. The
into_iter
on 59 is redundant though, asresult
is already an iterator. We might need to create a customflatten_or_fail
combinator which I think I had in the Hippo CLI but essentially did the same thing! - Could you elaborate on what you hope to achieve by doing so? If you're thinking about performance, the file accesses will absolutely dwarf the traversal. If it's clarity of expression then that's a good reason but let's just wrap the current code up in a combinator.
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.
It was mainly clarity.
To be clear, this is by no means blocking.
impl BindleWriter { | ||
pub async fn write(&self) -> anyhow::Result<()> { | ||
// This is very similar to bindle::StandaloneWrite::write but... not quite the same | ||
let bindle_id_hash = self.invoice.bindle.id.sha(); |
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.
nit: is this variable binding used anywhere else?
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.
Yeah, it's used on the next line.
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.
(other than the next line that was)
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.
No, that's the only place it's used... but that's enough isn't it? Not sure what you're getting at here, sorry.
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.
Sorry, I should have been more clear to begin with.
As a personal preference, whenever there are variables that are only used once, I rethink whether there actually needs to be a variable binding there at all. In this case:
let bindle_dir = self.dest_dir.join(invoice.bindle.id.sha());
This is very nitpicky, don't feel like you have to take this into account.
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.
SO MANY PHILOSOPHICAL RIFTS
crates/publish/src/lib.rs
Outdated
|
||
pub use bindle_pusher::push_all; | ||
pub use bindle_writer::write; | ||
pub use expander::expand_app_manifest; |
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.
Given Bindle is the only implementation for this crate, would it make sense to drop the bindle_
prefix from the files? And if we do that, how about just push
, write
, expand
instead of the nouns?
(this is just a personal preference.)
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.
Manually tested with a rather complicated application, and everything seems to work great!
I left a bunch of comments, most of them rather nitpicky, and definitely nothing blocking.
This is awesome, thank you!
acbf9df
to
e7518c4
Compare
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.
Yaaay, this looks great, thank you SO much!
LGTM
8a44dcd
to
35f71e6
Compare
This is still WIP - it works, but it needs the new bindle loader that hasn't merged to main yet, and is unpleasantly coupled to the loader internals. We'll discuss how to mitigate that but in the meantime here it is for people to play with!