MCPcopy Create free account
hub / github.com/nhost/nhost / CopyConfig

Function CopyConfig

cli/cmd/config/edit.go:63–82  ·  view source on GitHub ↗
(src, dst, overlayPath string)

Source from the content-addressed store, hash-verified

61}
62
63func CopyConfig[T any](src, dst, overlayPath string) error {
64 var cfg *T
65 if err := clienv.UnmarshalFile(src, &cfg, toml.Unmarshal); err != nil {
66 return fmt.Errorf("failed to parse config: %w", err)
67 }
68
69 var err error
70 if clienv.PathExists(overlayPath) {
71 cfg, err = ApplyJSONPatches(*cfg, overlayPath)
72 if err != nil {
73 return fmt.Errorf("failed to apply json patches: %w", err)
74 }
75 }
76
77 if err := clienv.MarshalFile(cfg, dst, toml.Marshal); err != nil {
78 return fmt.Errorf("failed to save temporary file: %w", err)
79 }
80
81 return nil
82}
83
84func readFile(filepath string) (any, error) {
85 f, err := os.Open(filepath)

Callers 2

commandConfigEditFunction · 0.92
editFunction · 0.85

Calls 5

UnmarshalFileFunction · 0.92
PathExistsFunction · 0.92
MarshalFileFunction · 0.92
ApplyJSONPatchesFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected