ValidateWriterClient checks if the client is valid by writing and deleting a secret in the provided mount path.
(m *Manager, pathPrefix string)
| 170 | // ValidateWriterClient checks if the client is valid by writing and deleting a secret |
| 171 | // in the provided mount path. |
| 172 | func ValidateWriterClient(m *Manager, pathPrefix string) error { |
| 173 | secretName := strings.Join([]string{pathPrefix, healthCheckSecret, uuid.NewString()}, "-") |
| 174 | |
| 175 | ctx := context.Background() |
| 176 | if _, err := m.client.SetSecret(ctx, secretName, azsecrets.SetSecretParameters{Value: strPtr("")}, nil); err != nil { |
| 177 | return fmt.Errorf("failed to set secret: %w", err) |
| 178 | } |
| 179 | |
| 180 | if _, err := m.client.DeleteSecret(ctx, secretName, nil); err != nil { |
| 181 | return fmt.Errorf("failed to delete secret: %w", err) |
| 182 | } |
| 183 | |
| 184 | return nil |
| 185 | } |
| 186 | |
| 187 | // string to pointer |
| 188 | func strPtr(s string) *string { |