MCPcopy Create free account
hub / github.com/docker/docker-agent / CreateToolSet

Function CreateToolSet

pkg/tools/builtin/shell/shell.go:512–528  ·  view source on GitHub ↗

CreateToolSet is used by the tools registry.

(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig)

Source from the content-addressed store, hash-verified

510
511// CreateToolSet is used by the tools registry.
512func CreateToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error) {
513 env, err := environment.ExpandAll(ctx, environment.ToValues(toolset.Env), runConfig.EnvProvider())
514 if err != nil {
515 return nil, fmt.Errorf("failed to expand the tool's environment variables: %w", err)
516 }
517 // Prepend os.Environ() so spawned processes inherit the host environment
518 // while the configured toolset env still wins on key collisions
519 // (exec.Cmd dedupes with last-wins). EnvProvider is used only to expand
520 // ${...} references in toolset.Env.
521 env = append(os.Environ(), env...)
522
523 ts := New(env, runConfig)
524 if toolset.SudoAskpass != nil && *toolset.SudoAskpass {
525 ts.handler.sudoAskpass = true
526 }
527 return ts, nil
528}
529
530// New creates a new shell toolset.
531func New(env []string, runConfig *config.RuntimeConfig) *ToolSet {

Callers 2

testToolsetRegistryFunction · 0.92
DefaultToolsetCreatorsFunction · 0.92

Calls 4

ExpandAllFunction · 0.92
ToValuesFunction · 0.92
EnvProviderMethod · 0.80
NewFunction · 0.70

Tested by 1

testToolsetRegistryFunction · 0.74