Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit 1b26c30

Browse files
committed
Implement env read command
1 parent 3be71fc commit 1b26c30

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

internals/secrethub/env_read.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package secrethub
22

33
import (
4+
"fmt"
5+
46
"github.com/secrethub/secrethub-cli/internals/cli/ui"
57
"github.com/secrethub/secrethub-cli/internals/secrethub/command"
68
)
@@ -34,5 +36,24 @@ func (cmd *EnvReadCommand) Register(r command.Registerer) {
3436

3537
// Run handles the command with the options as specified in the command.
3638
func (cmd *EnvReadCommand) Run() error {
39+
env, err := cmd.environment.env()
40+
if err != nil {
41+
return err
42+
}
43+
44+
value, found := env[cmd.key]
45+
if !found {
46+
return fmt.Errorf("no environment variable with that key is set")
47+
}
48+
49+
secretReader := newSecretReader(cmd.newClient)
50+
51+
res, err := value.resolve(secretReader)
52+
if err != nil {
53+
return err
54+
}
55+
56+
fmt.Fprintln(cmd.io.Stdout(), res)
57+
3758
return nil
3859
}

0 commit comments

Comments
 (0)