call RegisterRotationJobWithResponse from RegisterRotationJob from the grpcsystem server instead of duplicating the code (#14315) (#14383)

Co-authored-by: Robert <17119716+robmonte@users.noreply.github.com>
This commit is contained in:
Vault Automation 2026-04-28 15:37:21 -06:00 committed by GitHub
parent 06b3374bd5
commit b2675da223
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -555,31 +555,13 @@ func (s *gRPCSystemViewServer) RegisterRotationJobWithResponse(ctx context.Conte
}
func (s *gRPCSystemViewServer) RegisterRotationJob(ctx context.Context, req *pb.RegisterRotationJobRequest) (*pb.RegisterRotationJobResponse, error) {
if s.impl == nil {
return nil, errMissingSystemView
}
cfgReq := &rotation.RotationJobConfigureRequest{
Name: req.Job.Name,
MountPoint: req.Job.MountPoint,
ReqPath: req.Job.Path,
RotationSchedule: req.Job.RotationSchedule,
RotationPolicy: req.Job.RotationPolicy,
// on the side inbound to vault, we convert seconds back to time.Duration
// Note: this value is seconds (as per the outbound client call, despite being int64)
// The field is int64 because of gRPC reasons, not time.Duration reasons
RotationWindow: time.Duration(req.Job.RotationWindow) * time.Second,
RotationPeriod: time.Duration(req.Job.RotationPeriod) * time.Second,
MigratedLegacyNextRotationTime: time.Unix(req.Job.MigratedLegacyNextRotationTime, 0).UTC(),
}
rotationID, err := s.impl.RegisterRotationJob(ctx, cfgReq)
resp, err := s.RegisterRotationJobWithResponse(ctx, req)
if err != nil {
return &pb.RegisterRotationJobResponse{}, status.Error(codes.Internal, err.Error())
return &pb.RegisterRotationJobResponse{}, err
}
return &pb.RegisterRotationJobResponse{
RotationID: rotationID,
RotationID: resp.GetInfo().GetRotationID(),
}, nil
}