()
| 777 | } |
| 778 | |
| 779 | func prepareStripeConfig() error { |
| 780 | templateFile := "cli/cmd/devtool/data/stripe-config.template" |
| 781 | outputFile := filepath.Join(stateDirectory(), "stripe-config.toml") |
| 782 | |
| 783 | apiKey := lookupDotenv("RILL_DEVTOOL_STRIPE_CLI_API_KEY") |
| 784 | if apiKey == "" { |
| 785 | logWarn.Printf("No Stripe API key found in .env, Stripe webhook events will not be processed\n") |
| 786 | } |
| 787 | |
| 788 | // Parse the template |
| 789 | tmpl, err := template.ParseFiles(templateFile) |
| 790 | if err != nil { |
| 791 | return fmt.Errorf("failed to parse template: %w", err) |
| 792 | } |
| 793 | |
| 794 | // Create the output file |
| 795 | out, err := os.Create(outputFile) |
| 796 | if err != nil { |
| 797 | return fmt.Errorf("failed to create output file: %w", err) |
| 798 | } |
| 799 | defer out.Close() |
| 800 | |
| 801 | // Execute the template, writing to the output file |
| 802 | err = tmpl.Execute(out, map[string]string{"APIKey": apiKey}) |
| 803 | if err != nil { |
| 804 | return fmt.Errorf("failed to execute template: %w", err) |
| 805 | } |
| 806 | |
| 807 | return nil |
| 808 | } |
| 809 | |
| 810 | // awaitClose waits for all of the given channels to close. |
| 811 | // It returns an error if the context is canceled. |
no test coverage detected