mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Unify logging in generators and avoid annoying logs.
This commit is contained in:
		@@ -20,14 +20,13 @@ package main
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/args"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/args"
 | 
				
			||||||
	clientgenargs "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
 | 
						clientgenargs "k8s.io/kubernetes/cmd/libs/go2idl/client-gen/args"
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/generators"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/api/unversioned"
 | 
						"k8s.io/kubernetes/pkg/api/unversioned"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"strings"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/golang/glog"
 | 
						"github.com/golang/glog"
 | 
				
			||||||
	flag "github.com/spf13/pflag"
 | 
						flag "github.com/spf13/pflag"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -182,7 +181,7 @@ func main() {
 | 
				
			|||||||
			IncludedTypesOverrides:  includedTypesOverrides,
 | 
								IncludedTypesOverrides:  includedTypesOverrides,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		fmt.Printf("==arguments: %v\n", arguments)
 | 
							glog.Infof("==arguments: %v\n", arguments)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if err := arguments.Execute(
 | 
						if err := arguments.Execute(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,13 +22,14 @@ import (
 | 
				
			|||||||
	"go/format"
 | 
						"go/format"
 | 
				
			||||||
	"io"
 | 
						"io"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"log"
 | 
					 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/namer"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/namer"
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/types"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/golang/glog"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func errs2strings(errors []error) []string {
 | 
					func errs2strings(errors []error) []string {
 | 
				
			||||||
@@ -63,7 +64,7 @@ type DefaultFileType struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
 | 
					func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
 | 
				
			||||||
	log.Printf("Assembling file %q", pathname)
 | 
						glog.V(0).Infof("Assembling file %q", pathname)
 | 
				
			||||||
	destFile, err := os.Create(pathname)
 | 
						destFile, err := os.Create(pathname)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
@@ -90,7 +91,7 @@ func (ft DefaultFileType) AssembleFile(f *File, pathname string) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (ft DefaultFileType) VerifyFile(f *File, pathname string) error {
 | 
					func (ft DefaultFileType) VerifyFile(f *File, pathname string) error {
 | 
				
			||||||
	log.Printf("Verifying file %q", pathname)
 | 
						glog.V(0).Infof("Verifying file %q", pathname)
 | 
				
			||||||
	friendlyName := filepath.Join(f.PackageName, f.Name)
 | 
						friendlyName := filepath.Join(f.PackageName, f.Name)
 | 
				
			||||||
	b := &bytes.Buffer{}
 | 
						b := &bytes.Buffer{}
 | 
				
			||||||
	et := NewErrorTracker(b)
 | 
						et := NewErrorTracker(b)
 | 
				
			||||||
@@ -210,7 +211,7 @@ func (c *Context) addNameSystems(namers namer.NameSystems) *Context {
 | 
				
			|||||||
// import path already, this will be appended to 'outDir'.
 | 
					// import path already, this will be appended to 'outDir'.
 | 
				
			||||||
func (c *Context) ExecutePackage(outDir string, p Package) error {
 | 
					func (c *Context) ExecutePackage(outDir string, p Package) error {
 | 
				
			||||||
	path := filepath.Join(outDir, p.Path())
 | 
						path := filepath.Join(outDir, p.Path())
 | 
				
			||||||
	log.Printf("Processing package %q, disk location %q", p.Name(), path)
 | 
						glog.V(0).Infof("Processing package %q, disk location %q", p.Name(), path)
 | 
				
			||||||
	// Filter out any types the *package* doesn't care about.
 | 
						// Filter out any types the *package* doesn't care about.
 | 
				
			||||||
	packageContext := c.filteredBy(p.Filter)
 | 
						packageContext := c.filteredBy(p.Filter)
 | 
				
			||||||
	os.MkdirAll(path, 0755)
 | 
						os.MkdirAll(path, 0755)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,8 @@ import (
 | 
				
			|||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/generator"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/generator"
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/namer"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/namer"
 | 
				
			||||||
	"k8s.io/kubernetes/cmd/libs/go2idl/types"
 | 
						"k8s.io/kubernetes/cmd/libs/go2idl/types"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"github.com/golang/glog"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -200,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)
 | 
								return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, actualPath, err)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for v := range f.Imports {
 | 
							for v := range f.Imports {
 | 
				
			||||||
			// fmt.Printf("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
 | 
								glog.V(4).Infof("Checking %v matches %v: %v\n", r.SelectorRegexp, v, re.MatchString(v))
 | 
				
			||||||
			if !re.MatchString(v) {
 | 
								if !re.MatchString(v) {
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for _, forbidden := range r.ForbiddenPrefixes {
 | 
								for _, forbidden := range r.ForbiddenPrefixes {
 | 
				
			||||||
				// fmt.Printf("Checking %v against %v\n", v, forbidden)
 | 
									glog.V(4).Infof("Checking %v against %v\n", v, forbidden)
 | 
				
			||||||
				if strings.HasPrefix(v, forbidden) {
 | 
									if strings.HasPrefix(v, forbidden) {
 | 
				
			||||||
					return fmt.Errorf("import %v has forbidden prefix %v", v, forbidden)
 | 
										return fmt.Errorf("import %v has forbidden prefix %v", v, forbidden)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			found := false
 | 
								found := false
 | 
				
			||||||
			for _, allowed := range r.AllowedPrefixes {
 | 
								for _, allowed := range r.AllowedPrefixes {
 | 
				
			||||||
				fmt.Printf("Checking %v against %v\n", v, allowed)
 | 
									glog.V(0).Infof("Checking %v against %v\n", v, allowed)
 | 
				
			||||||
				if strings.HasPrefix(v, allowed) {
 | 
									if strings.HasPrefix(v, allowed) {
 | 
				
			||||||
					found = true
 | 
										found = true
 | 
				
			||||||
					break
 | 
										break
 | 
				
			||||||
@@ -224,7 +226,7 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if len(rules.Rules) > 0 {
 | 
						if len(rules.Rules) > 0 {
 | 
				
			||||||
		fmt.Printf("%v passes rules found in %v\n", path, actualPath)
 | 
							glog.V(0).Infof("%v passes rules found in %v\n", path, actualPath)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,7 +79,7 @@ func New() *Builder {
 | 
				
			|||||||
			// The returned string will have some/path/bin/go, so remove the last two elements.
 | 
								// 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")))
 | 
								c.GOROOT = filepath.Dir(filepath.Dir(strings.Trim(string(p), "\n")))
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			fmt.Printf("Warning: $GOROOT not set, and unable to run `which go` to find it: %v\n", err)
 | 
								glog.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
 | 
						// Force this to off, since we don't properly parse CGo.  All symbols must
 | 
				
			||||||
@@ -304,7 +304,7 @@ func (b *Builder) importer(imports map[string]*tc.Package, path string) (*tc.Pac
 | 
				
			|||||||
	pkg, err := b.typeCheckPackage(path)
 | 
						pkg, err := b.typeCheckPackage(path)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if ignoreError && pkg != nil {
 | 
							if ignoreError && pkg != nil {
 | 
				
			||||||
			fmt.Printf("type checking encountered some errors in %q, but ignoring.\n", path)
 | 
								glog.V(2).Infof("type checking encountered some errors in %q, but ignoring.\n", path)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -350,7 +350,7 @@ func (b *Builder) typeCheckPackage(id string) (*tc.Package, error) {
 | 
				
			|||||||
		// method. So there can't be cycles in the import graph.
 | 
							// method. So there can't be cycles in the import graph.
 | 
				
			||||||
		Importer: importAdapter{b},
 | 
							Importer: importAdapter{b},
 | 
				
			||||||
		Error: func(err error) {
 | 
							Error: func(err error) {
 | 
				
			||||||
			fmt.Printf("type checker error: %v\n", err)
 | 
								glog.V(2).Infof("type checker error: %v\n", err)
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pkg, err := c.Check(id, b.fset, files, nil)
 | 
						pkg, err := c.Check(id, b.fset, files, nil)
 | 
				
			||||||
@@ -685,7 +685,7 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
 | 
				
			|||||||
			return out
 | 
								return out
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		out.Kind = types.Unsupported
 | 
							out.Kind = types.Unsupported
 | 
				
			||||||
		fmt.Printf("Making unsupported type entry %q for: %#v\n", out, t)
 | 
							glog.Warningf("Making unsupported type entry %q for: %#v\n", out, t)
 | 
				
			||||||
		return out
 | 
							return out
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user