Set adds or replaces the credential for the given server URL. The canonical URL is mirrored into the value's ServerURL field so a caller reading the credential standalone still sees a consistent URL. Passing a nil credential is a no-op (use Delete to remove).
(serverURL string, c *Credentials)
| 183 | // caller reading the credential standalone still sees a consistent |
| 184 | // URL. Passing a nil credential is a no-op (use Delete to remove). |
| 185 | func (s *CredentialStore) Set(serverURL string, c *Credentials) { |
| 186 | if c == nil { |
| 187 | return |
| 188 | } |
| 189 | if s.Credentials == nil { |
| 190 | s.Credentials = map[string]*Credentials{} |
| 191 | } |
| 192 | key := normalizeServerURL(serverURL) |
| 193 | c.ServerURL = key |
| 194 | s.Credentials[key] = c |
| 195 | } |
| 196 | |
| 197 | // Delete removes the credential for the given server URL. No-op if the |
| 198 | // entry isn't present, or if the receiver is nil. |