MCPcopy
hub / github.com/getsops/sops / NewMasterKeyFromURI

Function NewMasterKeyFromURI

hcvault/keysource.go:168–188  ·  view source on GitHub ↗

NewMasterKeyFromURI obtains the Vault address, Transit backend path and the key name from the full URI of the key.

(uri string)

Source from the content-addressed store, hash-verified

166// NewMasterKeyFromURI obtains the Vault address, Transit backend path and the
167// key name from the full URI of the key.
168func NewMasterKeyFromURI(uri string) (*MasterKey, error) {
169 var key *MasterKey
170 if uri == "" {
171 return key, nil
172 }
173 u, err := url.Parse(uri)
174 if err != nil {
175 return nil, err
176 }
177 if u.Scheme == "" {
178 return nil, fmt.Errorf("missing scheme in Vault URL (should be like this: +"+
179 "https://vault.example.com:8200/v1/transit/keys/keyName), got: %v", uri)
180 }
181 enginePath, keyName, err := engineAndKeyFromPath(u.RequestURI())
182 if err != nil {
183 return nil, err
184 }
185 u.Path = ""
186 return NewMasterKey(u.String(), enginePath, keyName), nil
187
188}
189
190// NewMasterKey creates a new MasterKey from a Vault address, Transit backend
191// path and a key name.

Callers 4

mainFunction · 0.92
extractMasterKeysFunction · 0.92
NewMasterKeysFromURIsFunction · 0.85
TestNewMasterKeyFromURIFunction · 0.85

Calls 3

engineAndKeyFromPathFunction · 0.85
NewMasterKeyFunction · 0.70
StringMethod · 0.45

Tested by 1

TestNewMasterKeyFromURIFunction · 0.68