MCPcopy Create free account
hub / github.com/Chat2AnyLLM/code-agent-manager / Add

Function Add

internal/providers/store.go:50–65  ·  view source on GitHub ↗

Add inserts ep under name. Returns ErrAlreadyExists if name is already present, so callers can give a user-friendly "already exists" message without string-matching the wrapped error.

(file *File, name string, ep Endpoint)

Source from the content-addressed store, hash-verified

48// present, so callers can give a user-friendly "already exists" message
49// without string-matching the wrapped error.
50func Add(file *File, name string, ep Endpoint) error {
51 if file == nil {
52 return errors.New("providers: nil file")
53 }
54 if err := validateName(name); err != nil {
55 return err
56 }
57 if file.Endpoints == nil {
58 file.Endpoints = map[string]Endpoint{}
59 }
60 if _, ok := file.Endpoints[name]; ok {
61 return fmt.Errorf("provider %q already exists: %w", name, ErrAlreadyExists)
62 }
63 file.Endpoints[name] = ep
64 return nil
65}
66
67// Update applies the sparse patch to the endpoint named name. Returns
68// ErrNotFound if no such endpoint exists.

Callers 3

TestAddHappyAndDuplicateFunction · 0.92
AddProviderMethod · 0.92

Calls 1

validateNameFunction · 0.70

Tested by 2

TestAddHappyAndDuplicateFunction · 0.74