Skip to content

Commit

Permalink
Use handler-provided scheme instead of hardcoded http
Browse files Browse the repository at this point in the history
Fix some formatting issues
  • Loading branch information
jasimmons committed Dec 11, 2019
1 parent 13eca1a commit 3bcf884
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/kubelet/kuberuntime/kuberuntime_manager.go
Expand Up @@ -159,7 +159,7 @@ func NewKubeGenericRuntimeManager(
podStateProvider podStateProvider,
osInterface kubecontainer.OSInterface,
runtimeHelper kubecontainer.RuntimeHelper,
httpClient types.HttpDoer,
httpClient types.HTTPDoer,
imageBackOff *flowcontrol.Backoff,
serializeImagePulls bool,
imagePullQPS float32,
Expand Down
10 changes: 7 additions & 3 deletions pkg/kubelet/lifecycle/handlers.go
Expand Up @@ -39,7 +39,7 @@ const (
)

type HandlerRunner struct {
httpDoer kubetypes.HttpDoer
httpDoer kubetypes.HTTPDoer
commandRunner kubecontainer.ContainerCommandRunner
containerManager podStatusProvider
}
Expand All @@ -48,7 +48,7 @@ type podStatusProvider interface {
GetPodStatus(uid types.UID, name, namespace string) (*kubecontainer.PodStatus, error)
}

func NewHandlerRunner(httpDoer kubetypes.HttpDoer, commandRunner kubecontainer.ContainerCommandRunner, containerManager podStatusProvider) kubecontainer.HandlerRunner {
func NewHandlerRunner(httpDoer kubetypes.HTTPDoer, commandRunner kubecontainer.ContainerCommandRunner, containerManager podStatusProvider) kubecontainer.HandlerRunner {
return &HandlerRunner{
httpDoer: httpDoer,
commandRunner: commandRunner,
Expand Down Expand Up @@ -153,7 +153,11 @@ func (hr *HandlerRunner) runHTTPHandler(pod *v1.Pod, container *v1.Container, ha
}
}
path := handler.HTTPGet.Path
url := formatURL("http", host, port, path)
scheme := "http"
if string(handler.HTTPGet.Scheme) != "" {
scheme = string(handler.HTTPGet.Scheme)
}
url := formatURL(scheme, host, port, path)

req, err := http.NewRequest(http.MethodGet, url.String(), nil)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/lifecycle/handlers_test.go
Expand Up @@ -183,7 +183,7 @@ func TestRunHandlerHttpWithHeaders(t *testing.T) {
Port: intstr.FromInt(8080),
Path: "/bar",
HTTPHeaders: []v1.HTTPHeader{
{Name: "foo", Value: "bar"},
{Name: "Foo", Value: "bar"},
},
},
},
Expand All @@ -201,7 +201,7 @@ func TestRunHandlerHttpWithHeaders(t *testing.T) {
if fakeHttp.url != "http://foo:8080/bar" {
t.Errorf("unexpected url: %s", fakeHttp.url)
}
if fakeHttp.headers["foo"][0] != "bar" {
if fakeHttp.headers["Foo"][0] != "bar" {
t.Errorf("missing http header: %s", fakeHttp.headers)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/types/types.go
Expand Up @@ -26,8 +26,8 @@ import (

// TODO: Reconcile custom types in kubelet/types and this subpackage

// HttpDoer encapsulates http.Do functionality
type HttpDoer interface {
// HTTPDoer encapsulates http.Do functionality
type HTTPDoer interface {
Do(req *http.Request) (*http.Response, error)
}

Expand Down

0 comments on commit 3bcf884

Please sign in to comment.