Update vendor dependencies

Change-Id: I3b1ca9f2687388c831d9d46a4e1de413ffae06ac
This commit is contained in:
Davanum Srinivas
2018-11-09 14:22:00 -05:00
parent 954996e231
commit 3fe776f24b
127 changed files with 2564 additions and 732 deletions

View File

@@ -7,12 +7,12 @@ go_library(
importpath = "k8s.io/gengo/examples/deepcopy-gen/generators",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/args:go_default_library",
"//vendor/k8s.io/gengo/examples/set-gen/sets:go_default_library",
"//vendor/k8s.io/gengo/generator:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -29,7 +29,7 @@ import (
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
// CustomArgs is used tby the go2idl framework to pass args specific to this
@@ -62,7 +62,7 @@ func extractTag(comments []string) *tagValue {
}
// If there are multiple values, abort.
if len(tagVals) > 1 {
glog.Fatalf("Found %d %s tags: %q", len(tagVals), tagName, tagVals)
klog.Fatalf("Found %d %s tags: %q", len(tagVals), tagName, tagVals)
}
// If we got here we are returning something.
@@ -89,7 +89,7 @@ func extractTag(comments []string) *tagValue {
tag.register = true
}
default:
glog.Fatalf("Unsupported %s param: %q", tagName, parts[i])
klog.Fatalf("Unsupported %s param: %q", tagName, parts[i])
}
}
return tag
@@ -123,7 +123,7 @@ func DefaultNameSystem() string {
func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
boilerplate, err := arguments.LoadGoBoilerplate()
if err != nil {
glog.Fatalf("Failed loading boilerplate: %v", err)
klog.Fatalf("Failed loading boilerplate: %v", err)
}
inputs := sets.NewString(context.Inputs...)
@@ -143,7 +143,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}
for i := range inputs {
glog.V(5).Infof("Considering pkg %q", i)
klog.V(5).Infof("Considering pkg %q", i)
pkg := context.Universe[i]
if pkg == nil {
// If the input had no Go files, for example.
@@ -156,12 +156,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
if ptag != nil {
ptagValue = ptag.value
if ptagValue != tagValuePackage {
glog.Fatalf("Package %v: unsupported %s value: %q", i, tagName, ptagValue)
klog.Fatalf("Package %v: unsupported %s value: %q", i, tagName, ptagValue)
}
ptagRegister = ptag.register
glog.V(5).Infof(" tag.value: %q, tag.register: %t", ptagValue, ptagRegister)
klog.V(5).Infof(" tag.value: %q, tag.register: %t", ptagValue, ptagRegister)
} else {
glog.V(5).Infof(" no tag")
klog.V(5).Infof(" no tag")
}
// If the pkg-scoped tag says to generate, we can skip scanning types.
@@ -170,12 +170,12 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
// If the pkg-scoped tag did not exist, scan all types for one that
// explicitly wants generation.
for _, t := range pkg.Types {
glog.V(5).Infof(" considering type %q", t.Name.String())
klog.V(5).Infof(" considering type %q", t.Name.String())
ttag := extractTag(t.CommentLines)
if ttag != nil && ttag.value == "true" {
glog.V(5).Infof(" tag=true")
klog.V(5).Infof(" tag=true")
if !copyableType(t) {
glog.Fatalf("Type %v requests deepcopy generation but is not copyable", t)
klog.Fatalf("Type %v requests deepcopy generation but is not copyable", t)
}
pkgNeedsGeneration = true
break
@@ -184,7 +184,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}
if pkgNeedsGeneration {
glog.V(3).Infof("Package %q needs generation", i)
klog.V(3).Infof("Package %q needs generation", i)
path := pkg.Path
// if the source path is within a /vendor/ directory (for example,
// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow
@@ -263,10 +263,10 @@ func (g *genDeepCopy) Filter(c *generator.Context, t *types.Type) bool {
return false
}
if !copyableType(t) {
glog.V(2).Infof("Type %v is not copyable", t)
klog.V(2).Infof("Type %v is not copyable", t)
return false
}
glog.V(4).Infof("Type %v is copyable", t)
klog.V(4).Infof("Type %v is copyable", t)
g.typesForInit = append(g.typesForInit, t)
return true
}
@@ -321,12 +321,12 @@ func deepCopyMethod(t *types.Type) (*types.Signature, error) {
return f.Signature, nil
}
// deepCopyMethodOrDie returns the signatrue of a DeepCopy method, nil or calls glog.Fatalf
// deepCopyMethodOrDie returns the signatrue of a DeepCopy method, nil or calls klog.Fatalf
// if the type does not match.
func deepCopyMethodOrDie(t *types.Type) *types.Signature {
ret, err := deepCopyMethod(t)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
return ret
}
@@ -367,12 +367,12 @@ func deepCopyIntoMethod(t *types.Type) (*types.Signature, error) {
return f.Signature, nil
}
// deepCopyIntoMethodOrDie returns the signature of a DeepCopyInto() method, nil or calls glog.Fatalf
// deepCopyIntoMethodOrDie returns the signature of a DeepCopyInto() method, nil or calls klog.Fatalf
// if the type is wrong.
func deepCopyIntoMethodOrDie(t *types.Type) *types.Signature {
ret, err := deepCopyIntoMethod(t)
if err != nil {
glog.Fatal(err)
klog.Fatal(err)
}
return ret
}
@@ -465,17 +465,17 @@ func (g *genDeepCopy) needsGeneration(t *types.Type) bool {
if tag != nil {
tv = tag.value
if tv != "true" && tv != "false" {
glog.Fatalf("Type %v: unsupported %s value: %q", t, tagName, tag.value)
klog.Fatalf("Type %v: unsupported %s value: %q", t, tagName, tag.value)
}
}
if g.allTypes && tv == "false" {
// The whole package is being generated, but this type has opted out.
glog.V(5).Infof("Not generating for type %v because type opted out", t)
klog.V(5).Infof("Not generating for type %v because type opted out", t)
return false
}
if !g.allTypes && tv != "true" {
// The whole package is NOT being generated, and this type has NOT opted in.
glog.V(5).Infof("Not generating for type %v because type did not opt in", t)
klog.V(5).Infof("Not generating for type %v because type did not opt in", t)
return false
}
return true
@@ -576,7 +576,7 @@ func (g *genDeepCopy) GenerateType(c *generator.Context, t *types.Type, w io.Wri
if !g.needsGeneration(t) {
return nil
}
glog.V(5).Infof("Generating deepcopy function for type %v", t)
klog.V(5).Infof("Generating deepcopy function for type %v", t)
sw := generator.NewSnippetWriter(w, c, "$", "$")
args := argsFromType(t)
@@ -678,12 +678,12 @@ func (g *genDeepCopy) generateFor(t *types.Type, sw *generator.SnippetWriter) {
f = g.doPointer
case types.Interface:
// interfaces are handled in-line in the other cases
glog.Fatalf("Hit an interface type %v. This should never happen.", t)
klog.Fatalf("Hit an interface type %v. This should never happen.", t)
case types.Alias:
// can never happen because we branch on the underlying type which is never an alias
glog.Fatalf("Hit an alias type %v. This should never happen.", t)
klog.Fatalf("Hit an alias type %v. This should never happen.", t)
default:
glog.Fatalf("Hit an unsupported type %v.", t)
klog.Fatalf("Hit an unsupported type %v.", t)
}
f(t, sw)
}
@@ -711,7 +711,7 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
}
if !ut.Key.IsAssignable() {
glog.Fatalf("Hit an unsupported type %v.", uet)
klog.Fatalf("Hit an unsupported type %v.", uet)
}
sw.Do("*out = make($.|raw$, len(*in))\n", t)
@@ -754,7 +754,7 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
case uet.Kind == types.Struct:
sw.Do("(*out)[key] = *val.DeepCopy()\n", uet)
default:
glog.Fatalf("Hit an unsupported type %v.", uet)
klog.Fatalf("Hit an unsupported type %v.", uet)
}
sw.Do("}\n", nil)
}
@@ -795,7 +795,7 @@ func (g *genDeepCopy) doSlice(t *types.Type, sw *generator.SnippetWriter) {
} else if uet.Kind == types.Struct {
sw.Do("(*in)[i].DeepCopyInto(&(*out)[i])\n", nil)
} else {
glog.Fatalf("Hit an unsupported type %v.", uet)
klog.Fatalf("Hit an unsupported type %v.", uet)
}
sw.Do("}\n", nil)
}
@@ -863,7 +863,7 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
sw.Do(fmt.Sprintf("out.$.name$ = in.$.name$.DeepCopy%s()\n", uft.Name.Name), args)
sw.Do("}\n", nil)
default:
glog.Fatalf("Hit an unsupported type %v.", uft)
klog.Fatalf("Hit an unsupported type %v.", uft)
}
}
}
@@ -900,6 +900,6 @@ func (g *genDeepCopy) doPointer(t *types.Type, sw *generator.SnippetWriter) {
sw.Do("*out = new($.Elem|raw$)\n", ut)
sw.Do("(*in).DeepCopyInto(*out)\n", nil)
default:
glog.Fatalf("Hit an unsupported type %v.", uet)
klog.Fatalf("Hit an unsupported type %v.", uet)
}
}

View File

@@ -7,11 +7,11 @@ go_library(
importpath = "k8s.io/gengo/examples/defaulter-gen/generators",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/args:go_default_library",
"//vendor/k8s.io/gengo/generator:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -29,7 +29,7 @@ import (
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
// CustomArgs is used tby the go2idl framework to pass args specific to this
@@ -117,11 +117,11 @@ func getManualDefaultingFunctions(context *generator.Context, pkg *types.Package
for _, f := range pkg.Functions {
if f.Underlying == nil || f.Underlying.Kind != types.Func {
glog.Errorf("Malformed function: %#v", f)
klog.Errorf("Malformed function: %#v", f)
continue
}
if f.Underlying.Signature == nil {
glog.Errorf("Function without signature: %#v", f)
klog.Errorf("Function without signature: %#v", f)
continue
}
signature := f.Underlying.Signature
@@ -156,7 +156,7 @@ func getManualDefaultingFunctions(context *generator.Context, pkg *types.Package
}
v.base = f
manualMap[key] = v
glog.V(6).Infof("found base defaulter function for %s from %s", key.Name, f.Name)
klog.V(6).Infof("found base defaulter function for %s from %s", key.Name, f.Name)
// Is one of the additional defaulters - a top level defaulter on a type that is
// also invoked.
case strings.HasPrefix(f.Name.Name, buffer.String()+"_"):
@@ -176,7 +176,7 @@ func getManualDefaultingFunctions(context *generator.Context, pkg *types.Package
}
v.additional = append(v.additional, f)
manualMap[key] = v
glog.V(6).Infof("found additional defaulter function for %s from %s", key.Name, f.Name)
klog.V(6).Infof("found additional defaulter function for %s from %s", key.Name, f.Name)
}
buffer.Reset()
sw.Do("$.inType|objectdefaultfn$", args)
@@ -189,7 +189,7 @@ func getManualDefaultingFunctions(context *generator.Context, pkg *types.Package
}
v.object = f
manualMap[key] = v
glog.V(6).Infof("found object defaulter function for %s from %s", key.Name, f.Name)
klog.V(6).Infof("found object defaulter function for %s from %s", key.Name, f.Name)
}
buffer.Reset()
}
@@ -198,7 +198,7 @@ func getManualDefaultingFunctions(context *generator.Context, pkg *types.Package
func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
boilerplate, err := arguments.LoadGoBoilerplate()
if err != nil {
glog.Fatalf("Failed loading boilerplate: %v", err)
klog.Fatalf("Failed loading boilerplate: %v", err)
}
packages := generator.Packages{}
@@ -214,7 +214,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
// We are generating defaults only for packages that are explicitly
// passed as InputDir.
for _, i := range context.Inputs {
glog.V(5).Infof("considering pkg %q", i)
klog.V(5).Infof("considering pkg %q", i)
pkg := context.Universe[i]
if pkg == nil {
// If the input had no Go files, for example.
@@ -248,7 +248,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
shouldCreateObjectDefaulterFn := func(t *types.Type) bool {
if defaults, ok := existingDefaulters[t]; ok && defaults.object != nil {
// A default generator is defined
glog.V(5).Infof(" an object defaulter already exists as %s", defaults.base.Name)
klog.V(5).Infof(" an object defaulter already exists as %s", defaults.base.Name)
return false
}
// opt-out
@@ -285,7 +285,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
var err error
typesPkg, err = context.AddDirectory(filepath.Join(pkg.Path, inputTags[0]))
if err != nil {
glog.Fatalf("cannot import package %s", inputTags[0])
klog.Fatalf("cannot import package %s", inputTags[0])
}
// update context.Order to the latest context.Universe
orderer := namer.Orderer{Namer: namer.NewPublicNamer(1)}
@@ -299,7 +299,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}
if namer.IsPrivateGoName(t.Name.Name) {
// We won't be able to convert to a private type.
glog.V(5).Infof(" found a type %v, but it is a private name", t)
klog.V(5).Infof(" found a type %v, but it is a private name", t)
continue
}
@@ -338,7 +338,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
// prune any types that were not used
for t, d := range newDefaulters {
if d.object == nil {
glog.V(6).Infof("did not generate defaulter for %s because no child defaulters were registered", t.Name)
klog.V(6).Infof("did not generate defaulter for %s because no child defaulters were registered", t.Name)
delete(newDefaulters, t)
}
}
@@ -346,7 +346,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
}
if len(newDefaulters) == 0 {
glog.V(5).Infof("no defaulters in package %s", pkg.Name)
klog.V(5).Infof("no defaulters in package %s", pkg.Name)
}
path := pkg.Path
@@ -421,7 +421,7 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
parent.call = append(parent.call, newDefaults.object)
// if we will be generating the defaulter, it by definition is a covering
// defaulter, so we halt recursion
glog.V(6).Infof("the defaulter %s will be generated as an object defaulter", t.Name)
klog.V(6).Infof("the defaulter %s will be generated as an object defaulter", t.Name)
return parent
case defaults.object != nil:
@@ -434,7 +434,7 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
// if the base function indicates it "covers" (it already includes defaulters)
// we can halt recursion
if checkTag(defaults.base.CommentLines, "covers") {
glog.V(6).Infof("the defaulter %s indicates it covers all sub generators", t.Name)
klog.V(6).Infof("the defaulter %s indicates it covers all sub generators", t.Name)
return parent
}
}
@@ -496,7 +496,7 @@ func (c *callTreeForType) build(t *types.Type, root bool) *callNode {
}
}
if len(parent.children) == 0 && len(parent.call) == 0 {
//glog.V(6).Infof("decided type %s needs no generation", t.Name)
//klog.V(6).Infof("decided type %s needs no generation", t.Name)
return nil
}
return parent
@@ -596,11 +596,11 @@ func (g *genDefaulter) GenerateType(c *generator.Context, t *types.Type, w io.Wr
return nil
}
glog.V(5).Infof("generating for type %v", t)
klog.V(5).Infof("generating for type %v", t)
callTree := newCallTreeForType(g.existingDefaulters, g.newDefaulters).build(t, true)
if callTree == nil {
glog.V(5).Infof(" no defaulters defined")
klog.V(5).Infof(" no defaulters defined")
return nil
}
i := 0
@@ -609,7 +609,7 @@ func (g *genDefaulter) GenerateType(c *generator.Context, t *types.Type, w io.Wr
return
}
path := callPath(append(ancestors, current))
glog.V(5).Infof(" %d: %s", i, path)
klog.V(5).Infof(" %d: %s", i, path)
i++
})

View File

@@ -7,11 +7,11 @@ go_library(
importpath = "k8s.io/gengo/examples/import-boss/generators",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/args:go_default_library",
"//vendor/k8s.io/gengo/generator:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -33,7 +33,7 @@ import (
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
const (
@@ -202,19 +202,19 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, actualPath, err)
}
for v := range f.Imports {
glog.V(4).Infof("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
klog.V(4).Infof("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
if !re.MatchString(v) {
continue
}
for _, forbidden := range r.ForbiddenPrefixes {
glog.V(4).Infof("Checking %v against %v\n", v, forbidden)
klog.V(4).Infof("Checking %v against %v\n", v, forbidden)
if strings.HasPrefix(v, forbidden) {
return fmt.Errorf("import %v has forbidden prefix %v", v, forbidden)
}
}
found := false
for _, allowed := range r.AllowedPrefixes {
glog.V(4).Infof("Checking %v against %v\n", v, allowed)
klog.V(4).Infof("Checking %v against %v\n", v, allowed)
if strings.HasPrefix(v, allowed) {
found = true
break
@@ -226,7 +226,7 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
}
}
if len(rules.Rules) > 0 {
glog.V(2).Infof("%v passes rules found in %v\n", path, actualPath)
klog.V(2).Infof("%v passes rules found in %v\n", path, actualPath)
}
return nil

View File

@@ -10,11 +10,11 @@ go_library(
importpath = "k8s.io/gengo/examples/set-gen/generators",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/args:go_default_library",
"//vendor/k8s.io/gengo/generator:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -25,7 +25,7 @@ import (
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
// NameSystems returns the name system used by the generators in this package.
@@ -47,13 +47,13 @@ func DefaultNameSystem() string {
func Packages(_ *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
boilerplate, err := arguments.LoadGoBoilerplate()
if err != nil {
glog.Fatalf("Failed loading boilerplate: %v", err)
klog.Fatalf("Failed loading boilerplate: %v", err)
}
return generator.Packages{&generator.DefaultPackage{
PackageName: "sets",
PackagePath: arguments.OutputPackagePath,
HeaderText: boilerplate,
HeaderText: boilerplate,
PackageDocumentation: []byte(
`// Package sets has auto-generated set types.
`),

View File

@@ -17,8 +17,8 @@ limitations under the License.
package generators
import (
"github.com/golang/glog"
"k8s.io/gengo/types"
"k8s.io/klog"
)
// extractBoolTagOrDie gets the comment-tags for the key and asserts that, if
@@ -27,7 +27,7 @@ import (
func extractBoolTagOrDie(key string, lines []string) bool {
val, err := types.ExtractSingleBoolCommentTag("+", key, false, lines)
if err != nil {
glog.Fatalf(err.Error())
klog.Fatalf(err.Error())
}
return val
}

View File

@@ -16,11 +16,11 @@ go_library(
importpath = "k8s.io/gengo/generator",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/tools/imports:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/parser:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@@ -29,7 +29,7 @@ import (
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"github.com/golang/glog"
"k8s.io/klog"
)
func errs2strings(errors []error) []string {
@@ -64,7 +64,7 @@ type DefaultFileType struct {
}
func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
glog.V(2).Infof("Assembling file %q", pathname)
klog.V(2).Infof("Assembling file %q", pathname)
destFile, err := os.Create(pathname)
if err != nil {
return err
@@ -91,7 +91,7 @@ func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
}
func (ft DefaultFileType) VerifyFile(f *File, pathname string) error {
glog.V(2).Infof("Verifying file %q", pathname)
klog.V(2).Infof("Verifying file %q", pathname)
friendlyName := filepath.Join(f.PackageName, f.Name)
b := &bytes.Buffer{}
et := NewErrorTracker(b)
@@ -214,7 +214,7 @@ func (c *Context) addNameSystems(namers namer.NameSystems) *Context {
// import path already, this will be appended to 'outDir'.
func (c *Context) ExecutePackage(outDir string, p Package) error {
path := filepath.Join(outDir, p.Path())
glog.V(2).Infof("Processing package %q, disk location %q", p.Name(), path)
klog.V(2).Infof("Processing package %q, disk location %q", p.Name(), path)
// Filter out any types the *package* doesn't care about.
packageContext := c.filteredBy(p.Filter)
os.MkdirAll(path, 0755)

View File

@@ -19,7 +19,7 @@ package generator
import (
"strings"
"github.com/golang/glog"
"k8s.io/klog"
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
@@ -42,7 +42,7 @@ func golangTrackerLocalName(tracker namer.ImportTracker, t types.Name) string {
// Using backslashes in package names causes gengo to produce Go code which
// will not compile with the gc compiler. See the comment on GoSeperator.
if strings.ContainsRune(path, '\\') {
glog.Warningf("Warning: backslash used in import path '%v', this is unsupported.\n", path)
klog.Warningf("Warning: backslash used in import path '%v', this is unsupported.\n", path)
}
dirs := strings.Split(path, namer.GoSeperator)

View File

@@ -59,7 +59,7 @@ func (r *pluralNamer) Name(t *types.Type) string {
return r.finalize(plural)
}
if len(singular) < 2 {
return r.finalize(plural)
return r.finalize(singular)
}
switch rune(singular[len(singular)-1]) {
@@ -87,7 +87,7 @@ func (r *pluralNamer) Name(t *types.Type) string {
plural = sPlural(singular)
}
case 'f':
plural = vesPlural(singular)
plural = vesPlural(singular)
default:
plural = sPlural(singular)
}

2
vendor/k8s.io/gengo/parser/BUILD generated vendored
View File

@@ -10,8 +10,8 @@ go_library(
importpath = "k8s.io/gengo/parser",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

42
vendor/k8s.io/gengo/parser/parse.go generated vendored
View File

@@ -31,8 +31,8 @@ import (
"sort"
"strings"
"github.com/golang/glog"
"k8s.io/gengo/types"
"k8s.io/klog"
)
// This clarifies when a pkg path has been canonicalized.
@@ -89,7 +89,7 @@ func New() *Builder {
// The returned string will have some/path/bin/go, so remove the last two elements.
c.GOROOT = filepath.Dir(filepath.Dir(strings.Trim(string(p), "\n")))
} else {
glog.Warningf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err)
klog.Warningf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err)
}
}
// Force this to off, since we don't properly parse CGo. All symbols must
@@ -136,7 +136,7 @@ func (b *Builder) importBuildPackage(dir string) (*build.Package, error) {
}
// Remember it under the user-provided name.
glog.V(5).Infof("saving buildPackage %s", dir)
klog.V(5).Infof("saving buildPackage %s", dir)
b.buildPackages[dir] = buildPkg
canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
if dir != string(canonicalPackage) {
@@ -145,7 +145,7 @@ func (b *Builder) importBuildPackage(dir string) (*build.Package, error) {
return buildPkg, nil
}
// Must be new, save it under the canonical name, too.
glog.V(5).Infof("saving buildPackage %s", canonicalPackage)
klog.V(5).Infof("saving buildPackage %s", canonicalPackage)
b.buildPackages[string(canonicalPackage)] = buildPkg
}
@@ -175,11 +175,11 @@ func (b *Builder) AddFileForTest(pkg string, path string, src []byte) error {
func (b *Builder) addFile(pkgPath importPathString, path string, src []byte, userRequested bool) error {
for _, p := range b.parsed[pkgPath] {
if path == p.name {
glog.V(5).Infof("addFile %s %s already parsed, skipping", pkgPath, path)
klog.V(5).Infof("addFile %s %s already parsed, skipping", pkgPath, path)
return nil
}
}
glog.V(6).Infof("addFile %s %s", pkgPath, path)
klog.V(6).Infof("addFile %s %s", pkgPath, path)
p, err := parser.ParseFile(b.fset, path, src, parser.DeclarationErrors|parser.ParseComments)
if err != nil {
return err
@@ -221,7 +221,7 @@ func (b *Builder) AddDir(dir string) error {
func (b *Builder) AddDirRecursive(dir string) error {
// Add the root.
if _, err := b.importPackage(dir, true); err != nil {
glog.Warningf("Ignoring directory %v: %v", dir, err)
klog.Warningf("Ignoring directory %v: %v", dir, err)
}
// filepath.Walk includes the root dir, but we already did that, so we'll
@@ -236,7 +236,7 @@ func (b *Builder) AddDirRecursive(dir string) error {
// Add it.
if _, err := b.importPackage(pkg, true); err != nil {
glog.Warningf("Ignoring child directory %v: %v", pkg, err)
klog.Warningf("Ignoring child directory %v: %v", pkg, err)
}
}
}
@@ -284,7 +284,7 @@ func (b *Builder) AddDirectoryTo(dir string, u *types.Universe) (*types.Package,
// The implementation of AddDir. A flag indicates whether this directory was
// user-requested or just from following the import graph.
func (b *Builder) addDir(dir string, userRequested bool) error {
glog.V(5).Infof("addDir %s", dir)
klog.V(5).Infof("addDir %s", dir)
buildPkg, err := b.importBuildPackage(dir)
if err != nil {
return err
@@ -292,7 +292,7 @@ func (b *Builder) addDir(dir string, userRequested bool) error {
canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
pkgPath := canonicalPackage
if dir != string(canonicalPackage) {
glog.V(5).Infof("addDir %s, canonical path is %s", dir, pkgPath)
klog.V(5).Infof("addDir %s, canonical path is %s", dir, pkgPath)
}
// Sanity check the pkg dir has not changed.
@@ -324,13 +324,13 @@ func (b *Builder) addDir(dir string, userRequested bool) error {
// importPackage is a function that will be called by the type check package when it
// needs to import a go package. 'path' is the import path.
func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, error) {
glog.V(5).Infof("importPackage %s", dir)
klog.V(5).Infof("importPackage %s", dir)
var pkgPath = importPathString(dir)
// Get the canonical path if we can.
if buildPkg := b.buildPackages[dir]; buildPkg != nil {
canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
glog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
pkgPath = canonicalPackage
}
@@ -349,7 +349,7 @@ func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, er
// Get the canonical path now that it has been added.
if buildPkg := b.buildPackages[dir]; buildPkg != nil {
canonicalPackage := canonicalizeImportPath(buildPkg.ImportPath)
glog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
klog.V(5).Infof("importPackage %s, canonical path is %s", dir, canonicalPackage)
pkgPath = canonicalPackage
}
}
@@ -365,9 +365,9 @@ func (b *Builder) importPackage(dir string, userRequested bool) (*tc.Package, er
if err != nil {
switch {
case ignoreError && pkg != nil:
glog.V(2).Infof("type checking encountered some issues in %q, but ignoring.\n", pkgPath)
klog.V(2).Infof("type checking encountered some issues in %q, but ignoring.\n", pkgPath)
case !ignoreError && pkg != nil:
glog.V(2).Infof("type checking encountered some errors in %q\n", pkgPath)
klog.V(2).Infof("type checking encountered some errors in %q\n", pkgPath)
return nil, err
default:
return nil, err
@@ -389,10 +389,10 @@ func (a importAdapter) Import(path string) (*tc.Package, error) {
// errors, so you may check whether the package is nil or not even if you get
// an error.
func (b *Builder) typeCheckPackage(pkgPath importPathString) (*tc.Package, error) {
glog.V(5).Infof("typeCheckPackage %s", pkgPath)
klog.V(5).Infof("typeCheckPackage %s", pkgPath)
if pkg, ok := b.typeCheckedPackages[pkgPath]; ok {
if pkg != nil {
glog.V(6).Infof("typeCheckPackage %s already done", pkgPath)
klog.V(6).Infof("typeCheckPackage %s already done", pkgPath)
return pkg, nil
}
// We store a nil right before starting work on a package. So
@@ -416,7 +416,7 @@ func (b *Builder) typeCheckPackage(pkgPath importPathString) (*tc.Package, error
// method. So there can't be cycles in the import graph.
Importer: importAdapter{b},
Error: func(err error) {
glog.V(2).Infof("type checker: %v\n", err)
klog.V(2).Infof("type checker: %v\n", err)
},
}
pkg, err := c.Check(string(pkgPath), b.fset, files, nil)
@@ -469,7 +469,7 @@ func (b *Builder) FindTypes() (types.Universe, error) {
// findTypesIn finalizes the package import and searches through the package
// for types.
func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error {
glog.V(5).Infof("findTypesIn %s", pkgPath)
klog.V(5).Infof("findTypesIn %s", pkgPath)
pkg := b.typeCheckedPackages[pkgPath]
if pkg == nil {
return fmt.Errorf("findTypesIn(%s): package is not known", pkgPath)
@@ -479,7 +479,7 @@ func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error
// packages they asked for depend on will be included.
// But we don't need to include all types in all
// *packages* they depend on.
glog.V(5).Infof("findTypesIn %s: package is not user requested", pkgPath)
klog.V(5).Infof("findTypesIn %s: package is not user requested", pkgPath)
return nil
}
@@ -775,7 +775,7 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
return out
}
out.Kind = types.Unsupported
glog.Warningf("Making unsupported type entry %q for: %#v\n", out, t)
klog.Warningf("Making unsupported type entry %q for: %#v\n", out, t)
return out
}
}

4
vendor/k8s.io/gengo/types/types.go generated vendored
View File

@@ -51,10 +51,10 @@ func ParseFullyQualifiedName(fqn string) Name {
cs := strings.Split(fqn, ".")
pkg := ""
if len(cs) > 1 {
pkg = strings.Join(cs[0:len(cs) - 1], ".")
pkg = strings.Join(cs[0:len(cs)-1], ".")
}
return Name{
Name: cs[len(cs) - 1],
Name: cs[len(cs)-1],
Package: pkg,
}
}

14
vendor/k8s.io/klog/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,14 @@
language: go
dist: xenial
go:
- 1.9.x
- 1.10.x
- 1.11.x
script:
- go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d .)
- diff -u <(echo -n) <(golint $(go list -e ./...))
- go tool vet .
- go test -v -race ./...
install:
- go get golang.org/x/lint/golint

26
vendor/k8s.io/klog/BUILD generated vendored Normal file
View File

@@ -0,0 +1,26 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"klog.go",
"klog_file.go",
],
importmap = "k8s.io/kubernetes/vendor/k8s.io/klog",
importpath = "k8s.io/klog",
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"],
)

31
vendor/k8s.io/klog/CONTRIBUTING.md generated vendored Normal file
View File

@@ -0,0 +1,31 @@
# Contributing Guidelines
Welcome to Kubernetes. We are excited about the prospect of you joining our [community](https://github.com/kubernetes/community)! The Kubernetes community abides by the CNCF [code of conduct](code-of-conduct.md). Here is an excerpt:
_As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities._
## Getting Started
We have full documentation on how to get started contributing here:
<!---
If your repo has certain guidelines for contribution, put them here ahead of the general k8s resources
-->
- [Contributor License Agreement](https://git.k8s.io/community/CLA.md) Kubernetes projects require that you sign a Contributor License Agreement (CLA) before we can accept your pull requests
- [Kubernetes Contributor Guide](http://git.k8s.io/community/contributors/guide) - Main contributor documentation, or you can just jump directly to the [contributing section](http://git.k8s.io/community/contributors/guide#contributing)
- [Contributor Cheat Sheet](https://git.k8s.io/community/contributors/guide/contributor-cheatsheet.md) - Common resources for existing developers
## Mentorship
- [Mentoring Initiatives](https://git.k8s.io/community/mentoring) - We have a diverse set of mentorship programs available that are always looking for volunteers!
<!---
Custom Information - if you're copying this template for the first time you can add custom content here, for example:
## Contact Information
- [Slack channel](https://kubernetes.slack.com/messages/kubernetes-users) - Replace `kubernetes-users` with your slack channel string, this will send users directly to your channel.
- [Mailing list](URL)
-->

191
vendor/k8s.io/klog/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,191 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and
distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright
owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities
that control, are controlled by, or are under common control with that entity.
For the purposes of this definition, "control" means (i) the power, direct or
indirect, to cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising
permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including
but not limited to software source code, documentation source, and configuration
files.
"Object" form shall mean any form resulting from mechanical transformation or
translation of a Source form, including but not limited to compiled object code,
generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made
available under the License, as indicated by a copyright notice that is included
in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that
is based on (or derived from) the Work and for which the editorial revisions,
annotations, elaborations, or other modifications represent, as a whole, an
original work of authorship. For the purposes of this License, Derivative Works
shall not include works that remain separable from, or merely link (or bind by
name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version
of the Work and any modifications or additions to that Work or Derivative Works
thereof, that is intentionally submitted to Licensor for inclusion in the Work
by the copyright owner or by an individual or Legal Entity authorized to submit
on behalf of the copyright owner. For the purposes of this definition,
"submitted" means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems, and
issue tracking systems that are managed by, or on behalf of, the Licensor for
the purpose of discussing and improving the Work, but excluding communication
that is conspicuously marked or otherwise designated in writing by the copyright
owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
of whom a Contribution has been received by Licensor and subsequently
incorporated within the Work.
2. Grant of Copyright License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the Work and such
Derivative Works in Source or Object form.
3. Grant of Patent License.
Subject to the terms and conditions of this License, each Contributor hereby
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
irrevocable (except as stated in this section) patent license to make, have
made, use, offer to sell, sell, import, and otherwise transfer the Work, where
such license applies only to those patent claims licensable by such Contributor
that are necessarily infringed by their Contribution(s) alone or by combination
of their Contribution(s) with the Work to which such Contribution(s) was
submitted. If You institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work or a
Contribution incorporated within the Work constitutes direct or contributory
patent infringement, then any patent licenses granted to You under this License
for that Work shall terminate as of the date such litigation is filed.
4. Redistribution.
You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of
this License; and
You must cause any modified files to carry prominent notices stating that You
changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
following places: within a NOTICE text file distributed as part of the
Derivative Works; within the Source form or documentation, if provided along
with the Derivative Works; or, within a display generated by the Derivative
Works, if and wherever such third-party notices normally appear. The contents of
the NOTICE file are for informational purposes only and do not modify the
License. You may add Your own attribution notices within Derivative Works that
You distribute, alongside or as an addendum to the NOTICE text from the Work,
provided that such additional attribution notices cannot be construed as
modifying the License.
You may add Your own copyright statement to Your modifications and may provide
additional or different license terms and conditions for use, reproduction, or
distribution of Your modifications, or for any such Derivative Works as a whole,
provided Your use, reproduction, and distribution of the Work otherwise complies
with the conditions stated in this License.
5. Submission of Contributions.
Unless You explicitly state otherwise, any Contribution intentionally submitted
for inclusion in the Work by You to the Licensor shall be under the terms and
conditions of this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify the terms of
any separate license agreement you may have executed with Licensor regarding
such Contributions.
6. Trademarks.
This License does not grant permission to use the trade names, trademarks,
service marks, or product names of the Licensor, except as required for
reasonable and customary use in describing the origin of the Work and
reproducing the content of the NOTICE file.
7. Disclaimer of Warranty.
Unless required by applicable law or agreed to in writing, Licensor provides the
Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
including, without limitation, any warranties or conditions of TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
solely responsible for determining the appropriateness of using or
redistributing the Work and assume any risks associated with Your exercise of
permissions under this License.
8. Limitation of Liability.
In no event and under no legal theory, whether in tort (including negligence),
contract, or otherwise, unless required by applicable law (such as deliberate
and grossly negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special, incidental,
or consequential damages of any character arising as a result of this License or
out of the use or inability to use the Work (including but not limited to
damages for loss of goodwill, work stoppage, computer failure or malfunction, or
any and all other commercial damages or losses), even if such Contributor has
been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability.
While redistributing the Work or Derivative Works thereof, You may choose to
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
other liability obligations and/or rights consistent with this License. However,
in accepting such obligations, You may act only on Your own behalf and on Your
sole responsibility, not on behalf of any other Contributor, and only if You
agree to indemnify, defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason of your
accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work
To apply the Apache License to your work, attach the following boilerplate
notice, with the fields enclosed by brackets "[]" replaced with your own
identifying information. (Don't include the brackets!) The text should be
enclosed in the appropriate comment syntax for the file format. We also
recommend that a file or class name and description of purpose be included on
the same "printed page" as the copyright notice for easier identification within
third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

11
vendor/k8s.io/klog/OWNERS generated vendored Normal file
View File

@@ -0,0 +1,11 @@
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md
approvers:
- dims
- thockin
- justinsb
- tallclair
- piosz
- brancz
- DirectXMan12
- lavalamp

51
vendor/k8s.io/klog/README.md generated vendored Normal file
View File

@@ -0,0 +1,51 @@
klog
====
klog is a permanant fork of https://github.com/golang/glog. original README from glog is below
----
glog
====
Leveled execution logs for Go.
This is an efficient pure Go implementation of leveled logs in the
manner of the open source C++ package
https://github.com/google/glog
By binding methods to booleans it is possible to use the log package
without paying the expense of evaluating the arguments to the log.
Through the -vmodule flag, the package also provides fine-grained
control over logging at the file level.
The comment from glog.go introduces the ideas:
Package glog implements logging analogous to the Google-internal
C++ INFO/ERROR/V setup. It provides functions Info, Warning,
Error, Fatal, plus formatting variants such as Infof. It
also provides V-style logging controlled by the -v and
-vmodule=file=2 flags.
Basic examples:
glog.Info("Prepare to repel boarders")
glog.Fatalf("Initialization failed: %s", err)
See the documentation for the V function for an explanation
of these examples:
if glog.V(2) {
glog.Info("Starting transaction...")
}
glog.V(2).Infoln("Processed", nItems, "elements")
The repository contains an open source version of the log package
used inside Google. The master copy of the source lives inside
Google, not here. The code in this repo is for export only and is not itself
under development. Feature requests will be ignored.
Send bug reports to golang-nuts@googlegroups.com.

9
vendor/k8s.io/klog/RELEASE.md generated vendored Normal file
View File

@@ -0,0 +1,9 @@
# Release Process
The `klog` is released on an as-needed basis. The process is as follows:
1. An issue is proposing a new release with a changelog since the last release
1. All [OWNERS](OWNERS) must LGTM this release
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
1. The release issue is closed
1. An announcement email is sent to `kubernetes-dev@googlegroups.com` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released`

20
vendor/k8s.io/klog/SECURITY_CONTACTS generated vendored Normal file
View File

@@ -0,0 +1,20 @@
# Defined below are the security contacts for this repo.
#
# They are the contact point for the Product Security Team to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/
dims
thockin
justinsb
tallclair
piosz
brancz
DirectXMan12
lavalamp

1239
vendor/k8s.io/klog/klog.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

126
vendor/k8s.io/klog/klog_file.go generated vendored Normal file
View File

@@ -0,0 +1,126 @@
// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/
//
// Copyright 2013 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// File I/O for logs.
package klog
import (
"errors"
"fmt"
"os"
"os/user"
"path/filepath"
"strings"
"sync"
"time"
)
// MaxSize is the maximum size of a log file in bytes.
var MaxSize uint64 = 1024 * 1024 * 1800
// logDirs lists the candidate directories for new log files.
var logDirs []string
func createLogDirs() {
if logging.logDir != "" {
logDirs = append(logDirs, logging.logDir)
}
logDirs = append(logDirs, os.TempDir())
}
var (
pid = os.Getpid()
program = filepath.Base(os.Args[0])
host = "unknownhost"
userName = "unknownuser"
)
func init() {
h, err := os.Hostname()
if err == nil {
host = shortHostname(h)
}
current, err := user.Current()
if err == nil {
userName = current.Username
}
// Sanitize userName since it may contain filepath separators on Windows.
userName = strings.Replace(userName, `\`, "_", -1)
}
// shortHostname returns its argument, truncating at the first period.
// For instance, given "www.google.com" it returns "www".
func shortHostname(hostname string) string {
if i := strings.Index(hostname, "."); i >= 0 {
return hostname[:i]
}
return hostname
}
// logName returns a new log file name containing tag, with start time t, and
// the name for the symlink for tag.
func logName(tag string, t time.Time) (name, link string) {
name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d",
program,
host,
userName,
tag,
t.Year(),
t.Month(),
t.Day(),
t.Hour(),
t.Minute(),
t.Second(),
pid)
return name, program + "." + tag
}
var onceLogDirs sync.Once
// create creates a new log file and returns the file and its filename, which
// contains tag ("INFO", "FATAL", etc.) and t. If the file is created
// successfully, create also attempts to update the symlink for that tag, ignoring
// errors.
func create(tag string, t time.Time) (f *os.File, filename string, err error) {
if logging.logFile != "" {
f, err := os.Create(logging.logFile)
if err == nil {
return f, logging.logFile, nil
}
return nil, "", fmt.Errorf("log: unable to create log: %v", err)
}
onceLogDirs.Do(createLogDirs)
if len(logDirs) == 0 {
return nil, "", errors.New("log: no log dirs")
}
name, link := logName(tag, t)
var lastErr error
for _, dir := range logDirs {
fname := filepath.Join(dir, name)
f, err := os.Create(fname)
if err == nil {
symlink := filepath.Join(dir, link)
os.Remove(symlink) // ignore err
os.Symlink(name, symlink) // ignore err
return f, fname, nil
}
lastErr = err
}
return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr)
}

View File

@@ -8,6 +8,7 @@ go_library(
visibility = ["//visibility:private"],
deps = [
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/kube-openapi/cmd/openapi-gen/args:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/generators:go_default_library",
],

View File

@@ -28,9 +28,12 @@ import (
"k8s.io/kube-openapi/pkg/generators"
"github.com/spf13/pflag"
"k8s.io/klog"
)
func main() {
klog.InitFlags(nil)
genericArgs, customArgs := generatorargs.NewDefaults()
genericArgs.AddFlags(pflag.CommandLine)

View File

@@ -12,12 +12,12 @@ go_library(
importpath = "k8s.io/kube-openapi/pkg/generators",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/gengo/args:go_default_library",
"//vendor/k8s.io/gengo/examples/set-gen/sets:go_default_library",
"//vendor/k8s.io/gengo/generator:go_default_library",
"//vendor/k8s.io/gengo/namer:go_default_library",
"//vendor/k8s.io/gengo/types:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/kube-openapi/cmd/openapi-gen/args:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/common:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/generators/rules:go_default_library",

View File

@@ -26,9 +26,9 @@ import (
"k8s.io/kube-openapi/pkg/generators/rules"
"github.com/golang/glog"
"k8s.io/gengo/generator"
"k8s.io/gengo/types"
"k8s.io/klog"
)
const apiViolationFileType = "api-violation"
@@ -41,7 +41,7 @@ type apiViolationFile struct {
func (a apiViolationFile) AssembleFile(f *generator.File, path string) error {
path = a.unmangledPath
glog.V(2).Infof("Assembling file %q", path)
klog.V(2).Infof("Assembling file %q", path)
if path == "-" {
_, err := io.Copy(os.Stdout, &f.Body)
return err
@@ -106,7 +106,7 @@ func (v *apiViolationGen) Filename() string {
}
func (v *apiViolationGen) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
glog.V(5).Infof("validating API rules for type %v", t)
klog.V(5).Infof("validating API rules for type %v", t)
if err := v.linter.validate(t); err != nil {
return err
}
@@ -189,7 +189,7 @@ type APIRule interface {
// validate runs all API rules on type t and records any API rule violation
func (l *apiLinter) validate(t *types.Type) error {
for _, r := range l.rules {
glog.V(5).Infof("validating API rule %v for type %v", r.Name(), t)
klog.V(5).Infof("validating API rule %v for type %v", r.Name(), t)
fields, err := r.Validate(t)
if err != nil {
return err

View File

@@ -20,11 +20,11 @@ import (
"fmt"
"path/filepath"
"github.com/golang/glog"
"k8s.io/gengo/args"
"k8s.io/gengo/generator"
"k8s.io/gengo/namer"
"k8s.io/gengo/types"
"k8s.io/klog"
generatorargs "k8s.io/kube-openapi/cmd/openapi-gen/args"
)
@@ -54,7 +54,7 @@ func DefaultNameSystem() string {
func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
boilerplate, err := arguments.LoadGoBoilerplate()
if err != nil {
glog.Fatalf("Failed loading boilerplate: %v", err)
klog.Fatalf("Failed loading boilerplate: %v", err)
}
header := append([]byte(fmt.Sprintf("// +build !%s\n\n", arguments.GeneratedBuildTag)), boilerplate...)
header = append(header, []byte(

View File

@@ -30,7 +30,7 @@ import (
"k8s.io/gengo/types"
openapi "k8s.io/kube-openapi/pkg/common"
"github.com/golang/glog"
"k8s.io/klog"
)
// This is the comment tag that carries parameters for open API generation.
@@ -184,7 +184,7 @@ func (g *openAPIGen) Init(c *generator.Context, w io.Writer) error {
}
func (g *openAPIGen) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
glog.V(5).Infof("generating for type %v", t)
klog.V(5).Infof("generating for type %v", t)
sw := generator.NewSnippetWriter(w, c, "$", "$")
err := newOpenAPITypeWriter(sw).generate(t)
if err != nil {
@@ -289,7 +289,7 @@ func (g openAPITypeWriter) generateMembers(t *types.Type, required []string) ([]
required = append(required, name)
}
if err = g.generateProperty(&m, t); err != nil {
glog.Errorf("Error when generating: %v, %v\n", name, m)
klog.Errorf("Error when generating: %v, %v\n", name, m)
return required, err
}
}
@@ -376,7 +376,7 @@ func (g openAPITypeWriter) generateStructExtensions(t *types.Type) error {
// Initially, we will only log struct extension errors.
if len(errors) > 0 {
for _, e := range errors {
glog.V(2).Infof("[%s]: %s\n", t.String(), e)
klog.V(2).Infof("[%s]: %s\n", t.String(), e)
}
}
// TODO(seans3): Validate struct extensions here.
@@ -392,7 +392,7 @@ func (g openAPITypeWriter) generateMemberExtensions(m *types.Member, parent *typ
if len(errors) > 0 {
errorPrefix := fmt.Sprintf("[%s] %s:", parent.String(), m.String())
for _, e := range errors {
glog.V(2).Infof("%s %s\n", errorPrefix, e)
klog.V(2).Infof("%s %s\n", errorPrefix, e)
}
}
g.emitExtensions(extensions)