Skip to content

Commit

Permalink
Small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
radito3 committed Mar 12, 2024
1 parent 8188bd5 commit b0d8448
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions internal/executors/http/http_executor.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package http

import (
"bytes"
"errors"
"fmt"
"io"
Expand All @@ -10,6 +9,7 @@ import (
"net/http"
"net/http/httptrace"
"strconv"
"strings"
"time"

pb "github.com/SAP/remote-work-processor/build/proto/generated"
Expand Down Expand Up @@ -149,7 +149,7 @@ func requestTimedOut(err error) bool {
func createRequest(method string, url string, headers map[string]string, body, authHeader string) (*http.Request, <-chan int64, error) {
timeCh := make(chan int64, 1)

req, err := http.NewRequest(method, url, bytes.NewBuffer([]byte(body)))
req, err := http.NewRequest(method, url, strings.NewReader(body))
if err != nil {
return nil, nil, err
}
Expand All @@ -164,8 +164,9 @@ func createRequest(method string, url string, headers map[string]string, body, a
timeCh <- time.Since(start).Milliseconds()
},
}
traceCtx := httptrace.WithClientTrace(req.Context(), trace)

return req.WithContext(httptrace.WithClientTrace(req.Context(), trace)), timeCh, nil
return req.WithContext(traceCtx), timeCh, nil
}

func addHeaders(req *http.Request, headers map[string]string, authHeader string) {
Expand Down
6 changes: 3 additions & 3 deletions internal/executors/http/tls/tls_configuration_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func (p *ConfigurationProvider) CreateTransport() (http.RoundTripper, error) {
TLSClientConfig: &tls.Config{},
}

if p.TrustAnyCertificate() {
t.TLSClientConfig.InsecureSkipVerify = true
} else if p.UseTrustedCertificates() {
t.TLSClientConfig.InsecureSkipVerify = p.TrustAnyCertificate()

if p.UseTrustedCertificates() {
if err := p.trustCertificate(t, p.trustedCerts, "Failed to register the trusted certificate"); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/kubernetes/controller/manager_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (b *ManagerBuilder) BuildInternalManager(config *rest.Config, scheme *runti
log.Panicln("Failed to create manager:", err)
}

// these can only fail if the manager has been started prior to calling them
// these can fail only if the manager has been started prior to calling them
mgr.AddHealthzCheck("healthz", healthz.Ping)
mgr.AddReadyzCheck("readyz", healthz.Ping)
b.delegate = mgr
Expand Down

0 comments on commit b0d8448

Please sign in to comment.