MCPcopy Index your code
hub / github.com/rilldata/rill / prepareStripeConfig

Function prepareStripeConfig

cli/cmd/devtool/start.go:779–808  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

777}
778
779func 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.

Callers 1

runDepsMethod · 0.85

Calls 7

stateDirectoryFunction · 0.85
lookupDotenvFunction · 0.85
PrintfMethod · 0.80
CreateMethod · 0.80
ErrorfMethod · 0.65
CloseMethod · 0.65
ExecuteMethod · 0.65

Tested by

no test coverage detected