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

Method Read

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

Source from the content-addressed store, hash-verified

119}
120
121func (o Keyring) Read(serverURL *url.URL) (string, error) {
122 host, err := normalizeHost(serverURL)
123 if err != nil {
124 return "", err
125 }
126
127 credJSON, err := o.provider.Get(o.serviceName)
128 if err != nil {
129 return "", err
130 }
131 if len(credJSON) == 0 {
132 return "", os.ErrNotExist
133 }
134
135 creds, err := parseCredentialsJSON(credJSON)
136 if err != nil {
137 return "", xerrors.Errorf("read: parse existing credentials: %w", err)
138 }
139
140 // Return the credential for the specified URL
141 cred, ok := creds[host]
142 if !ok {
143 return "", os.ErrNotExist
144 }
145 return cred.APIToken, nil
146}
147
148func (o Keyring) Write(serverURL *url.URL, token string) error {
149 host, err := normalizeHost(serverURL)

Callers

nothing calls this directly

Calls 4

parseCredentialsJSONFunction · 0.85
normalizeHostFunction · 0.70
GetMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected