From 91d8d76c7d2e72e42a5ca7f6ad5cfdb727a23fba Mon Sep 17 00:00:00 2001 From: Javan lacerda Date: Fri, 19 Apr 2024 13:59:41 +0000 Subject: [PATCH] conform lint Signed-off-by: Javan lacerda --- cmd/prober/write.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/prober/write.go b/cmd/prober/write.go index a3c91a47a..ce0541eb5 100644 --- a/cmd/prober/write.go +++ b/cmd/prober/write.go @@ -140,7 +140,6 @@ func fulcioWriteEndpoint(ctx context.Context, priv *ecdsa.PrivateKey) (*x509.Cer } func makeRekorRequest(cert *x509.Certificate, priv *ecdsa.PrivateKey, hostPath string) (*http.Response, time.Time, error) { - body, err := rekorEntryRequest(cert, priv) t := time.Now() if err != nil { @@ -170,16 +169,22 @@ func rekorWriteEndpoint(ctx context.Context, cert *x509.Certificate, priv *ecdsa }() resp, t, err := makeRekorRequest(cert, priv, hostPath) - // A new body should be created when it is conflicted - for resp.StatusCode == http.StatusConflict { - resp, t, err = makeRekorRequest(cert, priv, hostPath) - } - - latency := time.Since(t).Milliseconds() if err != nil { return fmt.Errorf("error adding entry: %w", err) } defer resp.Body.Close() + // A new body should be created when it is conflicted + for { + if resp.StatusCode != http.StatusConflict { + break + } + resp, t, err = makeRekorRequest(cert, priv, hostPath) + if err != nil { + return fmt.Errorf("error adding entry: %w", err) + } + defer resp.Body.Close() + } + latency := time.Since(t).Milliseconds() exportDataToPrometheus(resp, rekorURL, endpoint, POST, latency) if resp.StatusCode != http.StatusCreated {