Fix golangci-lint warnings
This commit is contained in:
parent
8c99fe2fab
commit
6ded9c40ab
2 changed files with 69 additions and 49 deletions
|
@ -111,6 +111,18 @@ func (s *SignerClientHandler) ResponseData(ctx context.Context, in <-chan []byte
|
|||
case <-ctx.Done():
|
||||
return nil
|
||||
case frame := <-in:
|
||||
err := handleIncomingFrame(response, frame)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
case <-time.After(s.config.ResponseDataTimeout):
|
||||
return protocol.ErrResponseDataTimeoutExpired
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleIncomingFrame(response *protocol.Response, frame []byte) error {
|
||||
switch response.Announce.Code {
|
||||
case messages.RespHealth:
|
||||
var resp messages.HealthResponse
|
||||
|
@ -157,9 +169,6 @@ func (s *SignerClientHandler) ResponseData(ctx context.Context, in <-chan []byte
|
|||
default:
|
||||
return fmt.Errorf("unhandled response code %s", response.Announce.Code)
|
||||
}
|
||||
case <-time.After(s.config.ResponseDataTimeout):
|
||||
return protocol.ErrResponseDataTimeoutExpired
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -548,7 +548,10 @@ func (d *LegacyDB) requestSignedOpenPGPKeys(ctx context.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *LegacyDB) requestCerts(ctx context.Context, query string, rt responseType, recordFailureCallback func(ctx context.Context, rowID int)) error {
|
||||
func (d *LegacyDB) requestCerts(
|
||||
ctx context.Context, query string, rt responseType,
|
||||
recordFailureCallback func(ctx context.Context, rowID int),
|
||||
) error {
|
||||
issuerID, ok := d.issuerIDs[rt]
|
||||
if !ok {
|
||||
return fmt.Errorf("no known issuer id for type %s", rt)
|
||||
|
@ -608,7 +611,9 @@ func (d *LegacyDB) requestCerts(ctx context.Context, query string, rt responseTy
|
|||
}
|
||||
|
||||
if csrBlock.Type != "CERTIFICATE REQUEST" {
|
||||
d.logger.WithFields(logrus.Fields{"id": csrID, "file_name": csrFileName, "pem_block_type": csrBlock.Type}).Warn("unhandled PEM block type")
|
||||
d.logger.WithFields(
|
||||
logrus.Fields{"id": csrID, "file_name": csrFileName, "pem_block_type": csrBlock.Type},
|
||||
).Warn("unhandled PEM block type")
|
||||
|
||||
idsWithIssues = append(idsWithIssues, csrID)
|
||||
|
||||
|
@ -700,6 +705,7 @@ func buildSignCertificateCommand(
|
|||
if len(subjParts.Subject.Country) > 0 {
|
||||
signCertCommand.Country = subjParts.Subject.Country[0]
|
||||
}
|
||||
|
||||
return signCertCommand
|
||||
}
|
||||
|
||||
|
@ -789,28 +795,32 @@ func parseSubjectStringComponent(identifier, value string, res *x509.Certificate
|
|||
|
||||
func (d *LegacyDB) revokePersonalClientCerts(_ context.Context) error {
|
||||
logrus.Debug("not implemented")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *LegacyDB) revokePersonalServerCerts(_ context.Context) error {
|
||||
logrus.Debug("not implemented")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *LegacyDB) revokeOrganizationClientCerts(_ context.Context) error {
|
||||
logrus.Debug("not implemented")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *LegacyDB) revokeOrganizationServerCerts(_ context.Context) error {
|
||||
logrus.Debug("not implemented")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *LegacyDB) writeCertificate(prefix string, rowID int, signatureData []byte) (string, error) {
|
||||
crtDir := path.Join("..", "crt", prefix, strconv.Itoa(rowID/1000))
|
||||
|
||||
err := os.MkdirAll(crtDir, 0o755)
|
||||
err := os.MkdirAll(crtDir, 0o755) //nolint:gomnd
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not create directory: %w", err)
|
||||
}
|
||||
|
@ -840,7 +850,7 @@ func (d *LegacyDB) recordCertificate(ctx context.Context, prefix, query string,
|
|||
}
|
||||
|
||||
expiry := certificate.NotAfter
|
||||
serial := certificate.SerialNumber.Text(16) //nolint:gomnd
|
||||
serial := certificate.SerialNumber.Text(16)
|
||||
|
||||
pemData := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certBytes})
|
||||
|
||||
|
@ -1084,6 +1094,7 @@ func (d *LegacyDB) sendNotificationEmail(ctx context.Context, e emailData) error
|
|||
}
|
||||
|
||||
const smtpPort = 1025
|
||||
|
||||
c, err := mail.NewClient("localhost", mail.WithPort(smtpPort))
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create mail client: %w", err)
|
||||
|
|
Loading…
Reference in a new issue