(opts editExampleOpts)
| 48 | } |
| 49 | |
| 50 | func editExample(opts editExampleOpts) ([]byte, error) { |
| 51 | fileBytes := opts.InputStore.EmitExample() |
| 52 | branches, err := opts.InputStore.LoadPlainFile(fileBytes) |
| 53 | if err != nil { |
| 54 | return nil, common.NewExitError(fmt.Sprintf("Error unmarshalling file: %s", err), codes.CouldNotReadInputFile) |
| 55 | } |
| 56 | path, err := filepath.Abs(opts.InputPath) |
| 57 | if err != nil { |
| 58 | return nil, err |
| 59 | } |
| 60 | tree := sops.Tree{ |
| 61 | Branches: branches, |
| 62 | Metadata: metadataFromEncryptionConfig(opts.encryptConfig), |
| 63 | FilePath: path, |
| 64 | } |
| 65 | |
| 66 | // Generate a data key |
| 67 | dataKey, errs := tree.GenerateDataKeyWithKeyServices(opts.KeyServices) |
| 68 | if len(errs) > 0 { |
| 69 | return nil, common.NewExitError(fmt.Sprintf("Error encrypting the data key with one or more master keys: %s", errs), codes.CouldNotRetrieveKey) |
| 70 | } |
| 71 | |
| 72 | return editTree(opts.editOpts, &tree, dataKey) |
| 73 | } |
| 74 | |
| 75 | func edit(opts editOpts) ([]byte, error) { |
| 76 | // Load the file |
no test coverage detected