MCPcopy
hub / github.com/helm/helm / NewFromKeyring

Function NewFromKeyring

pkg/provenance/sign.go:110–148  ·  view source on GitHub ↗

NewFromKeyring reads a keyring file and creates a Signatory. If id is not the empty string, this will also try to find an Entity in the keyring whose name matches, and set that as the signing entity. It will return an error if the id is not empty and also not found.

(keyringfile, id string)

Source from the content-addressed store, hash-verified

108// keyring whose name matches, and set that as the signing entity. It will return
109// an error if the id is not empty and also not found.
110func NewFromKeyring(keyringfile, id string) (*Signatory, error) {
111 ring, err := loadKeyRing(keyringfile)
112 if err != nil {
113 return nil, err
114 }
115
116 s := &Signatory{KeyRing: ring}
117
118 // If the ID is empty, we can return now.
119 if id == "" {
120 return s, nil
121 }
122
123 // We're gonna go all GnuPG on this and look for a string that _contains_. If
124 // two or more keys contain the string and none are a direct match, we error
125 // out.
126 var candidate *openpgp.Entity
127 vague := false
128 for _, e := range ring {
129 for n := range e.Identities {
130 if n == id {
131 s.Entity = e
132 return s, nil
133 }
134 if strings.Contains(n, id) {
135 if candidate != nil {
136 vague = true
137 }
138 candidate = e
139 }
140 }
141 }
142 if vague {
143 return s, fmt.Errorf("more than one key contain the id %q", id)
144 }
145
146 s.Entity = candidate
147 return s, nil
148}
149
150// PassphraseFetcher returns a passphrase for decrypting keys.
151//

Callers 7

VerifyChartFunction · 0.92
ClearsignMethod · 0.92
runMethod · 0.92
VerifyPluginFunction · 0.92
TestSignPluginFunction · 0.92
TestVerifyPluginFunction · 0.92
TestDecryptKeyFunction · 0.85

Calls 2

loadKeyRingFunction · 0.85
ContainsMethod · 0.80

Tested by 3

TestSignPluginFunction · 0.74
TestVerifyPluginFunction · 0.74
TestDecryptKeyFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…