(ctx context.Context, rep repo.Repository)
| 36 | } |
| 37 | |
| 38 | func (c *commandNotificationTemplateShow) run(ctx context.Context, rep repo.Repository) error { |
| 39 | var ( |
| 40 | text string |
| 41 | err error |
| 42 | ) |
| 43 | |
| 44 | if c.original { |
| 45 | text, err = notifytemplate.GetEmbeddedTemplate(c.templateName) |
| 46 | } else { |
| 47 | var found bool |
| 48 | |
| 49 | text, found, err = notifytemplate.GetTemplate(ctx, rep, c.templateName) |
| 50 | if !found { |
| 51 | text, err = notifytemplate.GetEmbeddedTemplate(c.templateName) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | if err != nil { |
| 56 | return errors.Wrap(err, "error listing templates") |
| 57 | } |
| 58 | |
| 59 | if c.htmlOutput { |
| 60 | tf := filepath.Join(os.TempDir(), "kopia-template-preview.html") |
| 61 | |
| 62 | //nolint:gosec,mnd |
| 63 | if err := os.WriteFile(tf, []byte(text), 0o644); err != nil { |
| 64 | return errors.Wrap(err, "error writing template to file") |
| 65 | } |
| 66 | |
| 67 | open.Run(tf) //nolint:errcheck |
| 68 | } |
| 69 | |
| 70 | c.out.printStdout("%v\n", strings.TrimRight(text, "\n")) |
| 71 | |
| 72 | return nil |
| 73 | } |
nothing calls this directly
no test coverage detected