Skip to content

Commit

Permalink
conform lint
Browse files Browse the repository at this point in the history
Signed-off-by: Javan lacerda <[email protected]>
  • Loading branch information
javanlacerda committed Apr 19, 2024
1 parent 3198699 commit 91d8d76
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions cmd/prober/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 91d8d76

Please sign in to comment.