MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / ReadCredentials

Method ReadCredentials

pkg/credentials/vault/keyval.go:160–177  ·  view source on GitHub ↗
(ctx context.Context, secretID string, creds any)

Source from the content-addressed store, hash-verified

158}
159
160func (m *Manager) ReadCredentials(ctx context.Context, secretID string, creds any) error {
161 m.logger.Infow("msg", "reading credentials", "path", secretID)
162
163 s, err := m.client.Get(ctx, secretID)
164 if err != nil {
165 if errors.Is(err, vault.ErrSecretNotFound) {
166 return fmt.Errorf("%w: path=%s", credentials.ErrNotFound, secretID)
167 }
168
169 return fmt.Errorf("reading secret from Vault: %w", err)
170 }
171
172 if err := mapToStruct(s.Data, creds); err != nil {
173 return fmt.Errorf("converting secret to struct: %w", err)
174 }
175
176 return nil
177}
178
179func (m *Manager) DeleteCredentials(ctx context.Context, secretID string) error {
180 m.logger.Infow("msg", "deleting credentials", "path", secretID)

Callers 3

TestDeleteCredsMethod · 0.95

Calls 3

mapToStructFunction · 0.70
InfowMethod · 0.65
GetMethod · 0.65

Tested by 3

TestDeleteCredsMethod · 0.76