update cadvisor to v0.31.0

This commit is contained in:
David Ashpole
2018-09-10 10:31:56 -07:00
parent ba33abd528
commit 788196e45b
118 changed files with 190025 additions and 318 deletions

View File

@@ -0,0 +1,23 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["role.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/mesos/mesos-go/api/v1/lib/roles",
importpath = "github.com/mesos/mesos-go/api/v1/lib/roles",
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,82 @@
package roles
import (
"fmt"
"strings"
"unicode"
)
// Role is a deprecated type.
type Role string
const defaultRole = Role("*")
func (r Role) IsDefault() bool {
return r == defaultRole
}
func (r Role) Assign() func(interface{}) {
return func(v interface{}) {
type roler interface {
WithRole(string)
}
if ri, ok := v.(roler); ok {
ri.WithRole(string(r))
}
}
}
func (r Role) Proto() *string {
s := string(r)
return &s
}
// IsStrictSubroleOf returns true if left is a strict subrole of right.
func IsStrictSubroleOf(left, right string) bool {
return len(left) > len(right) && left[len(right)] == '/' && strings.HasPrefix(left, right)
}
var illegalComponents = map[string]struct{}{
".": struct{}{},
"..": struct{}{},
"*": struct{}{},
}
func Parse(s string) (string, error) {
if s == string(defaultRole) {
return s, nil
}
if strings.HasPrefix(s, "/") {
return "", fmt.Errorf("role %q cannot start with a slash", s)
}
if strings.HasSuffix(s, "/") {
return "", fmt.Errorf("role %q cannot end with a slash", s)
}
// validate each component in the role path
for _, part := range strings.Split(s, "/") {
if part == "" {
return "", fmt.Errorf("role %q cannot contain two adjacent slashes", s)
}
if bad, found := illegalComponents[part]; found {
return "", fmt.Errorf("role %q cannot contain %q as a component", s, bad)
}
if strings.HasPrefix(part, "-") {
return "", fmt.Errorf("role component %q is invalid because it begins with a dash", part)
}
if strings.IndexFunc(part, func(r rune) bool { return unicode.IsSpace(r) || unicode.IsControl(r) }) > -1 {
return "", fmt.Errorf("role component %q is invalid because it contains backspace or whitespace", part)
}
}
return s, nil
}
func Validate(roles ...string) error {
for i := range roles {
_, err := Parse(roles[i])
if err != nil {
return err
}
}
return nil
}