-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support creating required KV stores during application deploys #170
Support creating required KV stores during application deploys #170
Conversation
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.
This is a tricky one! I did feel a bit "you are lost in a maze of twisty things called resource, all alike" at times, but I don't have a better name (and if I did it would be outside the scope of this PR), and streamlining the "similar but not quite the same enough" bits that make it challenging to follow would take a significant refactor, which I don't think should hold up this PR. Anyway, I left some suggestions but I'm happy to defer most of the style ones to a later refactor - there is one on line 1058 (and surrounding areas) which I care about, and a couple of things I think might be leftovers, but the rest are nits / think-out-louds.
So, sorry for maundering at you, and LGTM!
src/commands/deploy/database.rs
Outdated
} | ||
ResourceType::KeyValueStore => { | ||
client | ||
.create_key_value_store(&r, Some(resource_label)) |
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.
I'm curious why this takes &r
and the SQLite arms takes r.clone()
. Is the API inconsistent or should it have been &db
in the previous 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.
the create APIs for KV and SQL are inconsistent. The SQL one sends db name in the body of the request while the KV one is updated to send the name in the path. I am hoping down the line to update the sql one to be at parity with KV
.await | ||
.with_context(|| { | ||
format!( | ||
r#"Could not link {resource_type} "{}" to app "{}""#, |
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.
Oh man... the nesting is getting a bit much for me - I find it hard to keep my mental stack when it gets this deep. Maybe that's a matter for a later refactor though.
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.
I think I agree with @itowlson here in that this is fine for us to land for now, but it's becoming very clear that a refactor is in order.
src/commands/deploy.rs
Outdated
.is_none() | ||
{ | ||
// User canceled terminal interaction | ||
// TODO: Clean up created databases and kv stores |
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 this something we need to tackle before we merge this PR?
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.
I don't think so because we also do not cleanup for SQL and users have the ability to use the CLI to clean up resources with other CLI commands. I'd like to expose get_limit
endpoints in the cloud API to support knowing a users limit before we start this flow in case they hit their max on a resource.
@@ -1,80 +1,110 @@ | |||
// TODO(kate): rename this module to something more generic like `resource` |
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 reason to not do this now? Renaming modules tends to be a pretty straight forward refactor.
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.
I call this out in the PR description. I didn't want to rename it and make it hard to discern the changes.
Signed-off-by: Kate Goldenring <[email protected]>
Signed-off-by: Kate Goldenring <[email protected]>
869f3ed
to
9a4981a
Compare
Updates the
deploy
flow to prompt and create KV stores for an application. The flow matches that of SQL, and I updated the code to share most of the code across SQL and KV using the term inside thedatabase.rs
module. This file should be renamed toresource.rs
in a subsequent PR. I didn't want to rename it and make it hard to discern the changes.Note that the
deploy --key-values
flag only applies to the default store. Should we introduce a way to set pairs during deploy or deprecate this flag and instead instruct them to use thespin cloud kv set
(#171) command to set pairs?TODOs for later PRs:
database.rs
toresource.rs