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

flux kvs get/put need type-hint options #1159

Closed
garlick opened this issue Aug 22, 2017 · 2 comments
Closed

flux kvs get/put need type-hint options #1159

garlick opened this issue Aug 22, 2017 · 2 comments
Assignees

Comments

@garlick
Copy link
Member

garlick commented Aug 22, 2017

The flux kvs get command presumes that all values are JSON. That assumption no longer holds after PR #1154.

Usage: flux-kvs get key [key...]
Get value stored under key
  -h, --help             Display this message.

We could add --raw and --json options. If neither is specified, first attempt to decode as JSON, and if that fails, presume raw.

Also, supporting multiple keys on the command line doesn't really work now, since values are separated by a newline, and values can contain a newline. With raw data, this becomes even less useful, so we should probably not allow it.

The flux kvs put command assumes values are JSON, with a fallback to convert to a JSON string if the value doesn't decode as valid JSON.

Usage: flux-kvs put key=value [key=value...]
Store value under key
  -h, --help             Display this message.

Here again, let's support only a single key, and add --json and --raw options. To support redirecting raw data from stdin, if =value is missing, stdin should be used. The fallback JSON string behavior should be eliminated.

@garlick
Copy link
Member Author

garlick commented Aug 22, 2017

Actually, I wonder if we should just have a --json option and presume raw if not specified? That reflects the way the KVS actually works after #1158. Also I should have noted that we'll need the raw txn/lookup functions that we decided to defer to another PR after #1158.

@grondo
Copy link
Contributor

grondo commented Aug 22, 2017

Actually, I wonder if we should just have a --json option and presume raw if not specified?

I like this approach, though it is a change from how the command has always worked. However, long term it seems like the most reasonable UI for the command.

@chu11 chu11 mentioned this issue Aug 22, 2017
@garlick garlick self-assigned this Aug 25, 2017
garlick added a commit to garlick/flux-core that referenced this issue Oct 24, 2017
Problem:  flux-kvs put presumes values should be stored as JSON,
but the KVS no longer requires this.

Add type options to allow the user to choose how values are stored.

If no options, value is stored as a NULL terminated string.

If --raw, value is stored as with no options, but without a
NULL terminator.

If --json, value is stored as a NULL terminated string if it
is valid encoded JSON; otherwise it is first encoded as a JSON
string.  This mimics the old default behavior of flux-kvs put
that is expected by many tests in t1000-kvs.t and t1002-kvs-extra.t.

Add --json to flux kvs put where used in various sharness tests.

Partial fix to flux-framework#1159.
garlick added a commit to garlick/flux-core that referenced this issue Oct 24, 2017
Problem:  flux-get put presumes values should be interpreted as JSON,
but the KVS no longer requires this.

Add type options mirroring those added to the "put" subcommand
to allow the user to choose how values are interpreted.

If no options, value is interpreted as a NULL terminated string
and written to stdout with a newline.

If --raw, value is interpreted as raw data and is written to
stdout without any formatting.

If --json, value is interpreted as encoded JSON.  If the value is an
object or array, or any scalar type but string, it is displayed
in its encoded form.  If the value is a JSON strong, quotes are
removed, which mimics the old default behavior of flux-kvs get
expected by many sharness tests.

Add --json to flux kvs get where used in various sharness tests.

Fixes flux-framework#1159
garlick added a commit to garlick/flux-core that referenced this issue Oct 25, 2017
Problem:  flux-kvs put presumes values should be stored as JSON,
but the KVS no longer requires this.

Add type options to allow the user to choose how values are stored.

If no options, value is stored as a NULL terminated string.

If --raw, value is stored as with no options, but without a
NULL terminator.

If --json, value is stored as a NULL terminated string if it
is valid encoded JSON; otherwise it is first encoded as a JSON
string.  This mimics the old default behavior of flux-kvs put
that is expected by many tests in t1000-kvs.t and t1002-kvs-extra.t.

Add --json to flux kvs put where used in various sharness tests.

Partial fix to flux-framework#1159.
garlick added a commit to garlick/flux-core that referenced this issue Oct 25, 2017
Problem:  flux-get put presumes values should be interpreted as JSON,
but the KVS no longer requires this.

Add type options mirroring those added to the "put" subcommand
to allow the user to choose how values are interpreted.

If no options, value is interpreted as a NULL terminated string
and written to stdout with a newline.

If --raw, value is interpreted as raw data and is written to
stdout without any formatting.

If --json, value is interpreted as encoded JSON.  If the value is an
object or array, or any scalar type but string, it is displayed
in its encoded form.  If the value is a JSON strong, quotes are
removed, which mimics the old default behavior of flux-kvs get
expected by many sharness tests.

Add --json to flux kvs get where used in various sharness tests.

Fixes flux-framework#1159
garlick added a commit to garlick/flux-core that referenced this issue Oct 26, 2017
Problem:  flux-kvs put presumes values should be stored as JSON,
but the KVS no longer requires this.

Add type options to allow the user to choose how values are stored.

If no options, value is stored as a NULL terminated string.

If --raw, value is stored as with no options, but without a
NULL terminator.

If --json, value is stored as a NULL terminated string if it
is valid encoded JSON; otherwise it is first encoded as a JSON
string.  This mimics the old default behavior of flux-kvs put
that is expected by many tests in t1000-kvs.t and t1002-kvs-extra.t.

Add --json to flux kvs put where used in various sharness tests.

Partial fix to flux-framework#1159.
garlick added a commit to garlick/flux-core that referenced this issue Oct 26, 2017
Problem:  flux-get put presumes values should be interpreted as JSON,
but the KVS no longer requires this.

Add type options mirroring those added to the "put" subcommand
to allow the user to choose how values are interpreted.

If no options, value is interpreted as a NULL terminated string
and written to stdout with a newline.

If --raw, value is interpreted as raw data and is written to
stdout without any formatting.

If --json, value is interpreted as encoded JSON.  If the value is an
object or array, or any scalar type but string, it is displayed
in its encoded form.  If the value is a JSON string, quotes are
removed, which mimics the old default behavior of flux-kvs get
expected by many sharness tests.

Add --json to flux kvs get where used in various sharness tests.

Fixes flux-framework#1159
garlick added a commit to garlick/flux-core that referenced this issue Oct 26, 2017
Problem:  flux-kvs put presumes values should be stored as JSON,
but the KVS no longer requires this.

Add type options to allow the user to choose how values are stored.

If no options, value is stored as a NULL terminated string.

If --raw, value is stored as with no options, but without a
NULL terminator.  For --raw mode only, key=- may be used to
take read value from stdin.

If --json, value is stored as a NULL terminated string if it
is valid encoded JSON; otherwise it is first encoded as a JSON
string.  This mimics the old default behavior of flux-kvs put
that is expected by many tests in t1000-kvs.t and t1002-kvs-extra.t.

Add --json to flux kvs put where used in various sharness tests.

Partial fix to flux-framework#1159.
@chu11 chu11 closed this as completed in 2892d92 Oct 26, 2017
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

No branches or pull requests

2 participants