(opts decryptOpts)
| 54 | } |
| 55 | |
| 56 | func 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 | |
| 75 | func extract(tree *sops.Tree, path []interface{}, outputStore sops.Store) (output []byte, err error) { |
| 76 | v, err := tree.Branches[0].Truncate(path) |
no test coverage detected