fermyon / cloud-plugin

A Spin plugin for the Spin CLI for managing Spin apps in Fermyon Cloud.
https://developer.fermyon.com/cloud/
Apache License 2.0
8 stars 13 forks source link

Non interactive databases take two #151

Closed itowlson closed 1 year ago

itowlson commented 1 year ago

This is another take on #125 (cf. #126). It's significantly more complicated than #126, but aims to be more explicit.

I am not delighted with the CLI experience in this initial draft. This looks like:

spin cloud deploy --link sqlite:default=* --link sqlite:monies=finance

Here the sqlite: prefix says what the label refers to (to allow for K/V or other resource linking in future), and * is a magic symbol for "create a new and link that". This is a lot more verbose than @kate-goldenring's example syntax in https://github.com/fermyon/cloud-plugin/pull/126#issuecomment-1749763854 and perhaps the future-proofing is too speculative, I'm not sure; and of course magic symbols are never great for discoverability.

That said, I'm optimistic about the principle of using a strategy object, and I think I've separated the CLI parsing reasonably cleanly from the strategy object itself, so maybe we can iterate on this and find an experience that folks are happy with?

(Oh yeah there are a whole lot more tests need writing but the mocks had turned my brain to sausage so I'll do them later.)

kate-goldenring commented 1 year ago

~@itowlson i haven't looked into the implementation yet but I am a little confused on what * means here:spin cloud deploy --link sqlite:default=*. How do we know which DB to link it to?~

You're amazing inline docs clear this up:

    /// do not exist will be created. To express "create a new database with
    /// a random name", use the special database '*'.
itowlson commented 1 year ago

chuickle but this does identify the non-obviousness of the syntax, especially since * means something different if it precedes the = sign.

I did wonder about using magic expressions such as sqlite:default=new(). I am not sure if that is better or worse. Or what the syntax for "for databases not explicitly listed..." would look like.

itowlson commented 1 year ago

@kate-goldenring updated