Debian Codegraph @

cmd/key.go

raw symbols SCIP
1 package cmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/
2
3 import (
4 "encoding/jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/"
5 "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/"
6 "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/"
7
8 intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/ "github.com/in-toto/in-toto-golang/in_totoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/"
9 "github.com/spf13/cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/"
10 )
11
12 var keyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyCmd. = &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
13 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "key",
14 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Key management commands",
15 }
16
17 var keyIDCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyIDCmd. = &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
18 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "id <file>",
19 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Output the key id for a given key",
20 Longscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Long.: "Output the key id for a given key",
21 Argsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Args.: cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.ExactArgsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/ExactArgs().(1),
22 RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE.: keyIDscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyID().,
23 }
24
25 var keyLayoutCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyLayoutCmd. = &cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#{
26 Usescip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Use.: "layout <file>",
27 Shortscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Short.: "Output the key layout for a given key in <KEYID>: <KEYOBJ> format",
28 Longscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Long.: "Output is a json formatted pubkey suitable for embedding in a layout file",
29 Argsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#Args.: cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.ExactArgsscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/ExactArgs().(1),
30 RunEscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#RunE.: keyLayoutscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyLayout().,
31 }
32
33 func initscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/init().() {
34 rootCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/rootCmd..AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(keyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyCmd.)
35
36 keyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyCmd..AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(keyIDCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyIDCmd.)
37 keyCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyCmd..AddCommandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#AddCommand().(keyLayoutCmdscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyLayoutCmd.)
38 }
39
40 func keyIDscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyID().(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#, args []string) error {
41 var key intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.Keyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#
42
43 err := key.LoadKeyDefaultsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#LoadKeyDefaults().(args[0])
44 if err != nil {
45 return err
46 }
47
48 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Printf().("%s\n", key.KeyIDscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#KeyID.)
49
50 return nil
51 }
52
53 func keyLayoutscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/cmd`/keyLayout().(cmd *cobrascip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/.Commandscip-go gomod github.com/spf13/cobra v1.10.2 `github.com/spf13/cobra`/Command#, args []string) error {
54 var key intotoscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/.Keyscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#
55
56 err := key.LoadKeyDefaultsscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#LoadKeyDefaults().(args[0])
57 if err != nil {
58 return err
59 }
60
61 // removed the private key from the struct such that it is not printed for use in the layout
62 key.KeyValscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#KeyVal..Privatescip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/KeyVal#Private. = ""
63
64 b, err := jsonscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/.Marshalscip-go gomod github.com/golang/go/src go1.24.0 `encoding/json`/Marshal().(key)
65 if err != nil {
66 return err
67 }
68
69 s2 := stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 strings/ReplaceAll().(string(b), `"private":"",`, "")
70 fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Printfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Printf().(`"%v": %s`, key.KeyIDscip-go gomod github.com/in-toto/in-toto-golang . `github.com/in-toto/in-toto-golang/in_toto`/Key#KeyID., s2)
71
72 return nil
73 }