(appId string, bindings map[string]string)
| 775 | } |
| 776 | |
| 777 | func WriteAppSecretBindings(appId string, bindings map[string]string) error { |
| 778 | if err := ValidateAppId(appId); err != nil { |
| 779 | return fmt.Errorf("invalid appId: %w", err) |
| 780 | } |
| 781 | |
| 782 | appDir, err := GetAppDir(appId) |
| 783 | if err != nil { |
| 784 | return err |
| 785 | } |
| 786 | |
| 787 | if bindings == nil { |
| 788 | bindings = make(map[string]string) |
| 789 | } |
| 790 | |
| 791 | data, err := json.MarshalIndent(bindings, "", " ") |
| 792 | if err != nil { |
| 793 | return fmt.Errorf("failed to marshal bindings: %w", err) |
| 794 | } |
| 795 | |
| 796 | bindingsPath := filepath.Join(appDir, SecretBindingsFileName) |
| 797 | if err := os.WriteFile(bindingsPath, data, 0644); err != nil { |
| 798 | return fmt.Errorf("failed to write %s: %w", SecretBindingsFileName, err) |
| 799 | } |
| 800 | |
| 801 | return nil |
| 802 | } |
| 803 | |
| 804 | func BuildAppSecretEnv(appId string, manifest *wshrpc.AppManifest, bindings map[string]string) (map[string]string, error) { |
| 805 | if manifest == nil { |
no test coverage detected