Skip to content
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

feat(kv): support setting key/value pairs #171

Merged

Conversation

kate-goldenring
Copy link
Collaborator

@kate-goldenring kate-goldenring commented Jan 19, 2024

Adds spin cloud key-value set command:

  • Set kv pair with store as identifier spin cloud key-value set --store "foo"
  • With link identifier spin cloud key-value set --label "foo" --app "myapp"
    Comparable to spin cloud sqlite execute command

The cloud API does not yet expose delete and list pairs endpoints, but once it does, I'll add them

Copy link
Contributor

@rylev rylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - I think this would also benefit from some general refactoring, but that should be done after this is merged.

@@ -74,6 +79,29 @@ impl From<GroupBy> for ResourceGroupBy {
}
}

#[derive(Parser, Debug)]
pub struct SetCommand {
/// The name of the key value store
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if Clap is smart enough to show the user that if they don't set this they have to set the app/label. If not, can we document that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some small adjustments (some conflicts withs), and it detects and tells the user when they have miscombined the flags. For example:

Kates-MacBook-Pro :: ~/Programs/cloud-plugin 2 » cargo run -- kv set --app a          
    Finished dev [unoptimized + debuginfo] target(s) in 0.16s
     Running `target/debug/cloud-plugin kv set --app a`
error: The following required arguments were not provided:
    --label <LABEL>

USAGE:

And:

Kates-MacBook-Pro :: ~/Programs/cloud-plugin 2 » cargo run -- kv set --store s --app a 
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/cloud-plugin kv set --store s --app a`
error: The argument '--store <STORE>' cannot be used with '--app <APP>'

USAGE:
    spin cloud key-value set --store <STORE>

For more information try --help

src/commands/key_value.rs Outdated Show resolved Hide resolved
src/commands/links_execute.rs Outdated Show resolved Hide resolved
Signed-off-by: Kate Goldenring <kate.goldenring@fermyon.com>
@kate-goldenring kate-goldenring merged commit 65433f5 into fermyon:main Jan 19, 2024
8 checks passed
@kate-goldenring kate-goldenring deleted the kv-subcommand-for-kv-pairs branch January 19, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants