style(datastore/fetch): Adjusts comments formatting
This commit is contained in:
parent
ebf134f181
commit
fcccfb085f
@ -40,8 +40,7 @@ func dialTimeout(network, addr string) (net.Conn, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Fetches user-data url with support for
|
||||
// exponential backoff and maximum retries
|
||||
// Fetches user-data url with support for exponential backoff and maximum retries
|
||||
func fetchURL(rawurl string) ([]byte, error) {
|
||||
if rawurl == "" {
|
||||
return nil, errors.New("user-data URL is empty. Skipping.")
|
||||
@ -52,18 +51,15 @@ func fetchURL(rawurl string) ([]byte, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Unfortunately, url.Parse
|
||||
// is too generic to throw errors
|
||||
// if a URL does not have a valid HTTP scheme.
|
||||
// So we have to do this extra validation
|
||||
// Unfortunately, url.Parse is too generic to throw errors if a URL does not
|
||||
// have a valid HTTP scheme. So, we have to do this extra validation
|
||||
if !strings.HasPrefix(url.Scheme, "http") {
|
||||
return nil, fmt.Errorf("user-data URL %s, does not have a valid HTTP scheme. Skipping.", rawurl)
|
||||
return nil, fmt.Errorf("user-data URL %s does not have a valid HTTP scheme. Skipping.", rawurl)
|
||||
}
|
||||
|
||||
userdataURL := url.String()
|
||||
|
||||
// We need to create our own client in order to
|
||||
// add timeout support.
|
||||
// We need to create our own client in order to add timeout support.
|
||||
// TODO(c4milo) Replace it once Go 1.3 is officially used by CoreOS
|
||||
// More info: https://code.google.com/p/go/source/detail?r=ada6f2d5f99f
|
||||
transport := &http.Transport{
|
||||
|
@ -17,9 +17,8 @@ var expBackoffTests = []struct {
|
||||
{2, "number of attempts: 2"},
|
||||
}
|
||||
|
||||
// Test exponential backoff
|
||||
// and that it continues retrying if a 5xx
|
||||
// response is received
|
||||
// Test exponential backoff and that it continues retrying if a 5xx response is
|
||||
// received
|
||||
func TestFetchURLExpBackOff(t *testing.T) {
|
||||
for i, tt := range expBackoffTests {
|
||||
mux := http.NewServeMux()
|
||||
@ -105,9 +104,9 @@ func TestFetchURLMalformed(t *testing.T) {
|
||||
url string
|
||||
want string
|
||||
}{
|
||||
{"boo", "user-data URL boo, does not have a valid HTTP scheme. Skipping."},
|
||||
{"mailto://boo", "user-data URL mailto://boo, does not have a valid HTTP scheme. Skipping."},
|
||||
{"ftp://boo", "user-data URL ftp://boo, does not have a valid HTTP scheme. Skipping."},
|
||||
{"boo", "user-data URL boo does not have a valid HTTP scheme. Skipping."},
|
||||
{"mailto://boo", "user-data URL mailto://boo does not have a valid HTTP scheme. Skipping."},
|
||||
{"ftp://boo", "user-data URL ftp://boo does not have a valid HTTP scheme. Skipping."},
|
||||
{"", "user-data URL is empty. Skipping."},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user