| 158 | } |
| 159 | |
| 160 | func (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 | |
| 179 | func (m *Manager) DeleteCredentials(ctx context.Context, secretID string) error { |
| 180 | m.logger.Infow("msg", "deleting credentials", "path", secretID) |