MCPcopy
hub / github.com/dagger/container-use / withConfig

Function withConfig

cmd/container-use/config.go:16–29  ·  view source on GitHub ↗

Helper function for read-only config operations

(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error)

Source from the content-addressed store, hash-verified

14
15// Helper function for read-only config operations
16func withConfig(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error) error {
17 ctx := cmd.Context()
18 repo, err := repository.Open(ctx, ".")
19 if err != nil {
20 return fmt.Errorf("failed to open repository: %w", err)
21 }
22
23 config := environment.DefaultConfig()
24 if err := config.Load(repo.SourcePath()); err != nil {
25 return fmt.Errorf("failed to load configuration: %w", err)
26 }
27
28 return fn(config)
29}
30
31// Helper function for config update operations
32func updateConfig(cmd *cobra.Command, fn func(*environment.EnvironmentConfig) error) error {

Callers 1

config.goFile · 0.85

Calls 4

OpenFunction · 0.92
DefaultConfigFunction · 0.92
LoadMethod · 0.80
SourcePathMethod · 0.80

Tested by

no test coverage detected