mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
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:
parent
06b3374bd5
commit
b2675da223
@ -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
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user