update cadvisor godeps to v0.30.0
This commit is contained in:
5
vendor/github.com/docker/docker/pkg/parsers/BUILD
generated
vendored
5
vendor/github.com/docker/docker/pkg/parsers/BUILD
generated
vendored
@@ -16,7 +16,10 @@ filegroup(
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//vendor/github.com/docker/docker/pkg/parsers/operatingsystem:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
49
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/BUILD
generated
vendored
Normal file
49
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/BUILD
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = select({
|
||||
"@io_bazel_rules_go//go/platform:darwin": [
|
||||
"operatingsystem_unix.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:freebsd": [
|
||||
"operatingsystem_unix.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"operatingsystem_linux.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:solaris": [
|
||||
"operatingsystem_solaris.go",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"operatingsystem_windows.go",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
cgo = True,
|
||||
importpath = "github.com/docker/docker/pkg/parsers/operatingsystem",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = select({
|
||||
"@io_bazel_rules_go//go/platform:linux": [
|
||||
"//vendor/github.com/mattn/go-shellwords:go_default_library",
|
||||
],
|
||||
"@io_bazel_rules_go//go/platform:windows": [
|
||||
"//vendor/golang.org/x/sys/windows:go_default_library",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
77
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_linux.go
generated
vendored
Normal file
77
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_linux.go
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
// Package operatingsystem provides helper function to get the operating system
|
||||
// name for different platforms.
|
||||
package operatingsystem
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-shellwords"
|
||||
)
|
||||
|
||||
var (
|
||||
// file to use to detect if the daemon is running in a container
|
||||
proc1Cgroup = "/proc/1/cgroup"
|
||||
|
||||
// file to check to determine Operating System
|
||||
etcOsRelease = "/etc/os-release"
|
||||
|
||||
// used by stateless systems like Clear Linux
|
||||
altOsRelease = "/usr/lib/os-release"
|
||||
)
|
||||
|
||||
// GetOperatingSystem gets the name of the current operating system.
|
||||
func GetOperatingSystem() (string, error) {
|
||||
osReleaseFile, err := os.Open(etcOsRelease)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return "", fmt.Errorf("Error opening %s: %v", etcOsRelease, err)
|
||||
}
|
||||
osReleaseFile, err = os.Open(altOsRelease)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Error opening %s: %v", altOsRelease, err)
|
||||
}
|
||||
}
|
||||
defer osReleaseFile.Close()
|
||||
|
||||
var prettyName string
|
||||
scanner := bufio.NewScanner(osReleaseFile)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.HasPrefix(line, "PRETTY_NAME=") {
|
||||
data := strings.SplitN(line, "=", 2)
|
||||
prettyNames, err := shellwords.Parse(data[1])
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("PRETTY_NAME is invalid: %s", err.Error())
|
||||
}
|
||||
if len(prettyNames) != 1 {
|
||||
return "", fmt.Errorf("PRETTY_NAME needs to be enclosed by quotes if they have spaces: %s", data[1])
|
||||
}
|
||||
prettyName = prettyNames[0]
|
||||
}
|
||||
}
|
||||
if prettyName != "" {
|
||||
return prettyName, nil
|
||||
}
|
||||
// If not set, defaults to PRETTY_NAME="Linux"
|
||||
// c.f. http://www.freedesktop.org/software/systemd/man/os-release.html
|
||||
return "Linux", nil
|
||||
}
|
||||
|
||||
// IsContainerized returns true if we are running inside a container.
|
||||
func IsContainerized() (bool, error) {
|
||||
b, err := ioutil.ReadFile(proc1Cgroup)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, line := range bytes.Split(b, []byte{'\n'}) {
|
||||
if len(line) > 0 && !bytes.HasSuffix(line, []byte{'/'}) && !bytes.HasSuffix(line, []byte("init.scope")) {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
37
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_solaris.go
generated
vendored
Normal file
37
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_solaris.go
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// +build solaris,cgo
|
||||
|
||||
package operatingsystem
|
||||
|
||||
/*
|
||||
#include <zone.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
var etcOsRelease = "/etc/release"
|
||||
|
||||
// GetOperatingSystem gets the name of the current operating system.
|
||||
func GetOperatingSystem() (string, error) {
|
||||
b, err := ioutil.ReadFile(etcOsRelease)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if i := bytes.Index(b, []byte("\n")); i >= 0 {
|
||||
b = bytes.Trim(b[:i], " ")
|
||||
return string(b), nil
|
||||
}
|
||||
return "", errors.New("release not found")
|
||||
}
|
||||
|
||||
// IsContainerized returns true if we are running inside a container.
|
||||
func IsContainerized() (bool, error) {
|
||||
if C.getzoneid() != 0 {
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
}
|
25
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_unix.go
generated
vendored
Normal file
25
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_unix.go
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// +build freebsd darwin
|
||||
|
||||
package operatingsystem
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// GetOperatingSystem gets the name of the current operating system.
|
||||
func GetOperatingSystem() (string, error) {
|
||||
cmd := exec.Command("uname", "-s")
|
||||
osName, err := cmd.Output()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(osName), nil
|
||||
}
|
||||
|
||||
// IsContainerized returns true if we are running inside a container.
|
||||
// No-op on FreeBSD and Darwin, always returns false.
|
||||
func IsContainerized() (bool, error) {
|
||||
// TODO: Implement jail detection for freeBSD
|
||||
return false, errors.New("Cannot detect if we are in container")
|
||||
}
|
50
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_windows.go
generated
vendored
Normal file
50
vendor/github.com/docker/docker/pkg/parsers/operatingsystem/operatingsystem_windows.go
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package operatingsystem
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
// See https://code.google.com/p/go/source/browse/src/pkg/mime/type_windows.go?r=d14520ac25bf6940785aabb71f5be453a286f58c
|
||||
// for a similar sample
|
||||
|
||||
// GetOperatingSystem gets the name of the current operating system.
|
||||
func GetOperatingSystem() (string, error) {
|
||||
|
||||
var h windows.Handle
|
||||
|
||||
// Default return value
|
||||
ret := "Unknown Operating System"
|
||||
|
||||
if err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE,
|
||||
windows.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`),
|
||||
0,
|
||||
windows.KEY_READ,
|
||||
&h); err != nil {
|
||||
return ret, err
|
||||
}
|
||||
defer windows.RegCloseKey(h)
|
||||
|
||||
var buf [1 << 10]uint16
|
||||
var typ uint32
|
||||
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16
|
||||
|
||||
if err := windows.RegQueryValueEx(h,
|
||||
windows.StringToUTF16Ptr("ProductName"),
|
||||
nil,
|
||||
&typ,
|
||||
(*byte)(unsafe.Pointer(&buf[0])),
|
||||
&n); err != nil {
|
||||
return ret, err
|
||||
}
|
||||
ret = windows.UTF16ToString(buf[:])
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// IsContainerized returns true if we are running inside a container.
|
||||
// No-op on Windows, always returns false.
|
||||
func IsContainerized() (bool, error) {
|
||||
return false, nil
|
||||
}
|
Reference in New Issue
Block a user