MCPcopy Index your code
hub / github.com/getsops/sops / UserError

Method UserError

usererrors.go:44–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func (err *getDataKeyError) UserError() string {
45 var groupErrs []string
46 for i, res := range err.GroupResults {
47 groupErr := decryptGroupError{
48 err: res,
49 groupName: fmt.Sprintf("%d", i),
50 }
51 groupErrs = append(groupErrs, groupErr.UserError())
52 }
53 var trailer string
54 if err.RequiredSuccessfulKeyGroups == 0 {
55 trailer = "Recovery failed because no master key was able to decrypt " +
56 "the file. In order for SOPS to recover the file, at least one key " +
57 "has to be successful, but none were."
58 } else {
59 trailer = fmt.Sprintf("Recovery failed because the file was "+
60 "encrypted with a Shamir threshold of %d, but only %d part(s) "+
61 "were successfully recovered, one for each successful key group. "+
62 "In order for SOPS to recover the file, at least %d groups have "+
63 "to be successful. In order for a group to be successful, "+
64 "decryption has to succeed with any of the keys in that key group.",
65 err.RequiredSuccessfulKeyGroups, err.successfulKeyGroups(),
66 err.RequiredSuccessfulKeyGroups)
67 }
68 trailer = wordwrap.WrapString(trailer, 75)
69 return fmt.Sprintf("Failed to get the data key required to "+
70 "decrypt the SOPS file.\n\n%s\n\n%s",
71 strings.Join(groupErrs, "\n\n"), trailer)
72}
73
74type decryptGroupError struct {
75 groupName string

Callers

nothing calls this directly

Calls 2

UserErrorMethod · 0.95
successfulKeyGroupsMethod · 0.95

Tested by

no test coverage detected