Skip to content

Commit

Permalink
Improve code and variables
Browse files Browse the repository at this point in the history
Signed-off-by: cmoulliard <[email protected]>
  • Loading branch information
cmoulliard committed Dec 11, 2024
1 parent 700a841 commit 5830b22
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/controllers/localbuild/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,14 +707,14 @@ func (r *LocalbuildReconciler) updateArgocdDevPassword(ctx context.Context, admi
}
req.Header.Set("Content-Type", "application/json")

// Create an HTTP client and disable TLS verification
client := &http.Client{}
// Create an HTTP httpClient and disable TLS verification
httpClient := &http.Client{}
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig.InsecureSkipVerify = true
client.Transport = transport
httpClient.Transport = transport

// Send the request
resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return fmt.Errorf("Error sending request: %v\n", err), "failed"
}
Expand Down Expand Up @@ -747,10 +747,12 @@ func (r *LocalbuildReconciler) updateArgocdDevPassword(ctx context.Context, admi
}

req, err := http.NewRequest("PUT", argocdEndpoint+"/account/password", bytes.NewBuffer(payloadBytes))
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", argocdSession.Token))
req.Header.Set("Content-Type", "application/json")
if req != nil {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", argocdSession.Token))
req.Header.Set("Content-Type", "application/json")
}

resp, err := client.Do(req)
resp, err := httpClient.Do(req)
if err != nil {
return fmt.Errorf("Error sending request: %v\n", err), "failed"
}
Expand All @@ -774,7 +776,7 @@ func (r *LocalbuildReconciler) updateArgocdDevPassword(ctx context.Context, admi
req.Header.Set("Content-Type", "application/json")

// Send the request
resp, err = client.Do(req)
resp, err = httpClient.Do(req)
if err != nil {
return fmt.Errorf("Error sending request: %v\n", err), "failed"
}
Expand Down

0 comments on commit 5830b22

Please sign in to comment.