update kube and vendor dependencies

With kubernetes 1.18 release of client-go, signatures on methods in
generated clientsets, dynamic, metadata, and scale clients have been
modified to accept context.Context as a first argument.
Signatures of Create, Update, and Patch methods have been updated
to accept CreateOptions, UpdateOptions and PatchOptions respectively.
Signatures of Delete and DeleteCollection methods now accept
DeleteOptions by value instead of by reference.
These changes are now accommodated with this PR and client-go
and dependencies are updated to v1.18.0

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal
2020-05-03 21:51:04 +05:30
parent d6be7e120d
commit b72230379f
1008 changed files with 20764 additions and 82152 deletions

View File

@@ -26,6 +26,8 @@ type DefaultPackage struct {
PackageName string
// Import path of the package, and the location on disk of the package.
PackagePath string
// The location of the package on disk.
Source string
// Emitted at the top of every file.
HeaderText []byte
@@ -43,8 +45,9 @@ type DefaultPackage struct {
FilterFunc func(*Context, *types.Type) bool
}
func (d *DefaultPackage) Name() string { return d.PackageName }
func (d *DefaultPackage) Path() string { return d.PackagePath }
func (d *DefaultPackage) Name() string { return d.PackageName }
func (d *DefaultPackage) Path() string { return d.PackagePath }
func (d *DefaultPackage) SourcePath() string { return d.Source }
func (d *DefaultPackage) Filter(c *Context, t *types.Type) bool {
if d.FilterFunc != nil {

View File

@@ -233,11 +233,13 @@ func (c *Context) ExecutePackage(outDir string, p Package) error {
if f == nil {
// This is the first generator to reference this file, so start it.
f = &File{
Name: g.Filename(),
FileType: fileType,
PackageName: p.Name(),
Header: p.Header(g.Filename()),
Imports: map[string]struct{}{},
Name: g.Filename(),
FileType: fileType,
PackageName: p.Name(),
PackagePath: p.Path(),
PackageSourcePath: p.SourcePath(),
Header: p.Header(g.Filename()),
Imports: map[string]struct{}{},
}
files[f.Name] = f
} else {

View File

@@ -31,6 +31,8 @@ type Package interface {
Name() string
// Path returns the package import path.
Path() string
// SourcePath returns the location of the package on disk.
SourcePath() string
// Filter should return true if this package cares about this type.
// Otherwise, this type will be omitted from the type ordering for
@@ -50,14 +52,16 @@ type Package interface {
}
type File struct {
Name string
FileType string
PackageName string
Header []byte
Imports map[string]struct{}
Vars bytes.Buffer
Consts bytes.Buffer
Body bytes.Buffer
Name string
FileType string
PackageName string
Header []byte
PackagePath string
PackageSourcePath string
Imports map[string]struct{}
Vars bytes.Buffer
Consts bytes.Buffer
Body bytes.Buffer
}
type FileType interface {
@@ -156,6 +160,12 @@ type Context struct {
// All the types, in case you want to look up something.
Universe types.Universe
// Incoming imports, i.e. packages importing the given package.
incomingImports map[string][]string
// Incoming transitive imports, i.e. the transitive closure of IncomingImports
incomingTransitiveImports map[string][]string
// All the user-specified packages. This is after recursive expansion.
Inputs []string
@@ -203,11 +213,36 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder
return c, nil
}
// IncomingImports returns the incoming imports for each package. The map is lazily computed.
func (ctxt *Context) IncomingImports() map[string][]string {
if ctxt.incomingImports == nil {
incoming := map[string][]string{}
for _, pkg := range ctxt.Universe {
for imp := range pkg.Imports {
incoming[imp] = append(incoming[imp], pkg.Path)
}
}
ctxt.incomingImports = incoming
}
return ctxt.incomingImports
}
// TransitiveIncomingImports returns the transitive closure of the incoming imports for each package.
// The map is lazily computed.
func (ctxt *Context) TransitiveIncomingImports() map[string][]string {
if ctxt.incomingTransitiveImports == nil {
ctxt.incomingTransitiveImports = transitiveClosure(ctxt.IncomingImports())
}
return ctxt.incomingTransitiveImports
}
// AddDir adds a Go package to the context. The specified path must be a single
// go package import path. GOPATH, GOROOT, and the location of your go binary
// (`which go`) will all be searched, in the normal Go fashion.
// Deprecated. Please use AddDirectory.
func (ctxt *Context) AddDir(path string) error {
ctxt.incomingImports = nil
ctxt.incomingTransitiveImports = nil
return ctxt.builder.AddDirTo(path, &ctxt.Universe)
}
@@ -215,5 +250,7 @@ func (ctxt *Context) AddDir(path string) error {
// single go package import path. GOPATH, GOROOT, and the location of your go
// binary (`which go`) will all be searched, in the normal Go fashion.
func (ctxt *Context) AddDirectory(path string) (*types.Package, error) {
ctxt.incomingImports = nil
ctxt.incomingTransitiveImports = nil
return ctxt.builder.AddDirectoryTo(path, &ctxt.Universe)
}

View File

@@ -17,6 +17,7 @@ limitations under the License.
package generator
import (
"go/token"
"strings"
"k8s.io/klog"
@@ -58,6 +59,11 @@ func golangTrackerLocalName(tracker namer.ImportTracker, t types.Name) string {
// This name collides with some other package
continue
}
// If the import name is a Go keyword, prefix with an underscore.
if token.Lookup(name).IsKeyword() {
name = "_" + name
}
return name
}
panic("can't find import for " + path)

65
vendor/k8s.io/gengo/generator/transitive_closure.go generated vendored Normal file
View File

@@ -0,0 +1,65 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package generator
import "sort"
type edge struct {
from string
to string
}
func transitiveClosure(in map[string][]string) map[string][]string {
adj := make(map[edge]bool)
imports := make(map[string]struct{})
for from, tos := range in {
for _, to := range tos {
adj[edge{from, to}] = true
imports[to] = struct{}{}
}
}
// Warshal's algorithm
for k := range in {
for i := range in {
if !adj[edge{i, k}] {
continue
}
for j := range imports {
if adj[edge{i, j}] {
continue
}
if adj[edge{k, j}] {
adj[edge{i, j}] = true
}
}
}
}
out := make(map[string][]string, len(in))
for i := range in {
for j := range imports {
if adj[edge{i, j}] {
out[i] = append(out[i], j)
}
}
sort.Strings(out[i])
}
return out
}