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

Function decrypt

cmd/sops/decrypt.go:56–73  ·  view source on GitHub ↗
(opts decryptOpts)

Source from the content-addressed store, hash-verified

54}
55
56func decrypt(opts decryptOpts) (decryptedFile []byte, err error) {
57 tree, err := decryptTree(opts)
58 if err != nil {
59 return nil, err
60 }
61
62 if len(opts.Extract) > 0 {
63 return extract(tree, opts.Extract, opts.OutputStore)
64 }
65 decryptedFile, err = opts.OutputStore.EmitPlainFile(tree.Branches)
66 if errors.Is(err, json.BinaryStoreEmitPlainError) {
67 err = fmt.Errorf("%s\n\n%s", err.Error(), notBinaryHint)
68 }
69 if err != nil {
70 return nil, common.NewExitError(fmt.Sprintf("Error dumping file: %s", err), codes.ErrorDumpingTree)
71 }
72 return decryptedFile, err
73}
74
75func extract(tree *sops.Tree, path []interface{}, outputStore sops.Store) (output []byte, err error) {
76 v, err := tree.Branches[0].Truncate(path)

Callers 1

mainFunction · 0.85

Calls 5

NewExitErrorFunction · 0.92
decryptTreeFunction · 0.85
extractFunction · 0.85
EmitPlainFileMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected