File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
internal/namespaces/secret/v1beta1 Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ package secret
2
+
3
+ import (
4
+ "context"
5
+
6
+ "github.com/scaleway/scaleway-cli/v2/internal/core"
7
+ secret "github.com/scaleway/scaleway-sdk-go/api/secret/v1beta1"
8
+ )
9
+
10
+ func GetCommands () * core.Commands {
11
+ cmds := GetGeneratedCommands ()
12
+
13
+ cmds .MustFind ("secret" , "version" , "create" ).Override (dataCreateVersion )
14
+ cmds .MustFind ("secret" , "version" , "access" ).Override (secretVersionAccessCommand )
15
+ return cmds
16
+ }
17
+
18
+ func dataCreateVersion (c * core.Command ) * core.Command {
19
+ * c .ArgSpecs .GetByName ("data" ) = core.ArgSpec {
20
+ Name : "data" ,
21
+ Short : "Content of the secret version. Base64 is handled by the SDK" ,
22
+ Required : true ,
23
+ CanLoadFile : true ,
24
+ }
25
+ return c
26
+ }
27
+
28
+ func secretVersionAccessCommand (c * core.Command ) * core.Command {
29
+ c .Run = func (ctx context.Context , args interface {}) (i interface {}, e error ) {
30
+ request := args .(* secret.AccessSecretVersionRequest )
31
+
32
+ client := core .ExtractClient (ctx )
33
+ api := secret .NewAPI (client )
34
+ res , err := api .AccessSecretVersion (request )
35
+
36
+ if err != nil {
37
+ return nil , err
38
+ }
39
+
40
+ return core .RawResult (res .Data ), nil
41
+ }
42
+
43
+ return c
44
+ }
You can’t perform that action at this time.
0 commit comments