Fix imported package names to not use mixedCaps or under_scores
This commit is contained in:
parent
75401d790c
commit
ce001dcd4e
@ -30,7 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/events"
|
"github.com/google/cadvisor/events"
|
||||||
httpMux "github.com/google/cadvisor/http/mux"
|
httpmux "github.com/google/cadvisor/http/mux"
|
||||||
info "github.com/google/cadvisor/info/v1"
|
info "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
)
|
)
|
||||||
@ -39,7 +39,7 @@ const (
|
|||||||
apiResource = "/api/"
|
apiResource = "/api/"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterHandlers(mux httpMux.Mux, m manager.Manager) error {
|
func RegisterHandlers(mux httpmux.Mux, m manager.Manager) error {
|
||||||
apiVersions := getApiVersions()
|
apiVersions := getApiVersions()
|
||||||
supportedApiVersions := make(map[string]ApiVersion, len(apiVersions))
|
supportedApiVersions := make(map[string]ApiVersion, len(apiVersions))
|
||||||
for _, v := range apiVersions {
|
for _, v := range apiVersions {
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
cadvisorHttp "github.com/google/cadvisor/http"
|
cadvisorhttp "github.com/google/cadvisor/http"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
"github.com/google/cadvisor/utils/sysfs"
|
"github.com/google/cadvisor/utils/sysfs"
|
||||||
"github.com/google/cadvisor/version"
|
"github.com/google/cadvisor/version"
|
||||||
@ -78,12 +78,12 @@ func main() {
|
|||||||
mux := http.DefaultServeMux
|
mux := http.DefaultServeMux
|
||||||
|
|
||||||
// Register all HTTP handlers.
|
// Register all HTTP handlers.
|
||||||
err = cadvisorHttp.RegisterHandlers(mux, containerManager, *httpAuthFile, *httpAuthRealm, *httpDigestFile, *httpDigestRealm)
|
err = cadvisorhttp.RegisterHandlers(mux, containerManager, *httpAuthFile, *httpAuthRealm, *httpDigestFile, *httpDigestRealm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Fatalf("Failed to register HTTP handlers: %v", err)
|
glog.Fatalf("Failed to register HTTP handlers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cadvisorHttp.RegisterPrometheusHandler(mux, containerManager, *prometheusEndpoint, nil)
|
cadvisorhttp.RegisterPrometheusHandler(mux, containerManager, *prometheusEndpoint, nil)
|
||||||
|
|
||||||
// Start the manager.
|
// Start the manager.
|
||||||
if err := containerManager.Start(); err != nil {
|
if err := containerManager.Start(); err != nil {
|
||||||
|
@ -23,11 +23,11 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
cgroup_fs "github.com/docker/libcontainer/cgroups/fs"
|
cgroupfs "github.com/docker/libcontainer/cgroups/fs"
|
||||||
libcontainerConfigs "github.com/docker/libcontainer/configs"
|
libcontainerconfigs "github.com/docker/libcontainer/configs"
|
||||||
docker "github.com/fsouza/go-dockerclient"
|
docker "github.com/fsouza/go-dockerclient"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
containerLibcontainer "github.com/google/cadvisor/container/libcontainer"
|
containerlibcontainer "github.com/google/cadvisor/container/libcontainer"
|
||||||
"github.com/google/cadvisor/fs"
|
"github.com/google/cadvisor/fs"
|
||||||
info "github.com/google/cadvisor/info/v1"
|
info "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/google/cadvisor/utils"
|
"github.com/google/cadvisor/utils"
|
||||||
@ -94,7 +94,7 @@ func newDockerContainerHandler(
|
|||||||
machineInfoFactory info.MachineInfoFactory,
|
machineInfoFactory info.MachineInfoFactory,
|
||||||
fsInfo fs.FsInfo,
|
fsInfo fs.FsInfo,
|
||||||
storageDriver storageDriver,
|
storageDriver storageDriver,
|
||||||
cgroupSubsystems *containerLibcontainer.CgroupSubsystems,
|
cgroupSubsystems *containerlibcontainer.CgroupSubsystems,
|
||||||
inHostNamespace bool,
|
inHostNamespace bool,
|
||||||
) (container.ContainerHandler, error) {
|
) (container.ContainerHandler, error) {
|
||||||
// Create the cgroup paths.
|
// Create the cgroup paths.
|
||||||
@ -104,8 +104,8 @@ func newDockerContainerHandler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the equivalent cgroup manager for this container.
|
// Generate the equivalent cgroup manager for this container.
|
||||||
cgroupManager := &cgroup_fs.Manager{
|
cgroupManager := &cgroupfs.Manager{
|
||||||
Cgroups: &libcontainerConfigs.Cgroup{
|
Cgroups: &libcontainerconfigs.Cgroup{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
Paths: cgroupPaths,
|
Paths: cgroupPaths,
|
||||||
@ -164,15 +164,15 @@ func (self *dockerContainerHandler) ContainerReference() (info.ContainerReferenc
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *dockerContainerHandler) readLibcontainerConfig() (*libcontainerConfigs.Config, error) {
|
func (self *dockerContainerHandler) readLibcontainerConfig() (*libcontainerconfigs.Config, error) {
|
||||||
config, err := containerLibcontainer.ReadConfig(*dockerRootDir, *dockerRunDir, self.id)
|
config, err := containerlibcontainer.ReadConfig(*dockerRootDir, *dockerRunDir, self.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to read libcontainer config: %v", err)
|
return nil, fmt.Errorf("failed to read libcontainer config: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace cgroup parent and name with our own since we may be running in a different context.
|
// Replace cgroup parent and name with our own since we may be running in a different context.
|
||||||
if config.Cgroups == nil {
|
if config.Cgroups == nil {
|
||||||
config.Cgroups = new(libcontainerConfigs.Cgroup)
|
config.Cgroups = new(libcontainerconfigs.Cgroup)
|
||||||
}
|
}
|
||||||
config.Cgroups.Name = self.name
|
config.Cgroups.Name = self.name
|
||||||
config.Cgroups.Parent = "/"
|
config.Cgroups.Parent = "/"
|
||||||
@ -180,7 +180,7 @@ func (self *dockerContainerHandler) readLibcontainerConfig() (*libcontainerConfi
|
|||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func libcontainerConfigToContainerSpec(config *libcontainerConfigs.Config, mi *info.MachineInfo) info.ContainerSpec {
|
func libcontainerConfigToContainerSpec(config *libcontainerconfigs.Config, mi *info.MachineInfo) info.ContainerSpec {
|
||||||
var spec info.ContainerSpec
|
var spec info.ContainerSpec
|
||||||
spec.HasMemory = true
|
spec.HasMemory = true
|
||||||
spec.Memory.Limit = math.MaxUint64
|
spec.Memory.Limit = math.MaxUint64
|
||||||
@ -274,7 +274,7 @@ func (self *dockerContainerHandler) getFsStats(stats *info.ContainerStats) error
|
|||||||
|
|
||||||
// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
|
// TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
|
||||||
func (self *dockerContainerHandler) GetStats() (*info.ContainerStats, error) {
|
func (self *dockerContainerHandler) GetStats() (*info.ContainerStats, error) {
|
||||||
stats, err := containerLibcontainer.GetStats(self.cgroupManager, self.rootFs, self.pid)
|
stats, err := containerlibcontainer.GetStats(self.cgroupManager, self.rootFs, self.pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stats, err
|
return stats, err
|
||||||
}
|
}
|
||||||
@ -318,7 +318,7 @@ func (self *dockerContainerHandler) GetContainerLabels() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *dockerContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
func (self *dockerContainerHandler) ListProcesses(listType container.ListType) ([]int, error) {
|
||||||
return containerLibcontainer.GetProcesses(self.cgroupManager)
|
return containerlibcontainer.GetProcesses(self.cgroupManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *dockerContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
|
func (self *dockerContainerHandler) WatchSubcontainers(events chan container.SubcontainerEvent) error {
|
||||||
@ -331,7 +331,7 @@ func (self *dockerContainerHandler) StopWatchingSubcontainers() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *dockerContainerHandler) Exists() bool {
|
func (self *dockerContainerHandler) Exists() bool {
|
||||||
return containerLibcontainer.Exists(*dockerRootDir, *dockerRunDir, self.id)
|
return containerlibcontainer.Exists(*dockerRootDir, *dockerRunDir, self.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func DockerInfo() (map[string]string, error) {
|
func DockerInfo() (map[string]string, error) {
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
cgroup_fs "github.com/docker/libcontainer/cgroups/fs"
|
cgroupfs "github.com/docker/libcontainer/cgroups/fs"
|
||||||
"github.com/docker/libcontainer/configs"
|
"github.com/docker/libcontainer/configs"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
@ -78,7 +78,7 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate the equivalent cgroup manager for this container.
|
// Generate the equivalent cgroup manager for this container.
|
||||||
cgroupManager := &cgroup_fs.Manager{
|
cgroupManager := &cgroupfs.Manager{
|
||||||
Cgroups: &configs.Cgroup{
|
Cgroups: &configs.Cgroup{
|
||||||
Name: name,
|
Name: name,
|
||||||
},
|
},
|
||||||
|
@ -17,7 +17,7 @@ package healthz
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
httpMux "github.com/google/cadvisor/http/mux"
|
httpmux "github.com/google/cadvisor/http/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleHealthz(w http.ResponseWriter, r *http.Request) {
|
func handleHealthz(w http.ResponseWriter, r *http.Request) {
|
||||||
@ -26,7 +26,7 @@ func handleHealthz(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register simple HTTP /healthz handler to return "ok".
|
// Register simple HTTP /healthz handler to return "ok".
|
||||||
func RegisterHandler(mux httpMux.Mux) error {
|
func RegisterHandler(mux httpmux.Mux) error {
|
||||||
mux.HandleFunc("/healthz", handleHealthz)
|
mux.HandleFunc("/healthz", handleHealthz)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/api"
|
"github.com/google/cadvisor/api"
|
||||||
"github.com/google/cadvisor/healthz"
|
"github.com/google/cadvisor/healthz"
|
||||||
httpMux "github.com/google/cadvisor/http/mux"
|
httpmux "github.com/google/cadvisor/http/mux"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
"github.com/google/cadvisor/metrics"
|
"github.com/google/cadvisor/metrics"
|
||||||
"github.com/google/cadvisor/pages"
|
"github.com/google/cadvisor/pages"
|
||||||
@ -31,7 +31,7 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RegisterHandlers(mux httpMux.Mux, containerManager manager.Manager, httpAuthFile, httpAuthRealm, httpDigestFile, httpDigestRealm string) error {
|
func RegisterHandlers(mux httpmux.Mux, containerManager manager.Manager, httpAuthFile, httpAuthRealm, httpDigestFile, httpDigestRealm string) error {
|
||||||
// Basic health handler.
|
// Basic health handler.
|
||||||
if err := healthz.RegisterHandler(mux); err != nil {
|
if err := healthz.RegisterHandler(mux); err != nil {
|
||||||
return fmt.Errorf("failed to register healthz handler: %s", err)
|
return fmt.Errorf("failed to register healthz handler: %s", err)
|
||||||
@ -88,7 +88,7 @@ func RegisterHandlers(mux httpMux.Mux, containerManager manager.Manager, httpAut
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterPrometheusHandler(mux httpMux.Mux, containerManager manager.Manager, prometheusEndpoint string, containerNameToLabelsFunc metrics.ContainerNameToLabelsFunc) {
|
func RegisterPrometheusHandler(mux httpmux.Mux, containerManager manager.Manager, prometheusEndpoint string, containerNameToLabelsFunc metrics.ContainerNameToLabelsFunc) {
|
||||||
collector := metrics.NewPrometheusCollector(containerManager, containerNameToLabelsFunc)
|
collector := metrics.NewPrometheusCollector(containerManager, containerNameToLabelsFunc)
|
||||||
prometheus.MustRegister(collector)
|
prometheus.MustRegister(collector)
|
||||||
mux.Handle(prometheusEndpoint, prometheus.Handler())
|
mux.Handle(prometheusEndpoint, prometheus.Handler())
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
auth "github.com/abbot/go-http-auth"
|
auth "github.com/abbot/go-http-auth"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
httpMux "github.com/google/cadvisor/http/mux"
|
httpmux "github.com/google/cadvisor/http/mux"
|
||||||
info "github.com/google/cadvisor/info/v1"
|
info "github.com/google/cadvisor/info/v1"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
)
|
)
|
||||||
@ -109,7 +109,7 @@ func dockerHandler(containerManager manager.Manager) auth.AuthenticatedHandlerFu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register http handlers
|
// Register http handlers
|
||||||
func RegisterHandlersDigest(mux httpMux.Mux, containerManager manager.Manager, authenticator *auth.DigestAuth) error {
|
func RegisterHandlersDigest(mux httpmux.Mux, containerManager manager.Manager, authenticator *auth.DigestAuth) error {
|
||||||
// Register the handler for the containers page.
|
// Register the handler for the containers page.
|
||||||
if authenticator != nil {
|
if authenticator != nil {
|
||||||
mux.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
|
mux.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
|
||||||
@ -121,7 +121,7 @@ func RegisterHandlersDigest(mux httpMux.Mux, containerManager manager.Manager, a
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlersBasic(mux httpMux.Mux, containerManager manager.Manager, authenticator *auth.BasicAuth) error {
|
func RegisterHandlersBasic(mux httpmux.Mux, containerManager manager.Manager, authenticator *auth.BasicAuth) error {
|
||||||
// Register the handler for the containers and docker age.
|
// Register the handler for the containers and docker age.
|
||||||
if authenticator != nil {
|
if authenticator != nil {
|
||||||
mux.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
|
mux.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
|
||||||
|
Loading…
Reference in New Issue
Block a user