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

Function Update

internal/providers/store.go:69–112  ·  view source on GitHub ↗

Update applies the sparse patch to the endpoint named name. Returns ErrNotFound if no such endpoint exists.

(file *File, name string, patch Patch)

Source from the content-addressed store, hash-verified

67// Update applies the sparse patch to the endpoint named name. Returns
68// ErrNotFound if no such endpoint exists.
69func Update(file *File, name string, patch Patch) error {
70 if file == nil {
71 return errors.New("providers: nil file")
72 }
73 ep, ok := file.Endpoints[name]
74 if !ok {
75 return fmt.Errorf("provider %q not found: %w", name, ErrNotFound)
76 }
77 if patch.Endpoint != nil {
78 ep.Endpoint = *patch.Endpoint
79 }
80 if patch.APIKey != nil {
81 ep.APIKey = *patch.APIKey
82 }
83 if patch.APIKeyEnv != nil {
84 ep.APIKeyEnv = *patch.APIKeyEnv
85 }
86 if patch.Description != nil {
87 ep.Description = *patch.Description
88 }
89 if patch.ListModelsCmd != nil {
90 ep.ListModelsCmd = *patch.ListModelsCmd
91 }
92 if patch.KeepProxyConfig != nil {
93 ep.KeepProxyConfig = *patch.KeepProxyConfig
94 }
95 if patch.UseProxy != nil {
96 ep.UseProxy = *patch.UseProxy
97 }
98 if patch.Enabled != nil {
99 v := *patch.Enabled
100 ep.Enabled = &v
101 }
102 if patch.Clients != nil {
103 current := ep.Clients()
104 updated := applyListPatch(current, *patch.Clients)
105 ep.SupportedClient = strings.Join(updated, ",")
106 }
107 if patch.Models != nil {
108 ep.Models = applyListPatch(ep.Models, *patch.Models)
109 }
110 file.Endpoints[name] = ep
111 return nil
112}
113
114// Remove deletes the endpoint named name. Returns false when no entry by
115// that name existed.

Callers 5

TestUpdateSparsePatchFunction · 0.92
UpdateProviderMethod · 0.92

Calls 2

applyListPatchFunction · 0.85
ClientsMethod · 0.80

Tested by 4

TestUpdateSparsePatchFunction · 0.74