Move http utils to pkg/util

This commit is contained in:
Peter Rifel 2021-01-18 20:36:46 -06:00
parent 3f0fb7f80d
commit 0ca76f91f8
No known key found for this signature in database
GPG Key ID: BC6469E5B16DB2B6
3 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ import (
"k8s.io/kops/tests/e2e/kubetest2-kops/aws"
"k8s.io/kops/tests/e2e/kubetest2-kops/do"
"k8s.io/kops/tests/e2e/kubetest2-kops/gce"
"k8s.io/kops/tests/e2e/kubetest2-kops/util"
"k8s.io/kops/tests/e2e/pkg/util"
"sigs.k8s.io/kubetest2/pkg/exec"
)

View File

@ -32,8 +32,8 @@ func init() {
httpTransport.RegisterProtocol("file", http.NewFileTransport(http.Dir("/")))
}
// httpGETWithHeaders writes the response of an HTTP GET request
func httpGETWithHeaders(url string, headers map[string]string, writer io.Writer) error {
// HTTPGETWithHeaders writes the response of an HTTP GET request
func HTTPGETWithHeaders(url string, headers map[string]string, writer io.Writer) error {
klog.Infof("curl %s", url)
c := &http.Client{Transport: httpTransport}
req, err := http.NewRequest("GET", url, nil)

View File

@ -37,7 +37,7 @@ var externalIPServiceURLs = []string{
func ExternalIPRange() (string, error) {
var b bytes.Buffer
err := httpGETWithHeaders(externalIPMetadataURL, map[string]string{"Metadata-Flavor": "Google"}, &b)
err := HTTPGETWithHeaders(externalIPMetadataURL, map[string]string{"Metadata-Flavor": "Google"}, &b)
if err != nil {
// This often fails due to workload identity
log.Printf("failed to get external ip from metadata service: %v", err)
@ -50,7 +50,7 @@ func ExternalIPRange() (string, error) {
for attempt := 0; attempt < 5; attempt++ {
for _, u := range externalIPServiceURLs {
b.Reset()
err = httpGETWithHeaders(u, nil, &b)
err = HTTPGETWithHeaders(u, nil, &b)
if err != nil {
// The external service may well be down
log.Printf("failed to get external ip from %s: %v", u, err)