Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -9,6 +9,7 @@
package main
import (
"encoding/json"
"flag"
"fmt"
"go/types"
@@ -26,16 +27,23 @@ import (
// flags
var (
depsFlag = flag.Bool("deps", false, "show dependencies too")
cgoFlag = flag.Bool("cgo", true, "process cgo files")
mode = flag.String("mode", "metadata", "mode (one of metadata, typecheck, wholeprogram)")
private = flag.Bool("private", false, "show non-exported declarations too")
depsFlag = flag.Bool("deps", false, "show dependencies too")
testFlag = flag.Bool("test", false, "include any tests implied by the patterns")
mode = flag.String("mode", "imports", "mode (one of files, imports, types, syntax, allsyntax)")
private = flag.Bool("private", false, "show non-exported declarations too")
printJSON = flag.Bool("json", false, "print package in JSON form")
cpuprofile = flag.String("cpuprofile", "", "write CPU profile to this file")
memprofile = flag.String("memprofile", "", "write memory profile to this file")
traceFlag = flag.String("trace", "", "write trace log to this file")
buildFlags stringListValue
)
func init() {
flag.Var(&buildFlags, "buildflag", "pass argument to underlying build system (may be repeated)")
}
func usage() {
fmt.Fprintln(os.Stderr, `Usage: gopackages [-deps] [-cgo] [-mode=...] [-private] package...
@@ -102,25 +110,30 @@ func main() {
}()
}
// Load, parse, and type-check the packages named on the command line.
cfg := &packages.Config{
Mode: packages.LoadSyntax,
Tests: *testFlag,
BuildFlags: buildFlags,
}
// -mode flag
load := packages.TypeCheck
switch strings.ToLower(*mode) {
case "metadata":
load = packages.Metadata
case "typecheck":
load = packages.TypeCheck
case "wholeprogram":
load = packages.WholeProgram
case "files":
cfg.Mode = packages.LoadFiles
case "imports":
cfg.Mode = packages.LoadImports
case "types":
cfg.Mode = packages.LoadTypes
case "syntax":
cfg.Mode = packages.LoadSyntax
case "allsyntax":
cfg.Mode = packages.LoadAllSyntax
default:
log.Fatalf("invalid mode: %s", *mode)
}
// Load, parse, and type-check the packages named on the command line.
opts := &packages.Options{
Error: func(error) {}, // we'll take responsibility for printing errors
DisableCgo: !*cgoFlag,
}
lpkgs, err := load(opts, flag.Args()...)
lpkgs, err := packages.Load(cfg, flag.Args()...)
if err != nil {
log.Fatal(err)
}
@@ -161,11 +174,15 @@ func main() {
}
func print(lpkg *packages.Package) {
if *printJSON {
data, _ := json.MarshalIndent(lpkg, "", "\t")
os.Stdout.Write(data)
return
}
// title
var kind string
if lpkg.IsTest {
kind = "test "
}
// TODO(matloob): If IsTest is added back print "test command" or
// "test package" for packages with IsTest == true.
if lpkg.Name == "main" {
kind += "command"
} else {
@@ -173,24 +190,23 @@ func print(lpkg *packages.Package) {
}
fmt.Printf("Go %s %q:\n", kind, lpkg.ID) // unique ID
fmt.Printf("\tpackage %s\n", lpkg.Name)
fmt.Printf("\treflect.Type.PkgPath %q\n", lpkg.PkgPath)
// characterize type info
if lpkg.Type == nil {
if lpkg.Types == nil {
fmt.Printf("\thas no exported type info\n")
} else if !lpkg.Type.Complete() {
} else if !lpkg.Types.Complete() {
fmt.Printf("\thas incomplete exported type info\n")
} else if len(lpkg.Files) == 0 {
} else if len(lpkg.Syntax) == 0 {
fmt.Printf("\thas complete exported type info\n")
} else {
fmt.Printf("\thas complete exported type info and typed ASTs\n")
}
if lpkg.Type != nil && lpkg.IllTyped && len(lpkg.Errors) == 0 {
if lpkg.Types != nil && lpkg.IllTyped && len(lpkg.Errors) == 0 {
fmt.Printf("\thas an error among its dependencies\n")
}
// source files
for _, src := range lpkg.Srcs {
for _, src := range lpkg.GoFiles {
fmt.Printf("\tfile %s\n", src)
}
@@ -216,9 +232,9 @@ func print(lpkg *packages.Package) {
}
// package members (TypeCheck or WholeProgram mode)
if lpkg.Type != nil {
qual := types.RelativeTo(lpkg.Type)
scope := lpkg.Type.Scope()
if lpkg.Types != nil {
qual := types.RelativeTo(lpkg.Types)
scope := lpkg.Types.Scope()
for _, name := range scope.Names() {
obj := scope.Lookup(name)
if !obj.Exported() && !*private {
@@ -239,3 +255,18 @@ func print(lpkg *packages.Package) {
fmt.Println()
}
// stringListValue is a flag.Value that accumulates strings.
// e.g. --flag=one --flag=two would produce []string{"one", "two"}.
type stringListValue []string
func newStringListValue(val []string, p *[]string) *stringListValue {
*p = val
return (*stringListValue)(p)
}
func (ss *stringListValue) Get() interface{} { return []string(*ss) }
func (ss *stringListValue) String() string { return fmt.Sprintf("%q", *ss) }
func (ss *stringListValue) Set(s string) error { *ss = append(*ss, s); return nil }