added env variable

This commit is contained in:
ston1th 2023-03-21 01:18:48 +01:00
commit 1d5d900f26
2 changed files with 20 additions and 7 deletions

View file

@ -32,6 +32,19 @@ export KEYCTL_ENDPOINT=http://127.0.0.1:7070
./keyctl get -id aabbccddeeff... ./keyctl get -id aabbccddeeff...
``` ```
Get secret of type `shamir` with share via environment variable:
```
export KEYCTL_SHARE=aabbccddeeff...
./keyctl get -id aabbccddeeff...
```
Get secret of type `shamir` with share via commandline flag:
```
./keyctl get -id aabbccddeeff... -share aabbccddeeff...
```
## Usage ## Usage
``` ```

View file

@ -43,11 +43,8 @@ func Run(arg string) {
if err != nil { if err != nil {
exit(err) exit(err)
} }
switch k.Type { fmt.Println("Key ID:", k.ID)
case core.Plain: if k.Type == core.Shamir {
fmt.Println("Key ID:", k.ID)
case core.Shamir:
fmt.Println("Key ID:", k.ID)
fmt.Println("Key Share:", k.Key) fmt.Println("Key Share:", k.Key)
} }
case "del": case "del":
@ -94,11 +91,11 @@ func Run(arg string) {
if err != nil { if err != nil {
exit(err) exit(err)
} }
key.Key = out
if json { if json {
key.Key = out
jsonOutput(key) // does not return jsonOutput(key) // does not return
} }
fmt.Println(key.Key) fmt.Println(out)
case "ls": case "ls":
json := outputFlags() json := outputFlags()
c := client() c := client()
@ -164,6 +161,9 @@ func getFlags() (id, share string, json bool, err error) {
if id == "" { if id == "" {
err = errors.New("missing flag: id") err = errors.New("missing flag: id")
} }
if share == "" {
share = os.Getenv("KEYCTL_SHARE")
}
return return
} }