mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-05-01 00:00:03 +08:00
Merge remote-tracking branch 'origin/master' into release-1.13
Kubernetes-commit: 03aacded1e0e8e9ebf2a84039f02433bb7b38bd0
This commit is contained in:
+14
-14
@@ -106,10 +106,6 @@
|
||||
"ImportPath": "github.com/gogo/protobuf/vanity/command",
|
||||
"Rev": "342cbe0a04158f6dcb03ca0079991a51a4248c02"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/golang/glog",
|
||||
"Rev": "44145f04b68cf362d9c4df2182967c2275eaefed"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/spf13/pflag",
|
||||
"Rev": "583c0c0531f06d5278b7d917446061adc344b5cd"
|
||||
@@ -124,43 +120,47 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/args",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/examples/deepcopy-gen/generators",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/examples/defaulter-gen/generators",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/examples/import-boss/generators",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/examples/set-gen/generators",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/examples/set-gen/sets",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/generator",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/namer",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/parser",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/gengo/types",
|
||||
"Rev": "fdcf9f9480fdd5bf2b3c3df9bf4ecd22b25b87e2"
|
||||
"Rev": "51747d6e00da1fc578d5a333a93bb2abcbce7a95"
|
||||
},
|
||||
{
|
||||
"ImportPath": "k8s.io/klog",
|
||||
"Rev": "8139d8cb77af419532b33dfa7dd09fbc5f1d344f"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
+3
-3
@@ -32,7 +32,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.
|
||||
@@ -318,12 +318,12 @@ func applyGroupOverrides(universe types.Universe, customArgs *clientgenargs.Cust
|
||||
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)
|
||||
}
|
||||
|
||||
customArgs, ok := arguments.CustomArgs.(*clientgenargs.CustomArgs)
|
||||
if !ok {
|
||||
glog.Fatalf("cannot convert arguments.CustomArgs to clientgenargs.CustomArgs")
|
||||
klog.Fatalf("cannot convert arguments.CustomArgs to clientgenargs.CustomArgs")
|
||||
}
|
||||
includedTypesOverrides := customArgs.IncludedTypesOverrides
|
||||
|
||||
|
||||
+4
-3
@@ -21,9 +21,9 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/client-gen/args"
|
||||
"k8s.io/code-generator/cmd/client-gen/generators"
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -52,7 +53,7 @@ func main() {
|
||||
}
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
if err := genericArgs.Execute(
|
||||
@@ -60,6 +61,6 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
+33
-33
@@ -29,7 +29,7 @@ import (
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
conversionargs "k8s.io/code-generator/cmd/conversion-gen/args"
|
||||
)
|
||||
@@ -124,10 +124,10 @@ type conversionFuncMap map[conversionPair]*types.Type
|
||||
// Returns all manually-defined conversion functions in the package.
|
||||
func getManualConversionFunctions(context *generator.Context, pkg *types.Package, manualMap conversionFuncMap) {
|
||||
if pkg == nil {
|
||||
glog.Warningf("Skipping nil package passed to getManualConversionFunctions")
|
||||
klog.Warningf("Skipping nil package passed to getManualConversionFunctions")
|
||||
return
|
||||
}
|
||||
glog.V(5).Infof("Scanning for conversion functions in %v", pkg.Name)
|
||||
klog.V(5).Infof("Scanning for conversion functions in %v", pkg.Name)
|
||||
|
||||
scopeName := types.Ref(conversionPackagePath, "Scope").Name
|
||||
errorName := types.Ref("", "error").Name
|
||||
@@ -136,34 +136,34 @@ func getManualConversionFunctions(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
|
||||
}
|
||||
glog.V(8).Infof("Considering function %s", f.Name)
|
||||
klog.V(8).Infof("Considering function %s", f.Name)
|
||||
signature := f.Underlying.Signature
|
||||
// Check whether the function is conversion function.
|
||||
// Note that all of them have signature:
|
||||
// func Convert_inType_To_outType(inType, outType, conversion.Scope) error
|
||||
if signature.Receiver != nil {
|
||||
glog.V(8).Infof("%s has a receiver", f.Name)
|
||||
klog.V(8).Infof("%s has a receiver", f.Name)
|
||||
continue
|
||||
}
|
||||
if len(signature.Parameters) != 3 || signature.Parameters[2].Name != scopeName {
|
||||
glog.V(8).Infof("%s has wrong parameters", f.Name)
|
||||
klog.V(8).Infof("%s has wrong parameters", f.Name)
|
||||
continue
|
||||
}
|
||||
if len(signature.Results) != 1 || signature.Results[0].Name != errorName {
|
||||
glog.V(8).Infof("%s has wrong results", f.Name)
|
||||
klog.V(8).Infof("%s has wrong results", f.Name)
|
||||
continue
|
||||
}
|
||||
inType := signature.Parameters[0]
|
||||
outType := signature.Parameters[1]
|
||||
if inType.Kind != types.Pointer || outType.Kind != types.Pointer {
|
||||
glog.V(8).Infof("%s has wrong parameter types", f.Name)
|
||||
klog.V(8).Infof("%s has wrong parameter types", f.Name)
|
||||
continue
|
||||
}
|
||||
// Now check if the name satisfies the convention.
|
||||
@@ -171,7 +171,7 @@ func getManualConversionFunctions(context *generator.Context, pkg *types.Package
|
||||
args := argsFromType(inType.Elem, outType.Elem)
|
||||
sw.Do("Convert_$.inType|public$_To_$.outType|public$", args)
|
||||
if f.Name.Name == buffer.String() {
|
||||
glog.V(4).Infof("Found conversion function %s", f.Name)
|
||||
klog.V(4).Infof("Found conversion function %s", f.Name)
|
||||
key := conversionPair{inType.Elem, outType.Elem}
|
||||
// We might scan the same package twice, and that's OK.
|
||||
if v, ok := manualMap[key]; ok && v != nil && v.Name.Package != pkg.Path {
|
||||
@@ -181,9 +181,9 @@ func getManualConversionFunctions(context *generator.Context, pkg *types.Package
|
||||
} else {
|
||||
// prevent user error when they don't get the correct conversion signature
|
||||
if strings.HasPrefix(f.Name.Name, "Convert_") {
|
||||
glog.Errorf("Rename function %s %s -> %s to match expected conversion signature", f.Name.Package, f.Name.Name, buffer.String())
|
||||
klog.Errorf("Rename function %s %s -> %s to match expected conversion signature", f.Name.Package, f.Name.Name, buffer.String())
|
||||
}
|
||||
glog.V(8).Infof("%s has wrong name", f.Name)
|
||||
klog.V(8).Infof("%s has wrong name", f.Name)
|
||||
}
|
||||
buffer.Reset()
|
||||
}
|
||||
@@ -192,7 +192,7 @@ func getManualConversionFunctions(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{}
|
||||
@@ -220,7 +220,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
}
|
||||
processed[i] = true
|
||||
|
||||
glog.V(5).Infof("considering pkg %q", i)
|
||||
klog.V(5).Infof("considering pkg %q", i)
|
||||
pkg := context.Universe[i]
|
||||
// typesPkg is where the versioned types are defined. Sometimes it is
|
||||
// different from pkg. For example, kubernetes core/v1 types are defined
|
||||
@@ -239,9 +239,9 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
// in their doc.go file.
|
||||
peerPkgs := extractTag(pkg.Comments)
|
||||
if peerPkgs != nil {
|
||||
glog.V(5).Infof(" tags: %q", peerPkgs)
|
||||
klog.V(5).Infof(" tags: %q", peerPkgs)
|
||||
} else {
|
||||
glog.V(5).Infof(" no tag")
|
||||
klog.V(5).Infof(" no tag")
|
||||
continue
|
||||
}
|
||||
skipUnsafe := false
|
||||
@@ -255,14 +255,14 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
externalTypesValues := extractExternalTypesTag(pkg.Comments)
|
||||
if externalTypesValues != nil {
|
||||
if len(externalTypesValues) != 1 {
|
||||
glog.Fatalf(" expect only one value for %q tag, got: %q", externalTypesTagName, externalTypesValues)
|
||||
klog.Fatalf(" expect only one value for %q tag, got: %q", externalTypesTagName, externalTypesValues)
|
||||
}
|
||||
externalTypes := externalTypesValues[0]
|
||||
glog.V(5).Infof(" external types tags: %q", externalTypes)
|
||||
klog.V(5).Infof(" external types tags: %q", externalTypes)
|
||||
var err error
|
||||
typesPkg, err = context.AddDirectory(externalTypes)
|
||||
if err != nil {
|
||||
glog.Fatalf("cannot import package %s", externalTypes)
|
||||
klog.Fatalf("cannot import package %s", externalTypes)
|
||||
}
|
||||
// update context.Order to the latest context.Universe
|
||||
orderer := namer.Orderer{Namer: namer.NewPublicNamer(1)}
|
||||
@@ -291,7 +291,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
context.AddDir(pp)
|
||||
p := context.Universe[pp]
|
||||
if nil == p {
|
||||
glog.Fatalf("failed to find pkg: %s", pp)
|
||||
klog.Fatalf("failed to find pkg: %s", pp)
|
||||
}
|
||||
getManualConversionFunctions(context, p, manualConversions)
|
||||
}
|
||||
@@ -335,7 +335,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
// from being a candidate for unsafe conversion
|
||||
for k, v := range manualConversions {
|
||||
if isCopyOnly(v.CommentLines) {
|
||||
glog.V(5).Infof("Conversion function %s will not block memory copy because it is copy-only", v.Name)
|
||||
klog.V(5).Infof("Conversion function %s will not block memory copy because it is copy-only", v.Name)
|
||||
continue
|
||||
}
|
||||
// this type should be excluded from all equivalence, because the converter must be called.
|
||||
@@ -518,9 +518,9 @@ func (g *genConversion) convertibleOnlyWithinPackage(inType, outType *types.Type
|
||||
tagvals := extractTag(t.CommentLines)
|
||||
if tagvals != nil {
|
||||
if tagvals[0] != "false" {
|
||||
glog.Fatalf("Type %v: unsupported %s value: %q", t, tagName, tagvals[0])
|
||||
klog.Fatalf("Type %v: unsupported %s value: %q", t, tagName, tagvals[0])
|
||||
}
|
||||
glog.V(5).Infof("type %v requests no conversion generation, skipping", t)
|
||||
klog.V(5).Infof("type %v requests no conversion generation, skipping", t)
|
||||
return false
|
||||
}
|
||||
// TODO: Consider generating functions for other kinds too.
|
||||
@@ -582,10 +582,10 @@ func (g *genConversion) preexists(inType, outType *types.Type) (*types.Type, boo
|
||||
}
|
||||
|
||||
func (g *genConversion) Init(c *generator.Context, w io.Writer) error {
|
||||
if glog.V(5) {
|
||||
if klog.V(5) {
|
||||
if m, ok := g.useUnsafe.(equalMemoryTypes); ok {
|
||||
var result []string
|
||||
glog.Infof("All objects without identical memory layout:")
|
||||
klog.Infof("All objects without identical memory layout:")
|
||||
for k, v := range m {
|
||||
if v {
|
||||
continue
|
||||
@@ -594,7 +594,7 @@ func (g *genConversion) Init(c *generator.Context, w io.Writer) error {
|
||||
}
|
||||
sort.Strings(result)
|
||||
for _, s := range result {
|
||||
glog.Infof(s)
|
||||
klog.Infof(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -643,7 +643,7 @@ func (g *genConversion) Init(c *generator.Context, w io.Writer) error {
|
||||
}
|
||||
|
||||
func (g *genConversion) 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)
|
||||
peerType := getPeerTypeFor(c, t, g.peerPackages)
|
||||
sw := generator.NewSnippetWriter(w, c, "$", "$")
|
||||
g.generateConversion(t, peerType, sw)
|
||||
@@ -664,10 +664,10 @@ func (g *genConversion) generateConversion(inType, outType *types.Type, sw *gene
|
||||
// There is a public manual Conversion method: use it.
|
||||
} else if skipped := g.skippedFields[inType]; len(skipped) != 0 {
|
||||
// The inType had some fields we could not generate.
|
||||
glog.Errorf("Warning: could not find nor generate a final Conversion function for %v -> %v", inType, outType)
|
||||
glog.Errorf(" the following fields need manual conversion:")
|
||||
klog.Errorf("Warning: could not find nor generate a final Conversion function for %v -> %v", inType, outType)
|
||||
klog.Errorf(" the following fields need manual conversion:")
|
||||
for _, f := range skipped {
|
||||
glog.Errorf(" - %v", f)
|
||||
klog.Errorf(" - %v", f)
|
||||
}
|
||||
} else {
|
||||
// Emit a public conversion function.
|
||||
@@ -682,7 +682,7 @@ func (g *genConversion) generateConversion(inType, outType *types.Type, sw *gene
|
||||
// at any nesting level. This makes the autogenerator easy to understand, and
|
||||
// the compiler shouldn't care.
|
||||
func (g *genConversion) generateFor(inType, outType *types.Type, sw *generator.SnippetWriter) {
|
||||
glog.V(5).Infof("generating %v -> %v", inType, outType)
|
||||
klog.V(5).Infof("generating %v -> %v", inType, outType)
|
||||
var f func(*types.Type, *types.Type, *generator.SnippetWriter)
|
||||
|
||||
switch inType.Kind {
|
||||
@@ -853,7 +853,7 @@ func (g *genConversion) doStruct(inType, outType *types.Type, sw *generator.Snip
|
||||
sw.Do("}\n", nil)
|
||||
continue
|
||||
}
|
||||
glog.V(5).Infof("Skipped function %s because it is copy-only and we can use direct assignment", function.Name)
|
||||
klog.V(5).Infof("Skipped function %s because it is copy-only and we can use direct assignment", function.Name)
|
||||
}
|
||||
|
||||
// If we can't auto-convert, punt before we emit any code.
|
||||
|
||||
+5
-4
@@ -38,9 +38,9 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/conversion-gen/args"
|
||||
"k8s.io/code-generator/cmd/conversion-gen/generators"
|
||||
@@ -48,6 +48,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -61,7 +62,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Run it.
|
||||
@@ -70,7 +71,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+5
-4
@@ -46,16 +46,17 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/deepcopy-gen/generators"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/deepcopy-gen/args"
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -69,7 +70,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Run it.
|
||||
@@ -78,7 +79,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+5
-4
@@ -45,16 +45,17 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/defaulter-gen/generators"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/defaulter-gen/args"
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -68,7 +69,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Run it.
|
||||
@@ -77,7 +78,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
@@ -85,7 +85,7 @@ func (g *genProtoIDL) Filter(c *generator.Context, t *types.Type) bool {
|
||||
// Type specified "true".
|
||||
return true
|
||||
}
|
||||
glog.Fatalf(`Comment tag "protobuf" must be true or false, found: %q`, tagVals[0])
|
||||
klog.Fatalf(`Comment tag "protobuf" must be true or false, found: %q`, tagVals[0])
|
||||
}
|
||||
if !g.generateAll {
|
||||
// We're not generating everything.
|
||||
|
||||
+2
-2
@@ -17,8 +17,8 @@ limitations under the License.
|
||||
package protobuf
|
||||
|
||||
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.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
+4
-3
@@ -63,10 +63,11 @@ import (
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/import-boss/generators"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
arguments := args.Default()
|
||||
|
||||
// Override defaults.
|
||||
@@ -82,8 +83,8 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Errorf("Error: %v", err)
|
||||
klog.Errorf("Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ import (
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// factoryGenerator produces a file of listers for a given GroupVersion and
|
||||
@@ -65,7 +65,7 @@ func (g *factoryGenerator) Imports(c *generator.Context) (imports []string) {
|
||||
func (g *factoryGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
|
||||
sw := generator.NewSnippetWriter(w, c, "{{", "}}")
|
||||
|
||||
glog.V(5).Infof("processing type %v", t)
|
||||
klog.V(5).Infof("processing type %v", t)
|
||||
|
||||
gvInterfaces := make(map[string]*types.Type)
|
||||
gvNewFuncs := make(map[string]*types.Type)
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import (
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// factoryInterfaceGenerator produces a file of interfaces used to break a dependency cycle for
|
||||
@@ -60,7 +60,7 @@ func (g *factoryInterfaceGenerator) Imports(c *generator.Context) (imports []str
|
||||
func (g *factoryInterfaceGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
|
||||
sw := generator.NewSnippetWriter(w, c, "{{", "}}")
|
||||
|
||||
glog.V(5).Infof("processing type %v", t)
|
||||
klog.V(5).Infof("processing type %v", t)
|
||||
|
||||
m := map[string]interface{}{
|
||||
"cacheSharedIndexInformer": c.Universe.Type(cacheSharedIndexInformer),
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ import (
|
||||
"k8s.io/code-generator/cmd/client-gen/generators/util"
|
||||
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// informerGenerator produces a file of listers for a given GroupVersion and
|
||||
@@ -66,7 +66,7 @@ func (g *informerGenerator) Imports(c *generator.Context) (imports []string) {
|
||||
func (g *informerGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
|
||||
sw := generator.NewSnippetWriter(w, c, "$", "$")
|
||||
|
||||
glog.V(5).Infof("processing type %v", t)
|
||||
klog.V(5).Infof("processing type %v", t)
|
||||
|
||||
listerPackage := fmt.Sprintf("%s/%s/%s", g.listersPackage, g.groupPkgName, strings.ToLower(g.groupVersion.Version.NonEmpty()))
|
||||
clientSetInterface := c.Universe.Type(types.Name{Package: g.clientSetPackage, Name: "Interface"})
|
||||
|
||||
+5
-5
@@ -22,11 +22,11 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/generator"
|
||||
"k8s.io/gengo/namer"
|
||||
"k8s.io/gengo/types"
|
||||
"k8s.io/klog"
|
||||
|
||||
"k8s.io/code-generator/cmd/client-gen/generators/util"
|
||||
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
|
||||
@@ -102,12 +102,12 @@ func vendorless(p string) 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)
|
||||
}
|
||||
|
||||
customArgs, ok := arguments.CustomArgs.(*informergenargs.CustomArgs)
|
||||
if !ok {
|
||||
glog.Fatalf("Wrong CustomArgs type: %T", arguments.CustomArgs)
|
||||
klog.Fatalf("Wrong CustomArgs type: %T", arguments.CustomArgs)
|
||||
}
|
||||
|
||||
internalVersionPackagePath := filepath.Join(arguments.OutputPackagePath)
|
||||
@@ -128,7 +128,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
|
||||
objectMeta, internal, err := objectMetaForPackage(p)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
if objectMeta == nil {
|
||||
// no types in this package had genclient
|
||||
@@ -141,7 +141,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
if internal {
|
||||
lastSlash := strings.LastIndex(p.Path, "/")
|
||||
if lastSlash == -1 {
|
||||
glog.Fatalf("error constructing internal group version for package %q", p.Path)
|
||||
klog.Fatalf("error constructing internal group version for package %q", p.Path)
|
||||
}
|
||||
gv.Group = clientgentypes.Group(p.Path[lastSlash+1:])
|
||||
targetGroupVersions = internalGroupVersions
|
||||
|
||||
+2
-2
@@ -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.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
+5
-4
@@ -20,16 +20,17 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/code-generator/cmd/informer-gen/generators"
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/informer-gen/args"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -47,7 +48,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Run it.
|
||||
@@ -56,7 +57,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+5
-5
@@ -30,7 +30,7 @@ import (
|
||||
"k8s.io/code-generator/cmd/client-gen/generators/util"
|
||||
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// NameSystems returns the name system used by the generators in this package.
|
||||
@@ -66,7 +66,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)
|
||||
}
|
||||
|
||||
var packageList generator.Packages
|
||||
@@ -75,7 +75,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
|
||||
objectMeta, internal, err := objectMetaForPackage(p)
|
||||
if err != nil {
|
||||
glog.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
if objectMeta == nil {
|
||||
// no types in this package had genclient
|
||||
@@ -88,7 +88,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
if internal {
|
||||
lastSlash := strings.LastIndex(p.Path, "/")
|
||||
if lastSlash == -1 {
|
||||
glog.Fatalf("error constructing internal group version for package %q", p.Path)
|
||||
klog.Fatalf("error constructing internal group version for package %q", p.Path)
|
||||
}
|
||||
gv.Group = clientgentypes.Group(p.Path[lastSlash+1:])
|
||||
internalGVPkg = p.Path
|
||||
@@ -223,7 +223,7 @@ func (g *listerGenerator) Imports(c *generator.Context) (imports []string) {
|
||||
func (g *listerGenerator) GenerateType(c *generator.Context, t *types.Type, w io.Writer) error {
|
||||
sw := generator.NewSnippetWriter(w, c, "$", "$")
|
||||
|
||||
glog.V(5).Infof("processing type %v", t)
|
||||
klog.V(5).Infof("processing type %v", t)
|
||||
m := map[string]interface{}{
|
||||
"Resource": c.Universe.Function(types.Name{Package: t.Name.Package, Name: "Resource"}),
|
||||
"type": t,
|
||||
|
||||
+2
-2
@@ -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.Fatal(err)
|
||||
klog.Fatal(err)
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
+5
-4
@@ -20,16 +20,17 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/code-generator/cmd/lister-gen/generators"
|
||||
"k8s.io/code-generator/pkg/util"
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/lister-gen/args"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs, customArgs := generatorargs.NewDefaults()
|
||||
|
||||
// Override defaults.
|
||||
@@ -44,7 +45,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
// Run it.
|
||||
@@ -53,7 +54,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+9
-9
@@ -22,7 +22,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
|
||||
clientgentypes "k8s.io/code-generator/cmd/client-gen/types"
|
||||
"k8s.io/gengo/args"
|
||||
@@ -46,7 +46,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)
|
||||
}
|
||||
|
||||
packages := generator.Packages{}
|
||||
@@ -54,27 +54,27 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
pkg := context.Universe.Package(inputDir)
|
||||
internal, err := isInternal(pkg)
|
||||
if err != nil {
|
||||
glog.V(5).Infof("skipping the generation of %s file, due to err %v", arguments.OutputFileBaseName, err)
|
||||
klog.V(5).Infof("skipping the generation of %s file, due to err %v", arguments.OutputFileBaseName, err)
|
||||
continue
|
||||
}
|
||||
if internal {
|
||||
glog.V(5).Infof("skipping the generation of %s file because %s package contains internal types, note that internal types don't have \"json\" tags", arguments.OutputFileBaseName, pkg.Name)
|
||||
klog.V(5).Infof("skipping the generation of %s file because %s package contains internal types, note that internal types don't have \"json\" tags", arguments.OutputFileBaseName, pkg.Name)
|
||||
continue
|
||||
}
|
||||
registerFileName := "register.go"
|
||||
searchPath := path.Join(args.DefaultSourceTree(), inputDir, registerFileName)
|
||||
if _, err := os.Stat(path.Join(searchPath)); err == nil {
|
||||
glog.V(5).Infof("skipping the generation of %s file because %s already exists in the path %s", arguments.OutputFileBaseName, registerFileName, searchPath)
|
||||
klog.V(5).Infof("skipping the generation of %s file because %s already exists in the path %s", arguments.OutputFileBaseName, registerFileName, searchPath)
|
||||
continue
|
||||
} else if err != nil && !os.IsNotExist(err) {
|
||||
glog.Fatalf("an error %v has occurred while checking if %s exists", err, registerFileName)
|
||||
klog.Fatalf("an error %v has occurred while checking if %s exists", err, registerFileName)
|
||||
}
|
||||
|
||||
gv := clientgentypes.GroupVersion{}
|
||||
{
|
||||
pathParts := strings.Split(pkg.Path, "/")
|
||||
if len(pathParts) < 2 {
|
||||
glog.Errorf("the path of the package must contain the group name and the version, path = %s", pkg.Path)
|
||||
klog.Errorf("the path of the package must contain the group name and the version, path = %s", pkg.Path)
|
||||
continue
|
||||
}
|
||||
gv.Group = clientgentypes.Group(pathParts[len(pathParts)-2])
|
||||
@@ -84,14 +84,14 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
||||
// extract the fully qualified API group name from it and overwrite the group inferred from the package path
|
||||
if override := types.ExtractCommentTags("+", pkg.DocComments)["groupName"]; override != nil {
|
||||
groupName := override[0]
|
||||
glog.V(5).Infof("overriding the group name with = %s", groupName)
|
||||
klog.V(5).Infof("overriding the group name with = %s", groupName)
|
||||
gv.Group = clientgentypes.Group(groupName)
|
||||
}
|
||||
}
|
||||
|
||||
typesToRegister := []*types.Type{}
|
||||
for _, t := range pkg.Types {
|
||||
glog.V(5).Infof("considering type = %s", t.Name.String())
|
||||
klog.V(5).Infof("considering type = %s", t.Name.String())
|
||||
for _, typeMember := range t.Members {
|
||||
if typeMember.Name == "TypeMeta" && typeMember.Embedded == true {
|
||||
typesToRegister = append(typesToRegister, t)
|
||||
|
||||
+5
-4
@@ -20,8 +20,8 @@ import (
|
||||
"flag"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/klog"
|
||||
|
||||
generatorargs "k8s.io/code-generator/cmd/register-gen/args"
|
||||
"k8s.io/code-generator/cmd/register-gen/generators"
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
genericArgs := generatorargs.NewDefaults()
|
||||
genericArgs.GoHeaderFilePath = filepath.Join(args.DefaultSourceTree(), util.BoilerplatePath())
|
||||
genericArgs.AddFlags(pflag.CommandLine)
|
||||
@@ -38,7 +39,7 @@ func main() {
|
||||
|
||||
pflag.Parse()
|
||||
if err := generatorargs.Validate(genericArgs); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
|
||||
if err := genericArgs.Execute(
|
||||
@@ -46,7 +47,7 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Fatalf("Error: %v", err)
|
||||
klog.Fatalf("Error: %v", err)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
+4
-3
@@ -32,10 +32,11 @@ import (
|
||||
"k8s.io/gengo/args"
|
||||
"k8s.io/gengo/examples/set-gen/generators"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
func main() {
|
||||
klog.InitFlags(nil)
|
||||
arguments := args.Default()
|
||||
|
||||
// Override defaults.
|
||||
@@ -48,8 +49,8 @@ func main() {
|
||||
generators.DefaultNameSystem(),
|
||||
generators.Packages,
|
||||
); err != nil {
|
||||
glog.Errorf("Error: %v", err)
|
||||
klog.Errorf("Error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
glog.V(2).Info("Completed successfully.")
|
||||
klog.V(2).Info("Completed successfully.")
|
||||
}
|
||||
|
||||
Generated
Vendored
+30
-30
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+19
-19
@@ -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++
|
||||
})
|
||||
|
||||
|
||||
Generated
Vendored
+5
-5
@@ -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
|
||||
|
||||
Generated
Vendored
+3
-3
@@ -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.
|
||||
`),
|
||||
|
||||
Generated
Vendored
+2
-2
@@ -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
|
||||
}
|
||||
|
||||
+4
-4
@@ -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)
|
||||
|
||||
+2
-2
@@ -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)
|
||||
|
||||
+2
-2
@@ -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)
|
||||
}
|
||||
|
||||
+21
-21
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
@@ -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
|
||||
+31
@@ -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)
|
||||
|
||||
-->
|
||||
Generated
Vendored
+11
@@ -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
|
||||
Generated
Vendored
+8
-1
@@ -1,3 +1,10 @@
|
||||
klog
|
||||
====
|
||||
|
||||
klog is a permanant fork of https://github.com/golang/glog. original README from glog is below
|
||||
|
||||
----
|
||||
|
||||
glog
|
||||
====
|
||||
|
||||
@@ -5,7 +12,7 @@ Leveled execution logs for Go.
|
||||
|
||||
This is an efficient pure Go implementation of leveled logs in the
|
||||
manner of the open source C++ package
|
||||
http://code.google.com/p/google-glog
|
||||
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.
|
||||
+9
@@ -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
@@ -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
|
||||
Generated
Vendored
+72
-10
@@ -14,7 +14,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
|
||||
// Package klog 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.
|
||||
//
|
||||
@@ -68,7 +68,7 @@
|
||||
// -vmodule=gopher*=3
|
||||
// sets the V level to 3 in all Go files whose names begin "gopher".
|
||||
//
|
||||
package glog
|
||||
package klog
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@@ -396,13 +396,6 @@ type flushSyncWriter interface {
|
||||
}
|
||||
|
||||
func init() {
|
||||
flag.BoolVar(&logging.toStderr, "logtostderr", false, "log to standard error instead of files")
|
||||
flag.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files")
|
||||
flag.Var(&logging.verbosity, "v", "log level for V logs")
|
||||
flag.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
|
||||
flag.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
|
||||
flag.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")
|
||||
|
||||
// Default stderrThreshold is ERROR.
|
||||
logging.stderrThreshold = errorLog
|
||||
|
||||
@@ -410,6 +403,22 @@ func init() {
|
||||
go logging.flushDaemon()
|
||||
}
|
||||
|
||||
// InitFlags is for explicitly initializing the flags
|
||||
func InitFlags(flagset *flag.FlagSet) {
|
||||
if flagset == nil {
|
||||
flagset = flag.CommandLine
|
||||
}
|
||||
flagset.StringVar(&logging.logDir, "log_dir", "", "If non-empty, write log files in this directory")
|
||||
flagset.StringVar(&logging.logFile, "log_file", "", "If non-empty, use this log file")
|
||||
flagset.BoolVar(&logging.toStderr, "logtostderr", false, "log to standard error instead of files")
|
||||
flagset.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files")
|
||||
flagset.Var(&logging.verbosity, "v", "log level for V logs")
|
||||
flagset.BoolVar(&logging.skipHeaders, "skip_headers", false, "If true, avoid header prefixes in the log messages")
|
||||
flagset.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
|
||||
flagset.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
|
||||
flagset.Var(&logging.traceLocation, "log_backtrace_at", "when logging hits line file:N, emit a stack trace")
|
||||
}
|
||||
|
||||
// Flush flushes all pending log I/O.
|
||||
func Flush() {
|
||||
logging.lockAndFlushAll()
|
||||
@@ -453,6 +462,17 @@ type loggingT struct {
|
||||
// safely using atomic.LoadInt32.
|
||||
vmodule moduleSpec // The state of the -vmodule flag.
|
||||
verbosity Level // V logging level, the value of the -v flag/
|
||||
|
||||
// If non-empty, overrides the choice of directory in which to write logs.
|
||||
// See createLogDirs for the full list of possible destinations.
|
||||
logDir string
|
||||
|
||||
// If non-empty, specifies the path of the file to write logs. mutually exclusive
|
||||
// with the log-dir option.
|
||||
logFile string
|
||||
|
||||
// If true, do not add the prefix headers, useful when used with SetOutput
|
||||
skipHeaders bool
|
||||
}
|
||||
|
||||
// buffer holds a byte Buffer for reuse. The zero value is ready for use.
|
||||
@@ -556,6 +576,9 @@ func (l *loggingT) formatHeader(s severity, file string, line int) *buffer {
|
||||
s = infoLog // for safety.
|
||||
}
|
||||
buf := l.getBuffer()
|
||||
if l.skipHeaders {
|
||||
return buf
|
||||
}
|
||||
|
||||
// Avoid Fprintf, for speed. The format is so simple that we can do it quickly by hand.
|
||||
// It's worth about 3X. Fprintf is hard.
|
||||
@@ -667,6 +690,45 @@ func (l *loggingT) printWithFileLine(s severity, file string, line int, alsoToSt
|
||||
l.output(s, buf, file, line, alsoToStderr)
|
||||
}
|
||||
|
||||
// redirectBuffer is used to set an alternate destination for the logs
|
||||
type redirectBuffer struct {
|
||||
w io.Writer
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Sync() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rb *redirectBuffer) Write(bytes []byte) (n int, err error) {
|
||||
return rb.w.Write(bytes)
|
||||
}
|
||||
|
||||
// SetOutput sets the output destination for all severities
|
||||
func SetOutput(w io.Writer) {
|
||||
for s := fatalLog; s >= infoLog; s-- {
|
||||
rb := &redirectBuffer{
|
||||
w: w,
|
||||
}
|
||||
logging.file[s] = rb
|
||||
}
|
||||
}
|
||||
|
||||
// SetOutputBySeverity sets the output destination for specific severity
|
||||
func SetOutputBySeverity(name string, w io.Writer) {
|
||||
sev, ok := severityByName(name)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("SetOutputBySeverity(%q): unrecognized severity name", name))
|
||||
}
|
||||
rb := &redirectBuffer{
|
||||
w: w,
|
||||
}
|
||||
logging.file[sev] = rb
|
||||
}
|
||||
|
||||
// output writes the data to the log files and releases the buffer.
|
||||
func (l *loggingT) output(s severity, buf *buffer, file string, line int, alsoToStderr bool) {
|
||||
l.mu.Lock()
|
||||
@@ -876,7 +938,7 @@ const flushInterval = 30 * time.Second
|
||||
|
||||
// flushDaemon periodically flushes the log file buffers.
|
||||
func (l *loggingT) flushDaemon() {
|
||||
for _ = range time.NewTicker(flushInterval).C {
|
||||
for range time.NewTicker(flushInterval).C {
|
||||
l.lockAndFlushAll()
|
||||
}
|
||||
}
|
||||
Generated
Vendored
+10
-8
@@ -16,11 +16,10 @@
|
||||
|
||||
// File I/O for logs.
|
||||
|
||||
package glog
|
||||
package klog
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
@@ -36,13 +35,9 @@ var MaxSize uint64 = 1024 * 1024 * 1800
|
||||
// logDirs lists the candidate directories for new log files.
|
||||
var logDirs []string
|
||||
|
||||
// If non-empty, overrides the choice of directory in which to write logs.
|
||||
// See createLogDirs for the full list of possible destinations.
|
||||
var logDir = flag.String("log_dir", "", "If non-empty, write log files in this directory")
|
||||
|
||||
func createLogDirs() {
|
||||
if *logDir != "" {
|
||||
logDirs = append(logDirs, *logDir)
|
||||
if logging.logDir != "" {
|
||||
logDirs = append(logDirs, logging.logDir)
|
||||
}
|
||||
logDirs = append(logDirs, os.TempDir())
|
||||
}
|
||||
@@ -103,6 +98,13 @@ var onceLogDirs sync.Once
|
||||
// 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")
|
||||
Reference in New Issue
Block a user