Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"net/http"
netUrl "net/url"
"os"
"strings"

Expand All @@ -20,10 +21,27 @@ type roundTripper struct {

func (rt roundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
r.Header.Set("Authorization", fmt.Sprintf("token %s", rt.accessToken))
transport := http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: rt.insecure}}
transport := rt.getTransport()
return transport.RoundTrip(r)
}

func (rt roundTripper) getTransport() *http.Transport {
proxyURLStr := os.Getenv("HTTPS_PROXY")
transport := http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: rt.insecure},
}

if proxyURLStr != "" {
proxyURL, err := netUrl.Parse(proxyURLStr)
if err != nil {
log.Fatal("failed to parse HTTPS_PROXY:", err)
}
transport.Proxy = http.ProxyURL(proxyURL)
}

return transport
}

func isValidState(state string) bool {
validStates := [4]string{"error", "failure", "pending", "success"}
for _, s := range validStates {
Expand Down