Fixes golint errors in pkg/kubelet

This commit is contained in:
Yuki Yugui Sonoda 2014-07-15 22:54:23 +09:00 committed by Yuki Sonoda (Yugui)
parent c6b27bb87d
commit edac5ce0b8
4 changed files with 13 additions and 7 deletions

View File

@ -27,6 +27,7 @@ import (
"os/exec"
"time"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/coreos/go-etcd/etcd"

View File

@ -25,14 +25,17 @@ import (
"github.com/golang/glog"
)
// HealthCheckStatus is an enum type which describes a status of health check.
type HealthCheckStatus int
// These are the valid values of HealthCheckStatus.
const (
CheckHealthy HealthCheckStatus = 0
CheckUnhealthy HealthCheckStatus = 1
CheckUnknown HealthCheckStatus = 2
)
// HealthChecker hides implementation details of checking health of containers.
type HealthChecker interface {
HealthCheck(container api.Container) (HealthCheckStatus, error)
}
@ -57,6 +60,8 @@ type MuxHealthChecker struct {
checkers map[string]HealthChecker
}
// HealthCheck delegates the health-checking of the container to one of the bundled implementations.
// It chooses an implementation according to container.LivenessProbe.Type.
func (m *MuxHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
checker, ok := m.checkers[container.LivenessProbe.Type]
if !ok || checker == nil {
@ -81,6 +86,7 @@ func (h *HTTPHealthChecker) findPort(container api.Container, portName string) i
return -1
}
// HealthCheck checks if the container is healthy by trying sending HTTP Get requests to the container.
func (h *HTTPHealthChecker) HealthCheck(container api.Container) (HealthCheckStatus, error) {
params := container.LivenessProbe.HTTPGet
if params == nil {

View File

@ -34,7 +34,6 @@ import (
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
_ "github.com/GoogleCloudPlatform/kubernetes/pkg/healthz"
"github.com/GoogleCloudPlatform/kubernetes/pkg/tools"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/coreos/go-etcd/etcd"
@ -145,7 +144,7 @@ func (kl *Kubelet) RunKubelet(dockerEndpoint, configPath, manifestURL, etcdServe
}
if address != "" {
glog.Infof("Starting to listen on %s:%d", address, port)
handler := KubeletServer{
handler := Server{
Kubelet: kl,
UpdateChannel: updateChannel,
DelegateHandler: http.DefaultServeMux,

View File

@ -31,8 +31,8 @@ import (
"gopkg.in/v1/yaml"
)
// KubeletServer is a http.Handler which exposes kubelet functionality over HTTP.
type KubeletServer struct {
// Server is a http.Handler which exposes kubelet functionality over HTTP.
type Server struct {
Kubelet kubeletInterface
UpdateChannel chan<- manifestUpdate
DelegateHandler http.Handler
@ -46,11 +46,11 @@ type kubeletInterface interface {
GetPodInfo(name string) (api.PodInfo, error)
}
func (s *KubeletServer) error(w http.ResponseWriter, err error) {
func (s *Server) error(w http.ResponseWriter, err error) {
http.Error(w, fmt.Sprintf("Internal Error: %v", err), http.StatusInternalServerError)
}
func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
defer apiserver.MakeLogged(req, &w).Log()
u, err := url.ParseRequestURI(req.RequestURI)
@ -110,7 +110,7 @@ func (s *KubeletServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
}
func (s *KubeletServer) serveStats(w http.ResponseWriter, req *http.Request) {
func (s *Server) serveStats(w http.ResponseWriter, req *http.Request) {
// /stats/<podid>/<containerName>
components := strings.Split(strings.TrimPrefix(path.Clean(req.URL.Path), "/"), "/")
var stats *api.ContainerStats