Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
kdb-cli: rewrite meta-set
Browse files Browse the repository at this point in the history
... and (partial) fix #3742
  • Loading branch information
hannes99 committed Jul 11, 2023
1 parent 6134ad9 commit 6c90bd4
Show file tree
Hide file tree
Showing 85 changed files with 470 additions and 483 deletions.
4 changes: 2 additions & 2 deletions doc/GETSTARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Note that the value is empty since we just want to specify the key.
Now let's show the actual power of Elektra by setting metadata to our specification:

```sh
sudo kdb meta-set "spec:/example/hello/what" default World
sudo kdb meta set "spec:/example/hello/what" default World
```

The metakey `default` (having the value `World`) is now associated with the key `spec:/example/hello/what`.
Expand All @@ -130,7 +130,7 @@ It should be noted that the previous setting of `what` is in this scenario redun
Now let's mount our specification:

```sh
sudo kdb meta-set "spec:/example/hello" mountpoint "hello.ni"
sudo kdb meta set "spec:/example/hello" mountpoint "hello.ni"
sudo kdb spec-mount "/example/hello" ni
```

Expand Down
2 changes: 1 addition & 1 deletion doc/help/elektra-cascading.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ They can be used like this:

```sh
kdb set /overrides/test "example override"
sudo kdb meta-set spec:/test override/#0 /overrides/test
sudo kdb meta set spec:/test override/#0 /overrides/test
```

## CASCADING
Expand Down
2 changes: 1 addition & 1 deletion doc/help/kdb-get.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ sudo kdb mount get.ecf spec:/tests/get/examples/kdb-get dump

# Create the keys we use for the examples
kdb set user:/tests/get/examples/kdb-get/key myKey
kdb meta-set spec:/tests/get/examples/kdb-get/anotherKey default defaultValue
kdb meta set spec:/tests/get/examples/kdb-get/anotherKey default defaultValue

# To get the value of a key:
kdb get user:/tests/get/examples/kdb-get/key
Expand Down
10 changes: 5 additions & 5 deletions doc/help/kdb-meta-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## SYNOPSIS

`kdb meta-set <key name> <metaname> [<metavalue>]`
`kdb meta set <key name> <metaname> [<metavalue>]`

Where `key name` is the name of the key that the metakey is associated with,
`metaname` is the name of the metakey the user would like to set the value of (or create),
Expand Down Expand Up @@ -56,23 +56,23 @@ This command will return the following values as an exit status:<br>
## EXAMPLES

To set a metakey called `description` associated with the key `user:/example/key` to the value `Hello World!`:<br>
`kdb meta-set spec:/example/key description "Hello World!"`
`kdb meta set spec:/example/key description "Hello World!"`

To create a new key `spec:/example/newkey` with a null value (if it did not exist before)
and a metakey `namespace/#0` associated with it to the value `system`:<br>
`kdb meta-set /example/newkey "namespace/#0" system`
`kdb meta set /example/newkey "namespace/#0" system`

To create an override link for a `/test` key:

```sh
kdb set /overrides/test "example override"
sudo kdb meta-set spec:/test override/#0 /overrides/test
sudo kdb meta set spec:/test override/#0 /overrides/test
```

To remove it:

```sh
sudo kdb meta-set spec:/test override/#0
sudo kdb meta set spec:/test override/#0
```

## SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions doc/help/kdb-meta-show.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ sudo kdb mount ls.ecf user:/tests/examples dump

# Create the keys we use for the examples
kdb set user:/tests/examples/kdb-meta-show test
kdb meta-set user:/tests/examples/kdb-meta-show meta1 val1
kdb meta-set user:/tests/examples/kdb-meta-show meta2 val2
kdb meta-set user:/tests/examples/kdb-meta-show meta3 val3
kdb meta-set user:/tests/examples/kdb-meta-show meta4 val4
kdb meta set user:/tests/examples/kdb-meta-show meta1 val1
kdb meta set user:/tests/examples/kdb-meta-show meta2 val2
kdb meta set user:/tests/examples/kdb-meta-show meta3 val3
kdb meta set user:/tests/examples/kdb-meta-show meta4 val4

# list all meta keys for /tests/examples/kdb-meta-show
kdb meta-show /tests/examples/kdb-meta-show
Expand Down
2 changes: 1 addition & 1 deletion doc/man/man1/kdb-get.1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sudo kdb mount get\.ecf spec:/tests/get/examples/kdb\-get dump

# Create the keys we use for the examples
kdb set user:/tests/get/examples/kdb\-get/key myKey
kdb meta\-set spec:/tests/get/examples/kdb\-get/anotherKey default defaultValue
kdb meta set spec:/tests/get/examples/kdb\-get/anotherKey default defaultValue

# To get the value of a key:
kdb get user:/tests/get/examples/kdb\-get/key
Expand Down
10 changes: 5 additions & 5 deletions doc/man/man1/kdb-meta-set.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH "NAME"
\fBkdb\-meta\-set\fR \- Set the value of a metakey
.SH "SYNOPSIS"
\fBkdb meta\-set <key name> <metaname> [<metavalue>]\fR
\fBkdb meta set <key name> <metaname> [<metavalue>]\fR
.P
Where \fBkey name\fR is the name of the key that the metakey is associated with, \fBmetaname\fR is the name of the metakey the user would like to set the value of (or create), and \fBmetavalue\fR is the value the user wishes to set the metakey to\. If no \fBmetavalue\fR is given, the metakey will be removed\.
.SH "DESCRIPTION"
Expand Down Expand Up @@ -55,24 +55,24 @@ Same as \fB\-q\fR: Suppress default messages\.
.SH "EXAMPLES"
To set a metakey called \fBdescription\fR associated with the key \fBuser:/example/key\fR to the value \fBHello World!\fR:
.br
\fBkdb meta\-set spec:/example/key description "Hello World!"\fR
\fBkdb meta set spec:/example/key description "Hello World!"\fR
.P
To create a new key \fBspec:/example/newkey\fR with a null value (if it did not exist before) and a metakey \fBnamespace/#0\fR associated with it to the value \fBsystem\fR:
.br
\fBkdb meta\-set /example/newkey "namespace/#0" system\fR
\fBkdb meta set /example/newkey "namespace/#0" system\fR
.P
To create an override link for a \fB/test\fR key:
.IP "" 4
.nf
kdb set /overrides/test "example override"
sudo kdb meta\-set spec:/test override/#0 /overrides/test
sudo kdb meta set spec:/test override/#0 /overrides/test
.fi
.IP "" 0
.P
To remove it:
.IP "" 4
.nf
sudo kdb meta\-set spec:/test override/#0
sudo kdb meta set spec:/test override/#0
.fi
.IP "" 0
.SH "SEE ALSO"
Expand Down
8 changes: 4 additions & 4 deletions doc/man/man1/kdb-meta-show.1
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ sudo kdb mount ls\.ecf user:/tests/examples dump

# Create the keys we use for the examples
kdb set user:/tests/examples/kdb\-meta\-show test
kdb meta\-set user:/tests/examples/kdb\-meta\-show meta1 val1
kdb meta\-set user:/tests/examples/kdb\-meta\-show meta2 val2
kdb meta\-set user:/tests/examples/kdb\-meta\-show meta3 val3
kdb meta\-set user:/tests/examples/kdb\-meta\-show meta4 val4
kdb meta set user:/tests/examples/kdb\-meta\-show meta1 val1
kdb meta set user:/tests/examples/kdb\-meta\-show meta2 val2
kdb meta set user:/tests/examples/kdb\-meta\-show meta3 val3
kdb meta set user:/tests/examples/kdb\-meta\-show meta4 val4

# list all meta keys for /tests/examples/kdb\-meta\-show
kdb meta\-show /tests/examples/kdb\-meta\-show
Expand Down
4 changes: 2 additions & 2 deletions doc/man/man7/elektra-cascading.7
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.10.1
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1.pre3
.TH "ELEKTRA\-CASCADING" "7" "November 2021" ""
.TH "ELEKTRA\-CASCADING" "7" "May 2023" ""
.SH "NAME"
\fBelektra\-cascading\fR \- of key names
.P
Expand All @@ -25,7 +25,7 @@ They can be used like this:
.IP "" 4
.nf
kdb set /overrides/test "example override"
sudo kdb meta\-set spec:/test override/#0 /overrides/test
sudo kdb meta set spec:/test override/#0 /overrides/test
.fi
.IP "" 0
.SH "CASCADING"
Expand Down
2 changes: 1 addition & 1 deletion doc/todo/PLUGINS
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ logging API:
implement semlock plugin, see commit bc8b5d66bd4babba6bc8c34804b966daf6878a1d

inherit/copy metadata/bind mounts:
kdb meta-set spec:/something inherit/override/# '"/elsewhere/key/" + basename'
kdb meta set spec:/something inherit/override/# '"/elsewhere/key/" + basename'
und ein inherit-Plugin kopiert dann automatisch ein override /elsewhere/key/ (mit dem richtigen basename dran) in alle Subkeys (die nicht ein anderes inherit/override haben).

werror plugin:
Expand Down
2 changes: 1 addition & 1 deletion doc/todo/TOOLS
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ generic fstab:
allows kdb mset fstab <args> to be the same as kdb fstab

kdb tool should work with arrays (add_entry, remove_entry)
or also kdb meta-set user:/abc check/enum -a "first enum" "second enum" "third enum"
or also kdb meta set user:/abc check/enum -a "first enum" "second enum" "third enum"
or also kdb set user:/abc -a "first array entry" "second" "third array entry"
allow key array increments with kdb tool

Expand Down
4 changes: 2 additions & 2 deletions doc/tutorials/application-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ You can use those features like following:

```sh
kdb set /overrides/test "example override"
sudo kdb meta-set spec:/test override/#0 /overrides/test
sudo kdb meta set spec:/test override/#0 /overrides/test
```

This technique provides complete transparency how a program will fetch a
Expand All @@ -260,7 +260,7 @@ we want to use `/sw/otherorg/otherapp/#0/current/section/subsection/key`.
So we specify:

```sh
kdb meta-set spec:/sw/org/myapp/#0/current/section/subsection/key \
kdb meta set spec:/sw/org/myapp/#0/current/section/subsection/key \
"fallback/#0" /sw/otherorg/otherapp/#0/current/section/subsection/key
```

Expand Down
6 changes: 3 additions & 3 deletions doc/tutorials/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ For an **empty array** (`[]`) we just add the [metakey](../help/elektra-metadata

```sh
# Create an empty array with the name `user:/tests/sequence`
kdb meta-set user:/tests/sequence array ''
kdb meta set user:/tests/sequence array ''
```

.
Expand Down Expand Up @@ -100,7 +100,7 @@ This of course works only, if the plugins already stores this information in the
- implicitly (e.g. the data below the array parent is stored as array/list/sequence in the config file), or
- explicitly (e.g. the plugin stores the metakey `array` directly in the config file)

. Either way, in some situations you might have to add this value manually via `kdb meta-set`:
. Either way, in some situations you might have to add this value manually via `kdb meta set`:

```sh
# Add array elements
Expand All @@ -112,7 +112,7 @@ kdb set user:/tests/favorites/superheros/#99999 'The guy with the bow and arrow'
#> Create a new key user:/tests/favorites/superheros/#____99999 with string "The guy with the bow and arrow"

# The metakey `array` should save the basename of the last element.
kdb meta-set user:/tests/favorites/superheros array '#99999'
kdb meta set user:/tests/favorites/superheros array '#99999'
```

. This way you can always retrieve the last element of an array easily:
Expand Down
6 changes: 5 additions & 1 deletion doc/tutorials/cascading.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ For example,
kdb set /tests/tutorial/cascading/key1 "hello world"
# RET: 2
# STDERR: .*key does not specify a namespace

kdb meta set /tests/tutorial/cascading/key1 meta1 hello
# RET: 2
# STDERR: .*key does not specify a namespace
```

## Override Links
Expand Down Expand Up @@ -136,7 +140,7 @@ sudo kdb set system:/tests/overrides/test "hello override"
Override links can be defined by adding them to the `override/#` metadata array key of the corresponding `spec-key`:

```sh
sudo kdb meta-set spec:/tests/tutorial/cascading/#0/current/test override/#0 /tests/overrides/test
sudo kdb meta set spec:/tests/tutorial/cascading/#0/current/test override/#0 /tests/overrides/test
```

Now when doing a cascading lookup, we get the value of our target key instead of the specified one:
Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/crypto.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ We want to protect the password, that is stored under `user:/test/password`.
So we set the metakey as follows:

```bash
kdb meta-set user:/tests/password crypto/encrypt 1
kdb meta set user:/tests/password crypto/encrypt 1
```

Now we are safe to set the actual password:
Expand Down Expand Up @@ -240,7 +240,7 @@ As a result you get "1234".
You can disable the encryption by setting `crypto/encrypt` to a value other than `1`, for example:

```bash
kdb meta-set user:/tests/password crypto/encrypt 0
kdb meta set user:/tests/password crypto/encrypt 0
```

### Complete Example
Expand All @@ -249,7 +249,7 @@ The complete example looks like this:

```sh
kdb mount test.ini user:/tests crypto "crypto/key=$(kdb gen-gpg-testkey)" base64 ini
kdb meta-set user:/tests/password crypto/encrypt 1
kdb meta set user:/tests/password crypto/encrypt 1
kdb set user:/tests/password 1234
kdb set user:/tests/unencrypted "I am not encrypted"
kdb file user:/tests/password | xargs cat
Expand All @@ -258,7 +258,7 @@ kdb file user:/tests/password | xargs cat
To disable encryption on `user:/tests/password`, we can run:

```sh
kdb meta-set user:/tests/password crypto/encrypt 0
kdb meta set user:/tests/password crypto/encrypt 0
kdb file user:/tests/password | xargs cat
```

Expand Down
Loading

0 comments on commit 6c90bd4

Please sign in to comment.