sanitizeToolName converts a string into a valid tool name.
(name string)
| 409 | |
| 410 | // sanitizeToolName converts a string into a valid tool name. |
| 411 | func sanitizeToolName(name string) string { |
| 412 | name = strings.NewReplacer( |
| 413 | "/", "_", |
| 414 | "-", "_", |
| 415 | ".", "_", |
| 416 | "{", "", |
| 417 | "}", "", |
| 418 | ).Replace(name) |
| 419 | |
| 420 | name = strings.Trim(name, "_") |
| 421 | |
| 422 | // Collapse multiple underscores. |
| 423 | for strings.Contains(name, "__") { |
| 424 | name = strings.ReplaceAll(name, "__", "_") |
| 425 | } |
| 426 | |
| 427 | return name |
| 428 | } |
| 429 | |
| 430 | // setHeaders sets identity headers (User-Agent, X-Docker-Agent-Version, |
| 431 | // X-Docker-Desktop-Version) plus any operator-supplied custom headers on |
no outgoing calls