Add timeout to Azure ACR credential provider

Adds a default timeout to the Azure ACR HTTP client to avoid hanging
when unable to reach server.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
This commit is contained in:
hasheddan 2021-03-30 17:15:54 -05:00
parent bb89384f39
commit 7c7cff6d27
No known key found for this signature in database
GPG Key ID: BD68BC686A14C271

View File

@ -57,7 +57,10 @@ import (
"net/url"
"strconv"
"strings"
"time"
"unicode"
utilnet "k8s.io/apimachinery/pkg/util/net"
)
type authDirective struct {
@ -75,7 +78,10 @@ const userAgent = "kubernetes-credentialprovider-acr"
const dockerTokenLoginUsernameGUID = "00000000-0000-0000-0000-000000000000"
var client = &http.Client{}
var client = &http.Client{
Transport: utilnet.SetTransportDefaults(&http.Transport{}),
Timeout: time.Second * 10,
}
func receiveChallengeFromLoginServer(serverAddress string) (*authDirective, error) {
challengeURL := url.URL{