MCPcopy Index your code
hub / github.com/coder/coder / Delete

Method Delete

cli/sessionstore/sessionstore.go:182–216  ·  view source on GitHub ↗
(serverURL *url.URL)

Source from the content-addressed store, hash-verified

180}
181
182func (o Keyring) Delete(serverURL *url.URL) error {
183 host, err := normalizeHost(serverURL)
184 if err != nil {
185 return err
186 }
187
188 existingJSON, err := o.provider.Get(o.serviceName)
189 if err != nil {
190 return err
191 }
192
193 creds, err := parseCredentialsJSON(existingJSON)
194 if err != nil {
195 return xerrors.Errorf("failed to parse existing credentials: %w", err)
196 }
197
198 if _, ok := creds[host]; !ok {
199 return os.ErrNotExist
200 }
201
202 delete(creds, host)
203
204 // Delete the entire keyring entry when no credentials remain.
205 if len(creds) == 0 {
206 return o.provider.Delete(o.serviceName)
207 }
208
209 // Write back the updated credentials map.
210 credsJSON, err := json.Marshal(creds)
211 if err != nil {
212 return xerrors.Errorf("failed to marshal credentials: %w", err)
213 }
214
215 return o.provider.Set(o.serviceName, string(credsJSON))
216}
217
218// File is a Backend that exclusively stores the session token in a file on disk.
219type File struct {

Callers

nothing calls this directly

Calls 7

parseCredentialsJSONFunction · 0.85
normalizeHostFunction · 0.70
GetMethod · 0.65
DeleteMethod · 0.65
SetMethod · 0.65
ErrorfMethod · 0.45
MarshalMethod · 0.45

Tested by

no test coverage detected