feat: Validate cred rotation during creation (#23)

Throw an error when creating a host catalog with credentials that are not rotatable but credential rotation has been enabled
This commit is contained in:
Elim Tsiagbey authored and GitHub committed 2024-12-17 11:23:23 -05:00
1 parent d3a155bd3f
commit 5b6541491e
2 files changed
+51

No files matched your search

+4
View File
@@ -87,6 +87,10 @@ func (p *HostPlugin) OnCreateCatalog(ctx context.Context, req *pb.OnCreateCatalo
credential.IAMServiceAccountKeysDeletePermission,
}
if !credState.CredentialsConfig.IsRotatable() && !catalogAttributes.DisableCredentialRotation {
return nil, status.Error(codes.InvalidArgument, "cannot rotate credentials for non-rotatable credentials")
}
if credState.CredentialsConfig.IsRotatable() && !catalogAttributes.DisableCredentialRotation {
if err := credState.RotateCreds(ctx, permissions, p.testGCPClientOpts...); err != nil {
return nil, err