From a3d33909fadc3e62417efeff53b0840b8f5269c2 Mon Sep 17 00:00:00 2001 From: Mike Dame Date: Mon, 28 Oct 2019 17:04:26 -0400 Subject: [PATCH] bump(*): remove glog --- glide.lock | 8 +- vendor/github.com/golang/glog/LICENSE | 191 --- vendor/github.com/golang/glog/README | 44 - vendor/github.com/golang/glog/glog.go | 1180 ----------------- vendor/github.com/golang/glog/glog_file.go | 124 -- vendor/github.com/golang/glog/glog_test.go | 415 ------ vendor/k8s.io/gengo/.travis.yml | 2 +- vendor/k8s.io/gengo/args/args.go | 3 - .../defaulter-gen/generators/defaulter.go | 6 +- .../gengo/examples/import-boss/Makefile | 28 - .../import-boss/generators/import_restrict.go | 212 +-- .../k8s.io/gengo/examples/import-boss/main.go | 57 +- .../import-boss/tests/inverse/a/doc.go | 6 - .../import-boss/tests/inverse/b/doc.go | 7 - .../import-boss/tests/inverse/c/doc.go | 7 - .../import-boss/tests/inverse/d/doc.go | 6 - .../import-boss/tests/inverse/lib/doc.go | 6 - .../import-boss/tests/inverse/lib/lib_test.go | 5 - .../inverse/lib/nonprod/.import-restrictions | 9 - .../tests/inverse/lib/nonprod/doc.go | 2 - .../inverse/lib/private/.import-restrictions | 11 - .../tests/inverse/lib/private/doc.go | 1 - .../tests/inverse/lib/public/doc.go | 1 - .../tests/inverse/lib/quarantine/doc.go | 6 - .../tests/rules/a/.import-restrictions | 11 - .../examples/import-boss/tests/rules/a/doc.go | 5 - .../tests/rules/b/.import-restrictions | 11 - .../examples/import-boss/tests/rules/b/doc.go | 6 - .../examples/import-boss/tests/rules/c/doc.go | 1 - .../tests/rules/nested/.import-restrictions | 10 - .../import-boss/tests/rules/nested/doc.go | 5 - .../rules/nested/nested/.import-restrictions | 10 - .../tests/rules/nested/nested/doc.go | 5 - .../nested/nested/nested/.import-restrictions | 10 - .../tests/rules/nested/nested/nested/doc.go | 5 - .../rules/nested/nested/nested/inherit/doc.go | 5 - .../k8s.io/gengo/generator/default_package.go | 7 +- vendor/k8s.io/gengo/generator/execute.go | 12 +- vendor/k8s.io/gengo/generator/generator.go | 53 +- .../k8s.io/gengo/generator/import_tracker.go | 6 - .../gengo/generator/import_tracker_test.go | 75 -- .../gengo/generator/transitive_closure.go | 65 - .../generator/transitive_closure_test.go | 64 - vendor/k8s.io/gengo/parser/parse.go | 14 +- vendor/k8s.io/kubernetes/CHANGELOG-1.16.md | 123 +- .../kubernetes/api/openapi-spec/swagger.json | 2 +- .../build/build-image/cross/Dockerfile | 2 +- .../build/build-image/cross/VERSION | 2 +- .../k8s.io/kubernetes/build/dependencies.yaml | 2 +- vendor/k8s.io/kubernetes/build/lib/release.sh | 5 +- vendor/k8s.io/kubernetes/build/root/.bazelrc | 1 + vendor/k8s.io/kubernetes/build/root/WORKSPACE | 6 +- .../kubernetes/cluster/gce/gci/configure.sh | 2 +- .../kubernetes/cluster/get-kube-binaries.sh | 4 +- vendor/k8s.io/kubernetes/cluster/get-kube.sh | 19 +- .../pkg/controller/disruption/disruption.go | 16 +- .../azure/azure_vmss.go | 5 + .../test/e2e/storage/testsuites/BUILD | 1 - .../test/e2e/storage/testsuites/volumemode.go | 38 +- .../test/e2e_node/startup_probe_test.go | 7 +- vendor/k8s.io/kubernetes/test/images/Makefile | 2 +- 61 files changed, 265 insertions(+), 2689 deletions(-) delete mode 100644 vendor/github.com/golang/glog/LICENSE delete mode 100644 vendor/github.com/golang/glog/README delete mode 100644 vendor/github.com/golang/glog/glog.go delete mode 100644 vendor/github.com/golang/glog/glog_file.go delete mode 100644 vendor/github.com/golang/glog/glog_test.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/Makefile delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/a/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/b/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/c/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/d/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/lib_test.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/public/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/c/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/.import-restrictions delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/doc.go delete mode 100644 vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/inherit/doc.go delete mode 100644 vendor/k8s.io/gengo/generator/import_tracker_test.go delete mode 100644 vendor/k8s.io/gengo/generator/transitive_closure.go delete mode 100644 vendor/k8s.io/gengo/generator/transitive_closure_test.go diff --git a/glide.lock b/glide.lock index bfa0e2bcf..2dd04638f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: f82bf395df6f00004b1794606a9256d5c69b62deb5498b574a08b2b5d15f7a6a -updated: 2019-10-12T11:22:30.564437-04:00 +updated: 2019-10-28T17:02:34.793943-04:00 imports: - name: cloud.google.com/go version: 8c41231e01b2085512d98153bcffb847ff9b4b9f @@ -32,8 +32,6 @@ imports: subpackages: - proto - sortkeys -- name: github.com/golang/glog - version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998 - name: github.com/golang/protobuf version: b5d812f8a3706043e23a9cd5babf2e5423744d30 subpackages: @@ -362,7 +360,7 @@ imports: - featuregate - logs - name: k8s.io/gengo - version: 7fa3014cb28f99ce2d9e803bcd3efa7edd4effa9 + version: 26a664648505d962332bda642b27306bc10d1082 - name: k8s.io/klog version: 3ca30a56d8a775276f9cdae009ba326fdc05af7f - name: k8s.io/kube-openapi @@ -370,7 +368,7 @@ imports: subpackages: - pkg/util/proto - name: k8s.io/kubernetes - version: c97fe5036ef3df2967d086711e6c0c405941e14b + version: b1e4a13ba1f74f363154ea2e1d36047ea55190a3 subpackages: - pkg/api/legacyscheme - pkg/api/testapi diff --git a/vendor/github.com/golang/glog/LICENSE b/vendor/github.com/golang/glog/LICENSE deleted file mode 100644 index 37ec93a14..000000000 --- a/vendor/github.com/golang/glog/LICENSE +++ /dev/null @@ -1,191 +0,0 @@ -Apache License -Version 2.0, January 2004 -http://www.apache.org/licenses/ - -TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - -1. Definitions. - -"License" shall mean the terms and conditions for use, reproduction, and -distribution as defined by Sections 1 through 9 of this document. - -"Licensor" shall mean the copyright owner or entity authorized by the copyright -owner that is granting the License. - -"Legal Entity" shall mean the union of the acting entity and all other entities -that control, are controlled by, or are under common control with that entity. -For the purposes of this definition, "control" means (i) the power, direct or -indirect, to cause the direction or management of such entity, whether by -contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the -outstanding shares, or (iii) beneficial ownership of such entity. - -"You" (or "Your") shall mean an individual or Legal Entity exercising -permissions granted by this License. - -"Source" form shall mean the preferred form for making modifications, including -but not limited to software source code, documentation source, and configuration -files. - -"Object" form shall mean any form resulting from mechanical transformation or -translation of a Source form, including but not limited to compiled object code, -generated documentation, and conversions to other media types. - -"Work" shall mean the work of authorship, whether in Source or Object form, made -available under the License, as indicated by a copyright notice that is included -in or attached to the work (an example is provided in the Appendix below). - -"Derivative Works" shall mean any work, whether in Source or Object form, that -is based on (or derived from) the Work and for which the editorial revisions, -annotations, elaborations, or other modifications represent, as a whole, an -original work of authorship. For the purposes of this License, Derivative Works -shall not include works that remain separable from, or merely link (or bind by -name) to the interfaces of, the Work and Derivative Works thereof. - -"Contribution" shall mean any work of authorship, including the original version -of the Work and any modifications or additions to that Work or Derivative Works -thereof, that is intentionally submitted to Licensor for inclusion in the Work -by the copyright owner or by an individual or Legal Entity authorized to submit -on behalf of the copyright owner. For the purposes of this definition, -"submitted" means any form of electronic, verbal, or written communication sent -to the Licensor or its representatives, including but not limited to -communication on electronic mailing lists, source code control systems, and -issue tracking systems that are managed by, or on behalf of, the Licensor for -the purpose of discussing and improving the Work, but excluding communication -that is conspicuously marked or otherwise designated in writing by the copyright -owner as "Not a Contribution." - -"Contributor" shall mean Licensor and any individual or Legal Entity on behalf -of whom a Contribution has been received by Licensor and subsequently -incorporated within the Work. - -2. Grant of Copyright License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable copyright license to reproduce, prepare Derivative Works of, -publicly display, publicly perform, sublicense, and distribute the Work and such -Derivative Works in Source or Object form. - -3. Grant of Patent License. - -Subject to the terms and conditions of this License, each Contributor hereby -grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, -irrevocable (except as stated in this section) patent license to make, have -made, use, offer to sell, sell, import, and otherwise transfer the Work, where -such license applies only to those patent claims licensable by such Contributor -that are necessarily infringed by their Contribution(s) alone or by combination -of their Contribution(s) with the Work to which such Contribution(s) was -submitted. If You institute patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Work or a -Contribution incorporated within the Work constitutes direct or contributory -patent infringement, then any patent licenses granted to You under this License -for that Work shall terminate as of the date such litigation is filed. - -4. Redistribution. - -You may reproduce and distribute copies of the Work or Derivative Works thereof -in any medium, with or without modifications, and in Source or Object form, -provided that You meet the following conditions: - -You must give any other recipients of the Work or Derivative Works a copy of -this License; and -You must cause any modified files to carry prominent notices stating that You -changed the files; and -You must retain, in the Source form of any Derivative Works that You distribute, -all copyright, patent, trademark, and attribution notices from the Source form -of the Work, excluding those notices that do not pertain to any part of the -Derivative Works; and -If the Work includes a "NOTICE" text file as part of its distribution, then any -Derivative Works that You distribute must include a readable copy of the -attribution notices contained within such NOTICE file, excluding those notices -that do not pertain to any part of the Derivative Works, in at least one of the -following places: within a NOTICE text file distributed as part of the -Derivative Works; within the Source form or documentation, if provided along -with the Derivative Works; or, within a display generated by the Derivative -Works, if and wherever such third-party notices normally appear. The contents of -the NOTICE file are for informational purposes only and do not modify the -License. You may add Your own attribution notices within Derivative Works that -You distribute, alongside or as an addendum to the NOTICE text from the Work, -provided that such additional attribution notices cannot be construed as -modifying the License. -You may add Your own copyright statement to Your modifications and may provide -additional or different license terms and conditions for use, reproduction, or -distribution of Your modifications, or for any such Derivative Works as a whole, -provided Your use, reproduction, and distribution of the Work otherwise complies -with the conditions stated in this License. - -5. Submission of Contributions. - -Unless You explicitly state otherwise, any Contribution intentionally submitted -for inclusion in the Work by You to the Licensor shall be under the terms and -conditions of this License, without any additional terms or conditions. -Notwithstanding the above, nothing herein shall supersede or modify the terms of -any separate license agreement you may have executed with Licensor regarding -such Contributions. - -6. Trademarks. - -This License does not grant permission to use the trade names, trademarks, -service marks, or product names of the Licensor, except as required for -reasonable and customary use in describing the origin of the Work and -reproducing the content of the NOTICE file. - -7. Disclaimer of Warranty. - -Unless required by applicable law or agreed to in writing, Licensor provides the -Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, -including, without limitation, any warranties or conditions of TITLE, -NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are -solely responsible for determining the appropriateness of using or -redistributing the Work and assume any risks associated with Your exercise of -permissions under this License. - -8. Limitation of Liability. - -In no event and under no legal theory, whether in tort (including negligence), -contract, or otherwise, unless required by applicable law (such as deliberate -and grossly negligent acts) or agreed to in writing, shall any Contributor be -liable to You for damages, including any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License or -out of the use or inability to use the Work (including but not limited to -damages for loss of goodwill, work stoppage, computer failure or malfunction, or -any and all other commercial damages or losses), even if such Contributor has -been advised of the possibility of such damages. - -9. Accepting Warranty or Additional Liability. - -While redistributing the Work or Derivative Works thereof, You may choose to -offer, and charge a fee for, acceptance of support, warranty, indemnity, or -other liability obligations and/or rights consistent with this License. However, -in accepting such obligations, You may act only on Your own behalf and on Your -sole responsibility, not on behalf of any other Contributor, and only if You -agree to indemnify, defend, and hold each Contributor harmless for any liability -incurred by, or claims asserted against, such Contributor by reason of your -accepting any such warranty or additional liability. - -END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work - -To apply the Apache License to your work, attach the following boilerplate -notice, with the fields enclosed by brackets "[]" replaced with your own -identifying information. (Don't include the brackets!) The text should be -enclosed in the appropriate comment syntax for the file format. We also -recommend that a file or class name and description of purpose be included on -the same "printed page" as the copyright notice for easier identification within -third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/golang/glog/README b/vendor/github.com/golang/glog/README deleted file mode 100644 index 387b4eb68..000000000 --- a/vendor/github.com/golang/glog/README +++ /dev/null @@ -1,44 +0,0 @@ -glog -==== - -Leveled execution logs for Go. - -This is an efficient pure Go implementation of leveled logs in the -manner of the open source C++ package - https://github.com/google/glog - -By binding methods to booleans it is possible to use the log package -without paying the expense of evaluating the arguments to the log. -Through the -vmodule flag, the package also provides fine-grained -control over logging at the file level. - -The comment from glog.go introduces the ideas: - - Package glog implements logging analogous to the Google-internal - C++ INFO/ERROR/V setup. It provides functions Info, Warning, - Error, Fatal, plus formatting variants such as Infof. It - also provides V-style logging controlled by the -v and - -vmodule=file=2 flags. - - Basic examples: - - glog.Info("Prepare to repel boarders") - - glog.Fatalf("Initialization failed: %s", err) - - See the documentation for the V function for an explanation - of these examples: - - if glog.V(2) { - glog.Info("Starting transaction...") - } - - glog.V(2).Infoln("Processed", nItems, "elements") - - -The repository contains an open source version of the log package -used inside Google. The master copy of the source lives inside -Google, not here. The code in this repo is for export only and is not itself -under development. Feature requests will be ignored. - -Send bug reports to golang-nuts@googlegroups.com. diff --git a/vendor/github.com/golang/glog/glog.go b/vendor/github.com/golang/glog/glog.go deleted file mode 100644 index 54bd7afdc..000000000 --- a/vendor/github.com/golang/glog/glog.go +++ /dev/null @@ -1,1180 +0,0 @@ -// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ -// -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup. -// It provides functions Info, Warning, Error, Fatal, plus formatting variants such as -// Infof. It also provides V-style logging controlled by the -v and -vmodule=file=2 flags. -// -// Basic examples: -// -// glog.Info("Prepare to repel boarders") -// -// glog.Fatalf("Initialization failed: %s", err) -// -// See the documentation for the V function for an explanation of these examples: -// -// if glog.V(2) { -// glog.Info("Starting transaction...") -// } -// -// glog.V(2).Infoln("Processed", nItems, "elements") -// -// Log output is buffered and written periodically using Flush. Programs -// should call Flush before exiting to guarantee all log output is written. -// -// By default, all log statements write to files in a temporary directory. -// This package provides several flags that modify this behavior. -// As a result, flag.Parse must be called before any logging is done. -// -// -logtostderr=false -// Logs are written to standard error instead of to files. -// -alsologtostderr=false -// Logs are written to standard error as well as to files. -// -stderrthreshold=ERROR -// Log events at or above this severity are logged to standard -// error as well as to files. -// -log_dir="" -// Log files will be written to this directory instead of the -// default temporary directory. -// -// Other flags provide aids to debugging. -// -// -log_backtrace_at="" -// When set to a file and line number holding a logging statement, -// such as -// -log_backtrace_at=gopherflakes.go:234 -// a stack trace will be written to the Info log whenever execution -// hits that statement. (Unlike with -vmodule, the ".go" must be -// present.) -// -v=0 -// Enable V-leveled logging at the specified level. -// -vmodule="" -// The syntax of the argument is a comma-separated list of pattern=N, -// where pattern is a literal file name (minus the ".go" suffix) or -// "glob" pattern and N is a V level. For instance, -// -vmodule=gopher*=3 -// sets the V level to 3 in all Go files whose names begin "gopher". -// -package glog - -import ( - "bufio" - "bytes" - "errors" - "flag" - "fmt" - "io" - stdLog "log" - "os" - "path/filepath" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" -) - -// severity identifies the sort of log: info, warning etc. It also implements -// the flag.Value interface. The -stderrthreshold flag is of type severity and -// should be modified only through the flag.Value interface. The values match -// the corresponding constants in C++. -type severity int32 // sync/atomic int32 - -// These constants identify the log levels in order of increasing severity. -// A message written to a high-severity log file is also written to each -// lower-severity log file. -const ( - infoLog severity = iota - warningLog - errorLog - fatalLog - numSeverity = 4 -) - -const severityChar = "IWEF" - -var severityName = []string{ - infoLog: "INFO", - warningLog: "WARNING", - errorLog: "ERROR", - fatalLog: "FATAL", -} - -// get returns the value of the severity. -func (s *severity) get() severity { - return severity(atomic.LoadInt32((*int32)(s))) -} - -// set sets the value of the severity. -func (s *severity) set(val severity) { - atomic.StoreInt32((*int32)(s), int32(val)) -} - -// String is part of the flag.Value interface. -func (s *severity) String() string { - return strconv.FormatInt(int64(*s), 10) -} - -// Get is part of the flag.Value interface. -func (s *severity) Get() interface{} { - return *s -} - -// Set is part of the flag.Value interface. -func (s *severity) Set(value string) error { - var threshold severity - // Is it a known name? - if v, ok := severityByName(value); ok { - threshold = v - } else { - v, err := strconv.Atoi(value) - if err != nil { - return err - } - threshold = severity(v) - } - logging.stderrThreshold.set(threshold) - return nil -} - -func severityByName(s string) (severity, bool) { - s = strings.ToUpper(s) - for i, name := range severityName { - if name == s { - return severity(i), true - } - } - return 0, false -} - -// OutputStats tracks the number of output lines and bytes written. -type OutputStats struct { - lines int64 - bytes int64 -} - -// Lines returns the number of lines written. -func (s *OutputStats) Lines() int64 { - return atomic.LoadInt64(&s.lines) -} - -// Bytes returns the number of bytes written. -func (s *OutputStats) Bytes() int64 { - return atomic.LoadInt64(&s.bytes) -} - -// Stats tracks the number of lines of output and number of bytes -// per severity level. Values must be read with atomic.LoadInt64. -var Stats struct { - Info, Warning, Error OutputStats -} - -var severityStats = [numSeverity]*OutputStats{ - infoLog: &Stats.Info, - warningLog: &Stats.Warning, - errorLog: &Stats.Error, -} - -// Level is exported because it appears in the arguments to V and is -// the type of the v flag, which can be set programmatically. -// It's a distinct type because we want to discriminate it from logType. -// Variables of type level are only changed under logging.mu. -// The -v flag is read only with atomic ops, so the state of the logging -// module is consistent. - -// Level is treated as a sync/atomic int32. - -// Level specifies a level of verbosity for V logs. *Level implements -// flag.Value; the -v flag is of type Level and should be modified -// only through the flag.Value interface. -type Level int32 - -// get returns the value of the Level. -func (l *Level) get() Level { - return Level(atomic.LoadInt32((*int32)(l))) -} - -// set sets the value of the Level. -func (l *Level) set(val Level) { - atomic.StoreInt32((*int32)(l), int32(val)) -} - -// String is part of the flag.Value interface. -func (l *Level) String() string { - return strconv.FormatInt(int64(*l), 10) -} - -// Get is part of the flag.Value interface. -func (l *Level) Get() interface{} { - return *l -} - -// Set is part of the flag.Value interface. -func (l *Level) Set(value string) error { - v, err := strconv.Atoi(value) - if err != nil { - return err - } - logging.mu.Lock() - defer logging.mu.Unlock() - logging.setVState(Level(v), logging.vmodule.filter, false) - return nil -} - -// moduleSpec represents the setting of the -vmodule flag. -type moduleSpec struct { - filter []modulePat -} - -// modulePat contains a filter for the -vmodule flag. -// It holds a verbosity level and a file pattern to match. -type modulePat struct { - pattern string - literal bool // The pattern is a literal string - level Level -} - -// match reports whether the file matches the pattern. It uses a string -// comparison if the pattern contains no metacharacters. -func (m *modulePat) match(file string) bool { - if m.literal { - return file == m.pattern - } - match, _ := filepath.Match(m.pattern, file) - return match -} - -func (m *moduleSpec) String() string { - // Lock because the type is not atomic. TODO: clean this up. - logging.mu.Lock() - defer logging.mu.Unlock() - var b bytes.Buffer - for i, f := range m.filter { - if i > 0 { - b.WriteRune(',') - } - fmt.Fprintf(&b, "%s=%d", f.pattern, f.level) - } - return b.String() -} - -// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the -// struct is not exported. -func (m *moduleSpec) Get() interface{} { - return nil -} - -var errVmoduleSyntax = errors.New("syntax error: expect comma-separated list of filename=N") - -// Syntax: -vmodule=recordio=2,file=1,gfs*=3 -func (m *moduleSpec) Set(value string) error { - var filter []modulePat - for _, pat := range strings.Split(value, ",") { - if len(pat) == 0 { - // Empty strings such as from a trailing comma can be ignored. - continue - } - patLev := strings.Split(pat, "=") - if len(patLev) != 2 || len(patLev[0]) == 0 || len(patLev[1]) == 0 { - return errVmoduleSyntax - } - pattern := patLev[0] - v, err := strconv.Atoi(patLev[1]) - if err != nil { - return errors.New("syntax error: expect comma-separated list of filename=N") - } - if v < 0 { - return errors.New("negative value for vmodule level") - } - if v == 0 { - continue // Ignore. It's harmless but no point in paying the overhead. - } - // TODO: check syntax of filter? - filter = append(filter, modulePat{pattern, isLiteral(pattern), Level(v)}) - } - logging.mu.Lock() - defer logging.mu.Unlock() - logging.setVState(logging.verbosity, filter, true) - return nil -} - -// isLiteral reports whether the pattern is a literal string, that is, has no metacharacters -// that require filepath.Match to be called to match the pattern. -func isLiteral(pattern string) bool { - return !strings.ContainsAny(pattern, `\*?[]`) -} - -// traceLocation represents the setting of the -log_backtrace_at flag. -type traceLocation struct { - file string - line int -} - -// isSet reports whether the trace location has been specified. -// logging.mu is held. -func (t *traceLocation) isSet() bool { - return t.line > 0 -} - -// match reports whether the specified file and line matches the trace location. -// The argument file name is the full path, not the basename specified in the flag. -// logging.mu is held. -func (t *traceLocation) match(file string, line int) bool { - if t.line != line { - return false - } - if i := strings.LastIndex(file, "/"); i >= 0 { - file = file[i+1:] - } - return t.file == file -} - -func (t *traceLocation) String() string { - // Lock because the type is not atomic. TODO: clean this up. - logging.mu.Lock() - defer logging.mu.Unlock() - return fmt.Sprintf("%s:%d", t.file, t.line) -} - -// Get is part of the (Go 1.2) flag.Getter interface. It always returns nil for this flag type since the -// struct is not exported -func (t *traceLocation) Get() interface{} { - return nil -} - -var errTraceSyntax = errors.New("syntax error: expect file.go:234") - -// Syntax: -log_backtrace_at=gopherflakes.go:234 -// Note that unlike vmodule the file extension is included here. -func (t *traceLocation) Set(value string) error { - if value == "" { - // Unset. - t.line = 0 - t.file = "" - } - fields := strings.Split(value, ":") - if len(fields) != 2 { - return errTraceSyntax - } - file, line := fields[0], fields[1] - if !strings.Contains(file, ".") { - return errTraceSyntax - } - v, err := strconv.Atoi(line) - if err != nil { - return errTraceSyntax - } - if v <= 0 { - return errors.New("negative or zero value for level") - } - logging.mu.Lock() - defer logging.mu.Unlock() - t.line = v - t.file = file - return nil -} - -// flushSyncWriter is the interface satisfied by logging destinations. -type flushSyncWriter interface { - Flush() error - Sync() error - io.Writer -} - -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 - - logging.setVState(0, nil, false) - go logging.flushDaemon() -} - -// Flush flushes all pending log I/O. -func Flush() { - logging.lockAndFlushAll() -} - -// loggingT collects all the global state of the logging setup. -type loggingT struct { - // Boolean flags. Not handled atomically because the flag.Value interface - // does not let us avoid the =true, and that shorthand is necessary for - // compatibility. TODO: does this matter enough to fix? Seems unlikely. - toStderr bool // The -logtostderr flag. - alsoToStderr bool // The -alsologtostderr flag. - - // Level flag. Handled atomically. - stderrThreshold severity // The -stderrthreshold flag. - - // freeList is a list of byte buffers, maintained under freeListMu. - freeList *buffer - // freeListMu maintains the free list. It is separate from the main mutex - // so buffers can be grabbed and printed to without holding the main lock, - // for better parallelization. - freeListMu sync.Mutex - - // mu protects the remaining elements of this structure and is - // used to synchronize logging. - mu sync.Mutex - // file holds writer for each of the log types. - file [numSeverity]flushSyncWriter - // pcs is used in V to avoid an allocation when computing the caller's PC. - pcs [1]uintptr - // vmap is a cache of the V Level for each V() call site, identified by PC. - // It is wiped whenever the vmodule flag changes state. - vmap map[uintptr]Level - // filterLength stores the length of the vmodule filter chain. If greater - // than zero, it means vmodule is enabled. It may be read safely - // using sync.LoadInt32, but is only modified under mu. - filterLength int32 - // traceLocation is the state of the -log_backtrace_at flag. - traceLocation traceLocation - // These flags are modified only under lock, although verbosity may be fetched - // safely using atomic.LoadInt32. - vmodule moduleSpec // The state of the -vmodule flag. - verbosity Level // V logging level, the value of the -v flag/ -} - -// buffer holds a byte Buffer for reuse. The zero value is ready for use. -type buffer struct { - bytes.Buffer - tmp [64]byte // temporary byte array for creating headers. - next *buffer -} - -var logging loggingT - -// setVState sets a consistent state for V logging. -// l.mu is held. -func (l *loggingT) setVState(verbosity Level, filter []modulePat, setFilter bool) { - // Turn verbosity off so V will not fire while we are in transition. - logging.verbosity.set(0) - // Ditto for filter length. - atomic.StoreInt32(&logging.filterLength, 0) - - // Set the new filters and wipe the pc->Level map if the filter has changed. - if setFilter { - logging.vmodule.filter = filter - logging.vmap = make(map[uintptr]Level) - } - - // Things are consistent now, so enable filtering and verbosity. - // They are enabled in order opposite to that in V. - atomic.StoreInt32(&logging.filterLength, int32(len(filter))) - logging.verbosity.set(verbosity) -} - -// getBuffer returns a new, ready-to-use buffer. -func (l *loggingT) getBuffer() *buffer { - l.freeListMu.Lock() - b := l.freeList - if b != nil { - l.freeList = b.next - } - l.freeListMu.Unlock() - if b == nil { - b = new(buffer) - } else { - b.next = nil - b.Reset() - } - return b -} - -// putBuffer returns a buffer to the free list. -func (l *loggingT) putBuffer(b *buffer) { - if b.Len() >= 256 { - // Let big buffers die a natural death. - return - } - l.freeListMu.Lock() - b.next = l.freeList - l.freeList = b - l.freeListMu.Unlock() -} - -var timeNow = time.Now // Stubbed out for testing. - -/* -header formats a log header as defined by the C++ implementation. -It returns a buffer containing the formatted header and the user's file and line number. -The depth specifies how many stack frames above lives the source line to be identified in the log message. - -Log lines have this form: - Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg... -where the fields are defined as follows: - L A single character, representing the log level (eg 'I' for INFO) - mm The month (zero padded; ie May is '05') - dd The day (zero padded) - hh:mm:ss.uuuuuu Time in hours, minutes and fractional seconds - threadid The space-padded thread ID as returned by GetTID() - file The file name - line The line number - msg The user-supplied message -*/ -func (l *loggingT) header(s severity, depth int) (*buffer, string, int) { - _, file, line, ok := runtime.Caller(3 + depth) - if !ok { - file = "???" - line = 1 - } else { - slash := strings.LastIndex(file, "/") - if slash >= 0 { - file = file[slash+1:] - } - } - return l.formatHeader(s, file, line), file, line -} - -// formatHeader formats a log header using the provided file name and line number. -func (l *loggingT) formatHeader(s severity, file string, line int) *buffer { - now := timeNow() - if line < 0 { - line = 0 // not a real line number, but acceptable to someDigits - } - if s > fatalLog { - s = infoLog // for safety. - } - buf := l.getBuffer() - - // 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. - _, month, day := now.Date() - hour, minute, second := now.Clock() - // Lmmdd hh:mm:ss.uuuuuu threadid file:line] - buf.tmp[0] = severityChar[s] - buf.twoDigits(1, int(month)) - buf.twoDigits(3, day) - buf.tmp[5] = ' ' - buf.twoDigits(6, hour) - buf.tmp[8] = ':' - buf.twoDigits(9, minute) - buf.tmp[11] = ':' - buf.twoDigits(12, second) - buf.tmp[14] = '.' - buf.nDigits(6, 15, now.Nanosecond()/1000, '0') - buf.tmp[21] = ' ' - buf.nDigits(7, 22, pid, ' ') // TODO: should be TID - buf.tmp[29] = ' ' - buf.Write(buf.tmp[:30]) - buf.WriteString(file) - buf.tmp[0] = ':' - n := buf.someDigits(1, line) - buf.tmp[n+1] = ']' - buf.tmp[n+2] = ' ' - buf.Write(buf.tmp[:n+3]) - return buf -} - -// Some custom tiny helper functions to print the log header efficiently. - -const digits = "0123456789" - -// twoDigits formats a zero-prefixed two-digit integer at buf.tmp[i]. -func (buf *buffer) twoDigits(i, d int) { - buf.tmp[i+1] = digits[d%10] - d /= 10 - buf.tmp[i] = digits[d%10] -} - -// nDigits formats an n-digit integer at buf.tmp[i], -// padding with pad on the left. -// It assumes d >= 0. -func (buf *buffer) nDigits(n, i, d int, pad byte) { - j := n - 1 - for ; j >= 0 && d > 0; j-- { - buf.tmp[i+j] = digits[d%10] - d /= 10 - } - for ; j >= 0; j-- { - buf.tmp[i+j] = pad - } -} - -// someDigits formats a zero-prefixed variable-width integer at buf.tmp[i]. -func (buf *buffer) someDigits(i, d int) int { - // Print into the top, then copy down. We know there's space for at least - // a 10-digit number. - j := len(buf.tmp) - for { - j-- - buf.tmp[j] = digits[d%10] - d /= 10 - if d == 0 { - break - } - } - return copy(buf.tmp[i:], buf.tmp[j:]) -} - -func (l *loggingT) println(s severity, args ...interface{}) { - buf, file, line := l.header(s, 0) - fmt.Fprintln(buf, args...) - l.output(s, buf, file, line, false) -} - -func (l *loggingT) print(s severity, args ...interface{}) { - l.printDepth(s, 1, args...) -} - -func (l *loggingT) printDepth(s severity, depth int, args ...interface{}) { - buf, file, line := l.header(s, depth) - fmt.Fprint(buf, args...) - if buf.Bytes()[buf.Len()-1] != '\n' { - buf.WriteByte('\n') - } - l.output(s, buf, file, line, false) -} - -func (l *loggingT) printf(s severity, format string, args ...interface{}) { - buf, file, line := l.header(s, 0) - fmt.Fprintf(buf, format, args...) - if buf.Bytes()[buf.Len()-1] != '\n' { - buf.WriteByte('\n') - } - l.output(s, buf, file, line, false) -} - -// printWithFileLine behaves like print but uses the provided file and line number. If -// alsoLogToStderr is true, the log message always appears on standard error; it -// will also appear in the log file unless --logtostderr is set. -func (l *loggingT) printWithFileLine(s severity, file string, line int, alsoToStderr bool, args ...interface{}) { - buf := l.formatHeader(s, file, line) - fmt.Fprint(buf, args...) - if buf.Bytes()[buf.Len()-1] != '\n' { - buf.WriteByte('\n') - } - l.output(s, buf, file, line, alsoToStderr) -} - -// 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() - if l.traceLocation.isSet() { - if l.traceLocation.match(file, line) { - buf.Write(stacks(false)) - } - } - data := buf.Bytes() - if !flag.Parsed() { - os.Stderr.Write([]byte("ERROR: logging before flag.Parse: ")) - os.Stderr.Write(data) - } else if l.toStderr { - os.Stderr.Write(data) - } else { - if alsoToStderr || l.alsoToStderr || s >= l.stderrThreshold.get() { - os.Stderr.Write(data) - } - if l.file[s] == nil { - if err := l.createFiles(s); err != nil { - os.Stderr.Write(data) // Make sure the message appears somewhere. - l.exit(err) - } - } - switch s { - case fatalLog: - l.file[fatalLog].Write(data) - fallthrough - case errorLog: - l.file[errorLog].Write(data) - fallthrough - case warningLog: - l.file[warningLog].Write(data) - fallthrough - case infoLog: - l.file[infoLog].Write(data) - } - } - if s == fatalLog { - // If we got here via Exit rather than Fatal, print no stacks. - if atomic.LoadUint32(&fatalNoStacks) > 0 { - l.mu.Unlock() - timeoutFlush(10 * time.Second) - os.Exit(1) - } - // Dump all goroutine stacks before exiting. - // First, make sure we see the trace for the current goroutine on standard error. - // If -logtostderr has been specified, the loop below will do that anyway - // as the first stack in the full dump. - if !l.toStderr { - os.Stderr.Write(stacks(false)) - } - // Write the stack trace for all goroutines to the files. - trace := stacks(true) - logExitFunc = func(error) {} // If we get a write error, we'll still exit below. - for log := fatalLog; log >= infoLog; log-- { - if f := l.file[log]; f != nil { // Can be nil if -logtostderr is set. - f.Write(trace) - } - } - l.mu.Unlock() - timeoutFlush(10 * time.Second) - os.Exit(255) // C++ uses -1, which is silly because it's anded with 255 anyway. - } - l.putBuffer(buf) - l.mu.Unlock() - if stats := severityStats[s]; stats != nil { - atomic.AddInt64(&stats.lines, 1) - atomic.AddInt64(&stats.bytes, int64(len(data))) - } -} - -// timeoutFlush calls Flush and returns when it completes or after timeout -// elapses, whichever happens first. This is needed because the hooks invoked -// by Flush may deadlock when glog.Fatal is called from a hook that holds -// a lock. -func timeoutFlush(timeout time.Duration) { - done := make(chan bool, 1) - go func() { - Flush() // calls logging.lockAndFlushAll() - done <- true - }() - select { - case <-done: - case <-time.After(timeout): - fmt.Fprintln(os.Stderr, "glog: Flush took longer than", timeout) - } -} - -// stacks is a wrapper for runtime.Stack that attempts to recover the data for all goroutines. -func stacks(all bool) []byte { - // We don't know how big the traces are, so grow a few times if they don't fit. Start large, though. - n := 10000 - if all { - n = 100000 - } - var trace []byte - for i := 0; i < 5; i++ { - trace = make([]byte, n) - nbytes := runtime.Stack(trace, all) - if nbytes < len(trace) { - return trace[:nbytes] - } - n *= 2 - } - return trace -} - -// logExitFunc provides a simple mechanism to override the default behavior -// of exiting on error. Used in testing and to guarantee we reach a required exit -// for fatal logs. Instead, exit could be a function rather than a method but that -// would make its use clumsier. -var logExitFunc func(error) - -// exit is called if there is trouble creating or writing log files. -// It flushes the logs and exits the program; there's no point in hanging around. -// l.mu is held. -func (l *loggingT) exit(err error) { - fmt.Fprintf(os.Stderr, "log: exiting because of error: %s\n", err) - // If logExitFunc is set, we do that instead of exiting. - if logExitFunc != nil { - logExitFunc(err) - return - } - l.flushAll() - os.Exit(2) -} - -// syncBuffer joins a bufio.Writer to its underlying file, providing access to the -// file's Sync method and providing a wrapper for the Write method that provides log -// file rotation. There are conflicting methods, so the file cannot be embedded. -// l.mu is held for all its methods. -type syncBuffer struct { - logger *loggingT - *bufio.Writer - file *os.File - sev severity - nbytes uint64 // The number of bytes written to this file -} - -func (sb *syncBuffer) Sync() error { - return sb.file.Sync() -} - -func (sb *syncBuffer) Write(p []byte) (n int, err error) { - if sb.nbytes+uint64(len(p)) >= MaxSize { - if err := sb.rotateFile(time.Now()); err != nil { - sb.logger.exit(err) - } - } - n, err = sb.Writer.Write(p) - sb.nbytes += uint64(n) - if err != nil { - sb.logger.exit(err) - } - return -} - -// rotateFile closes the syncBuffer's file and starts a new one. -func (sb *syncBuffer) rotateFile(now time.Time) error { - if sb.file != nil { - sb.Flush() - sb.file.Close() - } - var err error - sb.file, _, err = create(severityName[sb.sev], now) - sb.nbytes = 0 - if err != nil { - return err - } - - sb.Writer = bufio.NewWriterSize(sb.file, bufferSize) - - // Write header. - var buf bytes.Buffer - fmt.Fprintf(&buf, "Log file created at: %s\n", now.Format("2006/01/02 15:04:05")) - fmt.Fprintf(&buf, "Running on machine: %s\n", host) - fmt.Fprintf(&buf, "Binary: Built with %s %s for %s/%s\n", runtime.Compiler, runtime.Version(), runtime.GOOS, runtime.GOARCH) - fmt.Fprintf(&buf, "Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg\n") - n, err := sb.file.Write(buf.Bytes()) - sb.nbytes += uint64(n) - return err -} - -// bufferSize sizes the buffer associated with each log file. It's large -// so that log records can accumulate without the logging thread blocking -// on disk I/O. The flushDaemon will block instead. -const bufferSize = 256 * 1024 - -// createFiles creates all the log files for severity from sev down to infoLog. -// l.mu is held. -func (l *loggingT) createFiles(sev severity) error { - now := time.Now() - // Files are created in decreasing severity order, so as soon as we find one - // has already been created, we can stop. - for s := sev; s >= infoLog && l.file[s] == nil; s-- { - sb := &syncBuffer{ - logger: l, - sev: s, - } - if err := sb.rotateFile(now); err != nil { - return err - } - l.file[s] = sb - } - return nil -} - -const flushInterval = 30 * time.Second - -// flushDaemon periodically flushes the log file buffers. -func (l *loggingT) flushDaemon() { - for _ = range time.NewTicker(flushInterval).C { - l.lockAndFlushAll() - } -} - -// lockAndFlushAll is like flushAll but locks l.mu first. -func (l *loggingT) lockAndFlushAll() { - l.mu.Lock() - l.flushAll() - l.mu.Unlock() -} - -// flushAll flushes all the logs and attempts to "sync" their data to disk. -// l.mu is held. -func (l *loggingT) flushAll() { - // Flush from fatal down, in case there's trouble flushing. - for s := fatalLog; s >= infoLog; s-- { - file := l.file[s] - if file != nil { - file.Flush() // ignore error - file.Sync() // ignore error - } - } -} - -// CopyStandardLogTo arranges for messages written to the Go "log" package's -// default logs to also appear in the Google logs for the named and lower -// severities. Subsequent changes to the standard log's default output location -// or format may break this behavior. -// -// Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not -// recognized, CopyStandardLogTo panics. -func CopyStandardLogTo(name string) { - sev, ok := severityByName(name) - if !ok { - panic(fmt.Sprintf("log.CopyStandardLogTo(%q): unrecognized severity name", name)) - } - // Set a log format that captures the user's file and line: - // d.go:23: message - stdLog.SetFlags(stdLog.Lshortfile) - stdLog.SetOutput(logBridge(sev)) -} - -// logBridge provides the Write method that enables CopyStandardLogTo to connect -// Go's standard logs to the logs provided by this package. -type logBridge severity - -// Write parses the standard logging line and passes its components to the -// logger for severity(lb). -func (lb logBridge) Write(b []byte) (n int, err error) { - var ( - file = "???" - line = 1 - text string - ) - // Split "d.go:23: message" into "d.go", "23", and "message". - if parts := bytes.SplitN(b, []byte{':'}, 3); len(parts) != 3 || len(parts[0]) < 1 || len(parts[2]) < 1 { - text = fmt.Sprintf("bad log format: %s", b) - } else { - file = string(parts[0]) - text = string(parts[2][1:]) // skip leading space - line, err = strconv.Atoi(string(parts[1])) - if err != nil { - text = fmt.Sprintf("bad line number: %s", b) - line = 1 - } - } - // printWithFileLine with alsoToStderr=true, so standard log messages - // always appear on standard error. - logging.printWithFileLine(severity(lb), file, line, true, text) - return len(b), nil -} - -// setV computes and remembers the V level for a given PC -// when vmodule is enabled. -// File pattern matching takes the basename of the file, stripped -// of its .go suffix, and uses filepath.Match, which is a little more -// general than the *? matching used in C++. -// l.mu is held. -func (l *loggingT) setV(pc uintptr) Level { - fn := runtime.FuncForPC(pc) - file, _ := fn.FileLine(pc) - // The file is something like /a/b/c/d.go. We want just the d. - if strings.HasSuffix(file, ".go") { - file = file[:len(file)-3] - } - if slash := strings.LastIndex(file, "/"); slash >= 0 { - file = file[slash+1:] - } - for _, filter := range l.vmodule.filter { - if filter.match(file) { - l.vmap[pc] = filter.level - return filter.level - } - } - l.vmap[pc] = 0 - return 0 -} - -// Verbose is a boolean type that implements Infof (like Printf) etc. -// See the documentation of V for more information. -type Verbose bool - -// V reports whether verbosity at the call site is at least the requested level. -// The returned value is a boolean of type Verbose, which implements Info, Infoln -// and Infof. These methods will write to the Info log if called. -// Thus, one may write either -// if glog.V(2) { glog.Info("log this") } -// or -// glog.V(2).Info("log this") -// The second form is shorter but the first is cheaper if logging is off because it does -// not evaluate its arguments. -// -// Whether an individual call to V generates a log record depends on the setting of -// the -v and --vmodule flags; both are off by default. If the level in the call to -// V is at least the value of -v, or of -vmodule for the source file containing the -// call, the V call will log. -func V(level Level) Verbose { - // This function tries hard to be cheap unless there's work to do. - // The fast path is two atomic loads and compares. - - // Here is a cheap but safe test to see if V logging is enabled globally. - if logging.verbosity.get() >= level { - return Verbose(true) - } - - // It's off globally but it vmodule may still be set. - // Here is another cheap but safe test to see if vmodule is enabled. - if atomic.LoadInt32(&logging.filterLength) > 0 { - // Now we need a proper lock to use the logging structure. The pcs field - // is shared so we must lock before accessing it. This is fairly expensive, - // but if V logging is enabled we're slow anyway. - logging.mu.Lock() - defer logging.mu.Unlock() - if runtime.Callers(2, logging.pcs[:]) == 0 { - return Verbose(false) - } - v, ok := logging.vmap[logging.pcs[0]] - if !ok { - v = logging.setV(logging.pcs[0]) - } - return Verbose(v >= level) - } - return Verbose(false) -} - -// Info is equivalent to the global Info function, guarded by the value of v. -// See the documentation of V for usage. -func (v Verbose) Info(args ...interface{}) { - if v { - logging.print(infoLog, args...) - } -} - -// Infoln is equivalent to the global Infoln function, guarded by the value of v. -// See the documentation of V for usage. -func (v Verbose) Infoln(args ...interface{}) { - if v { - logging.println(infoLog, args...) - } -} - -// Infof is equivalent to the global Infof function, guarded by the value of v. -// See the documentation of V for usage. -func (v Verbose) Infof(format string, args ...interface{}) { - if v { - logging.printf(infoLog, format, args...) - } -} - -// Info logs to the INFO log. -// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. -func Info(args ...interface{}) { - logging.print(infoLog, args...) -} - -// InfoDepth acts as Info but uses depth to determine which call frame to log. -// InfoDepth(0, "msg") is the same as Info("msg"). -func InfoDepth(depth int, args ...interface{}) { - logging.printDepth(infoLog, depth, args...) -} - -// Infoln logs to the INFO log. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. -func Infoln(args ...interface{}) { - logging.println(infoLog, args...) -} - -// Infof logs to the INFO log. -// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. -func Infof(format string, args ...interface{}) { - logging.printf(infoLog, format, args...) -} - -// Warning logs to the WARNING and INFO logs. -// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. -func Warning(args ...interface{}) { - logging.print(warningLog, args...) -} - -// WarningDepth acts as Warning but uses depth to determine which call frame to log. -// WarningDepth(0, "msg") is the same as Warning("msg"). -func WarningDepth(depth int, args ...interface{}) { - logging.printDepth(warningLog, depth, args...) -} - -// Warningln logs to the WARNING and INFO logs. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. -func Warningln(args ...interface{}) { - logging.println(warningLog, args...) -} - -// Warningf logs to the WARNING and INFO logs. -// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. -func Warningf(format string, args ...interface{}) { - logging.printf(warningLog, format, args...) -} - -// Error logs to the ERROR, WARNING, and INFO logs. -// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. -func Error(args ...interface{}) { - logging.print(errorLog, args...) -} - -// ErrorDepth acts as Error but uses depth to determine which call frame to log. -// ErrorDepth(0, "msg") is the same as Error("msg"). -func ErrorDepth(depth int, args ...interface{}) { - logging.printDepth(errorLog, depth, args...) -} - -// Errorln logs to the ERROR, WARNING, and INFO logs. -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. -func Errorln(args ...interface{}) { - logging.println(errorLog, args...) -} - -// Errorf logs to the ERROR, WARNING, and INFO logs. -// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. -func Errorf(format string, args ...interface{}) { - logging.printf(errorLog, format, args...) -} - -// Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, -// including a stack trace of all running goroutines, then calls os.Exit(255). -// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. -func Fatal(args ...interface{}) { - logging.print(fatalLog, args...) -} - -// FatalDepth acts as Fatal but uses depth to determine which call frame to log. -// FatalDepth(0, "msg") is the same as Fatal("msg"). -func FatalDepth(depth int, args ...interface{}) { - logging.printDepth(fatalLog, depth, args...) -} - -// Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, -// including a stack trace of all running goroutines, then calls os.Exit(255). -// Arguments are handled in the manner of fmt.Println; a newline is appended if missing. -func Fatalln(args ...interface{}) { - logging.println(fatalLog, args...) -} - -// Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, -// including a stack trace of all running goroutines, then calls os.Exit(255). -// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. -func Fatalf(format string, args ...interface{}) { - logging.printf(fatalLog, format, args...) -} - -// fatalNoStacks is non-zero if we are to exit without dumping goroutine stacks. -// It allows Exit and relatives to use the Fatal logs. -var fatalNoStacks uint32 - -// Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). -// Arguments are handled in the manner of fmt.Print; a newline is appended if missing. -func Exit(args ...interface{}) { - atomic.StoreUint32(&fatalNoStacks, 1) - logging.print(fatalLog, args...) -} - -// ExitDepth acts as Exit but uses depth to determine which call frame to log. -// ExitDepth(0, "msg") is the same as Exit("msg"). -func ExitDepth(depth int, args ...interface{}) { - atomic.StoreUint32(&fatalNoStacks, 1) - logging.printDepth(fatalLog, depth, args...) -} - -// Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). -func Exitln(args ...interface{}) { - atomic.StoreUint32(&fatalNoStacks, 1) - logging.println(fatalLog, args...) -} - -// Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). -// Arguments are handled in the manner of fmt.Printf; a newline is appended if missing. -func Exitf(format string, args ...interface{}) { - atomic.StoreUint32(&fatalNoStacks, 1) - logging.printf(fatalLog, format, args...) -} diff --git a/vendor/github.com/golang/glog/glog_file.go b/vendor/github.com/golang/glog/glog_file.go deleted file mode 100644 index 65075d281..000000000 --- a/vendor/github.com/golang/glog/glog_file.go +++ /dev/null @@ -1,124 +0,0 @@ -// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ -// -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// File I/O for logs. - -package glog - -import ( - "errors" - "flag" - "fmt" - "os" - "os/user" - "path/filepath" - "strings" - "sync" - "time" -) - -// MaxSize is the maximum size of a log file in bytes. -var MaxSize uint64 = 1024 * 1024 * 1800 - -// logDirs lists the candidate directories for new log files. -var logDirs []string - -// 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) - } - logDirs = append(logDirs, os.TempDir()) -} - -var ( - pid = os.Getpid() - program = filepath.Base(os.Args[0]) - host = "unknownhost" - userName = "unknownuser" -) - -func init() { - h, err := os.Hostname() - if err == nil { - host = shortHostname(h) - } - - current, err := user.Current() - if err == nil { - userName = current.Username - } - - // Sanitize userName since it may contain filepath separators on Windows. - userName = strings.Replace(userName, `\`, "_", -1) -} - -// shortHostname returns its argument, truncating at the first period. -// For instance, given "www.google.com" it returns "www". -func shortHostname(hostname string) string { - if i := strings.Index(hostname, "."); i >= 0 { - return hostname[:i] - } - return hostname -} - -// logName returns a new log file name containing tag, with start time t, and -// the name for the symlink for tag. -func logName(tag string, t time.Time) (name, link string) { - name = fmt.Sprintf("%s.%s.%s.log.%s.%04d%02d%02d-%02d%02d%02d.%d", - program, - host, - userName, - tag, - t.Year(), - t.Month(), - t.Day(), - t.Hour(), - t.Minute(), - t.Second(), - pid) - return name, program + "." + tag -} - -var onceLogDirs sync.Once - -// create creates a new log file and returns the file and its filename, which -// contains tag ("INFO", "FATAL", etc.) and t. If the file is created -// successfully, create also attempts to update the symlink for that tag, ignoring -// errors. -func create(tag string, t time.Time) (f *os.File, filename string, err error) { - onceLogDirs.Do(createLogDirs) - if len(logDirs) == 0 { - return nil, "", errors.New("log: no log dirs") - } - name, link := logName(tag, t) - var lastErr error - for _, dir := range logDirs { - fname := filepath.Join(dir, name) - f, err := os.Create(fname) - if err == nil { - symlink := filepath.Join(dir, link) - os.Remove(symlink) // ignore err - os.Symlink(name, symlink) // ignore err - return f, fname, nil - } - lastErr = err - } - return nil, "", fmt.Errorf("log: cannot create log: %v", lastErr) -} diff --git a/vendor/github.com/golang/glog/glog_test.go b/vendor/github.com/golang/glog/glog_test.go deleted file mode 100644 index 0fb376e1f..000000000 --- a/vendor/github.com/golang/glog/glog_test.go +++ /dev/null @@ -1,415 +0,0 @@ -// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ -// -// Copyright 2013 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package glog - -import ( - "bytes" - "fmt" - stdLog "log" - "path/filepath" - "runtime" - "strconv" - "strings" - "testing" - "time" -) - -// Test that shortHostname works as advertised. -func TestShortHostname(t *testing.T) { - for hostname, expect := range map[string]string{ - "": "", - "host": "host", - "host.google.com": "host", - } { - if got := shortHostname(hostname); expect != got { - t.Errorf("shortHostname(%q): expected %q, got %q", hostname, expect, got) - } - } -} - -// flushBuffer wraps a bytes.Buffer to satisfy flushSyncWriter. -type flushBuffer struct { - bytes.Buffer -} - -func (f *flushBuffer) Flush() error { - return nil -} - -func (f *flushBuffer) Sync() error { - return nil -} - -// swap sets the log writers and returns the old array. -func (l *loggingT) swap(writers [numSeverity]flushSyncWriter) (old [numSeverity]flushSyncWriter) { - l.mu.Lock() - defer l.mu.Unlock() - old = l.file - for i, w := range writers { - logging.file[i] = w - } - return -} - -// newBuffers sets the log writers to all new byte buffers and returns the old array. -func (l *loggingT) newBuffers() [numSeverity]flushSyncWriter { - return l.swap([numSeverity]flushSyncWriter{new(flushBuffer), new(flushBuffer), new(flushBuffer), new(flushBuffer)}) -} - -// contents returns the specified log value as a string. -func contents(s severity) string { - return logging.file[s].(*flushBuffer).String() -} - -// contains reports whether the string is contained in the log. -func contains(s severity, str string, t *testing.T) bool { - return strings.Contains(contents(s), str) -} - -// setFlags configures the logging flags how the test expects them. -func setFlags() { - logging.toStderr = false -} - -// Test that Info works as advertised. -func TestInfo(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - Info("test") - if !contains(infoLog, "I", t) { - t.Errorf("Info has wrong character: %q", contents(infoLog)) - } - if !contains(infoLog, "test", t) { - t.Error("Info failed") - } -} - -func TestInfoDepth(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - - f := func() { InfoDepth(1, "depth-test1") } - - // The next three lines must stay together - _, _, wantLine, _ := runtime.Caller(0) - InfoDepth(0, "depth-test0") - f() - - msgs := strings.Split(strings.TrimSuffix(contents(infoLog), "\n"), "\n") - if len(msgs) != 2 { - t.Fatalf("Got %d lines, expected 2", len(msgs)) - } - - for i, m := range msgs { - if !strings.HasPrefix(m, "I") { - t.Errorf("InfoDepth[%d] has wrong character: %q", i, m) - } - w := fmt.Sprintf("depth-test%d", i) - if !strings.Contains(m, w) { - t.Errorf("InfoDepth[%d] missing %q: %q", i, w, m) - } - - // pull out the line number (between : and ]) - msg := m[strings.LastIndex(m, ":")+1:] - x := strings.Index(msg, "]") - if x < 0 { - t.Errorf("InfoDepth[%d]: missing ']': %q", i, m) - continue - } - line, err := strconv.Atoi(msg[:x]) - if err != nil { - t.Errorf("InfoDepth[%d]: bad line number: %q", i, m) - continue - } - wantLine++ - if wantLine != line { - t.Errorf("InfoDepth[%d]: got line %d, want %d", i, line, wantLine) - } - } -} - -func init() { - CopyStandardLogTo("INFO") -} - -// Test that CopyStandardLogTo panics on bad input. -func TestCopyStandardLogToPanic(t *testing.T) { - defer func() { - if s, ok := recover().(string); !ok || !strings.Contains(s, "LOG") { - t.Errorf(`CopyStandardLogTo("LOG") should have panicked: %v`, s) - } - }() - CopyStandardLogTo("LOG") -} - -// Test that using the standard log package logs to INFO. -func TestStandardLog(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - stdLog.Print("test") - if !contains(infoLog, "I", t) { - t.Errorf("Info has wrong character: %q", contents(infoLog)) - } - if !contains(infoLog, "test", t) { - t.Error("Info failed") - } -} - -// Test that the header has the correct format. -func TestHeader(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - defer func(previous func() time.Time) { timeNow = previous }(timeNow) - timeNow = func() time.Time { - return time.Date(2006, 1, 2, 15, 4, 5, .067890e9, time.Local) - } - pid = 1234 - Info("test") - var line int - format := "I0102 15:04:05.067890 1234 glog_test.go:%d] test\n" - n, err := fmt.Sscanf(contents(infoLog), format, &line) - if n != 1 || err != nil { - t.Errorf("log format error: %d elements, error %s:\n%s", n, err, contents(infoLog)) - } - // Scanf treats multiple spaces as equivalent to a single space, - // so check for correct space-padding also. - want := fmt.Sprintf(format, line) - if contents(infoLog) != want { - t.Errorf("log format error: got:\n\t%q\nwant:\t%q", contents(infoLog), want) - } -} - -// Test that an Error log goes to Warning and Info. -// Even in the Info log, the source character will be E, so the data should -// all be identical. -func TestError(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - Error("test") - if !contains(errorLog, "E", t) { - t.Errorf("Error has wrong character: %q", contents(errorLog)) - } - if !contains(errorLog, "test", t) { - t.Error("Error failed") - } - str := contents(errorLog) - if !contains(warningLog, str, t) { - t.Error("Warning failed") - } - if !contains(infoLog, str, t) { - t.Error("Info failed") - } -} - -// Test that a Warning log goes to Info. -// Even in the Info log, the source character will be W, so the data should -// all be identical. -func TestWarning(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - Warning("test") - if !contains(warningLog, "W", t) { - t.Errorf("Warning has wrong character: %q", contents(warningLog)) - } - if !contains(warningLog, "test", t) { - t.Error("Warning failed") - } - str := contents(warningLog) - if !contains(infoLog, str, t) { - t.Error("Info failed") - } -} - -// Test that a V log goes to Info. -func TestV(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - logging.verbosity.Set("2") - defer logging.verbosity.Set("0") - V(2).Info("test") - if !contains(infoLog, "I", t) { - t.Errorf("Info has wrong character: %q", contents(infoLog)) - } - if !contains(infoLog, "test", t) { - t.Error("Info failed") - } -} - -// Test that a vmodule enables a log in this file. -func TestVmoduleOn(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - logging.vmodule.Set("glog_test=2") - defer logging.vmodule.Set("") - if !V(1) { - t.Error("V not enabled for 1") - } - if !V(2) { - t.Error("V not enabled for 2") - } - if V(3) { - t.Error("V enabled for 3") - } - V(2).Info("test") - if !contains(infoLog, "I", t) { - t.Errorf("Info has wrong character: %q", contents(infoLog)) - } - if !contains(infoLog, "test", t) { - t.Error("Info failed") - } -} - -// Test that a vmodule of another file does not enable a log in this file. -func TestVmoduleOff(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - logging.vmodule.Set("notthisfile=2") - defer logging.vmodule.Set("") - for i := 1; i <= 3; i++ { - if V(Level(i)) { - t.Errorf("V enabled for %d", i) - } - } - V(2).Info("test") - if contents(infoLog) != "" { - t.Error("V logged incorrectly") - } -} - -// vGlobs are patterns that match/don't match this file at V=2. -var vGlobs = map[string]bool{ - // Easy to test the numeric match here. - "glog_test=1": false, // If -vmodule sets V to 1, V(2) will fail. - "glog_test=2": true, - "glog_test=3": true, // If -vmodule sets V to 1, V(3) will succeed. - // These all use 2 and check the patterns. All are true. - "*=2": true, - "?l*=2": true, - "????_*=2": true, - "??[mno]?_*t=2": true, - // These all use 2 and check the patterns. All are false. - "*x=2": false, - "m*=2": false, - "??_*=2": false, - "?[abc]?_*t=2": false, -} - -// Test that vmodule globbing works as advertised. -func testVmoduleGlob(pat string, match bool, t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - defer logging.vmodule.Set("") - logging.vmodule.Set(pat) - if V(2) != Verbose(match) { - t.Errorf("incorrect match for %q: got %t expected %t", pat, V(2), match) - } -} - -// Test that a vmodule globbing works as advertised. -func TestVmoduleGlob(t *testing.T) { - for glob, match := range vGlobs { - testVmoduleGlob(glob, match, t) - } -} - -func TestRollover(t *testing.T) { - setFlags() - var err error - defer func(previous func(error)) { logExitFunc = previous }(logExitFunc) - logExitFunc = func(e error) { - err = e - } - defer func(previous uint64) { MaxSize = previous }(MaxSize) - MaxSize = 512 - - Info("x") // Be sure we have a file. - info, ok := logging.file[infoLog].(*syncBuffer) - if !ok { - t.Fatal("info wasn't created") - } - if err != nil { - t.Fatalf("info has initial error: %v", err) - } - fname0 := info.file.Name() - Info(strings.Repeat("x", int(MaxSize))) // force a rollover - if err != nil { - t.Fatalf("info has error after big write: %v", err) - } - - // Make sure the next log file gets a file name with a different - // time stamp. - // - // TODO: determine whether we need to support subsecond log - // rotation. C++ does not appear to handle this case (nor does it - // handle Daylight Savings Time properly). - time.Sleep(1 * time.Second) - - Info("x") // create a new file - if err != nil { - t.Fatalf("error after rotation: %v", err) - } - fname1 := info.file.Name() - if fname0 == fname1 { - t.Errorf("info.f.Name did not change: %v", fname0) - } - if info.nbytes >= MaxSize { - t.Errorf("file size was not reset: %d", info.nbytes) - } -} - -func TestLogBacktraceAt(t *testing.T) { - setFlags() - defer logging.swap(logging.newBuffers()) - // The peculiar style of this code simplifies line counting and maintenance of the - // tracing block below. - var infoLine string - setTraceLocation := func(file string, line int, ok bool, delta int) { - if !ok { - t.Fatal("could not get file:line") - } - _, file = filepath.Split(file) - infoLine = fmt.Sprintf("%s:%d", file, line+delta) - err := logging.traceLocation.Set(infoLine) - if err != nil { - t.Fatal("error setting log_backtrace_at: ", err) - } - } - { - // Start of tracing block. These lines know about each other's relative position. - _, file, line, ok := runtime.Caller(0) - setTraceLocation(file, line, ok, +2) // Two lines between Caller and Info calls. - Info("we want a stack trace here") - } - numAppearances := strings.Count(contents(infoLog), infoLine) - if numAppearances < 2 { - // Need 2 appearances, one in the log header and one in the trace: - // log_test.go:281: I0511 16:36:06.952398 02238 log_test.go:280] we want a stack trace here - // ... - // github.com/glog/glog_test.go:280 (0x41ba91) - // ... - // We could be more precise but that would require knowing the details - // of the traceback format, which may not be dependable. - t.Fatal("got no trace back; log is ", contents(infoLog)) - } -} - -func BenchmarkHeader(b *testing.B) { - for i := 0; i < b.N; i++ { - buf, _, _ := logging.header(infoLog, 0) - logging.putBuffer(buf) - } -} diff --git a/vendor/k8s.io/gengo/.travis.yml b/vendor/k8s.io/gengo/.travis.yml index 3ed9b3494..1fd593ace 100644 --- a/vendor/k8s.io/gengo/.travis.yml +++ b/vendor/k8s.io/gengo/.travis.yml @@ -13,4 +13,4 @@ jobs: - go test -v ./... - stage: Verify examples script: - - go run ./examples/import-boss/main.go -i $(go list k8s.io/gengo/... | grep -v import-boss/tests | paste -sd',' -) --verify-only + - go run ./examples/import-boss/main.go -i k8s.io/gengo/... --verify-only diff --git a/vendor/k8s.io/gengo/args/args.go b/vendor/k8s.io/gengo/args/args.go index 26c790e65..7401098c5 100644 --- a/vendor/k8s.io/gengo/args/args.go +++ b/vendor/k8s.io/gengo/args/args.go @@ -159,9 +159,6 @@ func (g *GeneratorArgs) InputIncludes(p *types.Package) bool { if strings.HasSuffix(d, "...") { d = strings.TrimSuffix(d, "...") } - if strings.HasPrefix(d, "./vendor/") { - d = strings.TrimPrefix(d, "./vendor/") - } if strings.HasPrefix(p.Path, d) { return true } diff --git a/vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go b/vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go index 9ee7b79f5..7e3bc6b4b 100644 --- a/vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go +++ b/vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go @@ -248,11 +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 - baseTypeName := "" - if defaults.base != nil { - baseTypeName = defaults.base.Name.String() - } - klog.V(5).Infof(" an object defaulter already exists as %s", baseTypeName) + klog.V(5).Infof(" an object defaulter already exists as %s", defaults.base.Name) return false } // opt-out diff --git a/vendor/k8s.io/gengo/examples/import-boss/Makefile b/vendor/k8s.io/gengo/examples/import-boss/Makefile deleted file mode 100644 index b1e247862..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOOL=import-boss - -all: test - -test: build test_rules test_inverse - -build: - @go build -o /tmp/$(TOOL) - -test_rules: - /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/a) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/b) - /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/c) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/nested) - /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/nested/nested) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/nested/nested/nested) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/rules/nested/nested/nested/inherit) - -test_inverse: - /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/a ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/b ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) - /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/c ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/d ./tests/inverse/lib/... | grep -v quarantine | paste -sd',' -) - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/lib/... | paste -sd',' -) - - ! /tmp/$(TOOL) --logtostderr --v=4 -i $$(go list ./tests/inverse/lib/... | paste -sd',' -) - -.PHONY: build test test_rules test_inverse diff --git a/vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go b/vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go index fb73c03bb..ea5716b6c 100644 --- a/vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go +++ b/vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go @@ -38,7 +38,6 @@ import ( ) const ( - goModFile = "go.mod" importBossFileType = "import-boss" ) @@ -59,7 +58,7 @@ func DefaultNameSystem() string { func Packages(c *generator.Context, arguments *args.GeneratorArgs) generator.Packages { pkgs := generator.Packages{} c.FileTypes = map[string]generator.FileType{ - importBossFileType: importRuleFile{c}, + importBossFileType: importRuleFile{}, } for _, p := range c.Universe { @@ -71,7 +70,6 @@ func Packages(c *generator.Context, arguments *args.GeneratorArgs) generator.Pac pkgs = append(pkgs, &generator.DefaultPackage{ PackageName: p.Name, PackagePath: p.Path, - Source: p.SourcePath, // GeneratorFunc returns a list of generators. Each generator makes a // single file. GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) { @@ -98,19 +96,10 @@ type Rule struct { ForbiddenPrefixes []string } -type InverseRule struct { - Rule - // True if the rule is to be applied to transitive imports. - Transitive bool -} - type fileFormat struct { CurrentImports []string - Rules []Rule - InverseRules []InverseRule - - path string + Rules []Rule } func readFile(path string) (*fileFormat, error) { @@ -124,7 +113,6 @@ func readFile(path string) (*fileFormat, error) { if err != nil { return nil, fmt.Errorf("couldn't unmarshal %v: %v", path, err) } - current.path = path return ¤t, nil } @@ -143,12 +131,10 @@ func writeFile(path string, ff *fileFormat) error { } // This does the actual checking, since it knows the literal destination file. -type importRuleFile struct { - context *generator.Context -} +type importRuleFile struct{} -func (irf importRuleFile) AssembleFile(f *generator.File, path string) error { - return irf.VerifyFile(f, path) +func (importRuleFile) AssembleFile(f *generator.File, path string) error { + return nil } // TODO: make a flag to enable this, or expose this information in some other way. @@ -183,100 +169,63 @@ func removeLastDir(path string) (newPath, removedDir string) { return filepath.Join(filepath.Dir(dir), file), filepath.Base(dir) } -// isGoModRoot checks if a directory is the root directory for a package -// by checking for the existence of a 'go.mod' file in that directory. -func isGoModRoot(path string) bool { - _, err := os.Stat(filepath.Join(filepath.Dir(path), goModFile)) - return err == nil -} - -// recursiveRead collects all '.import-restriction' files, between the current directory, -// and the package root when Go modules are enabled, or $GOPATH/src when they are not. -func recursiveRead(path string) ([]*fileFormat, error) { - restrictionFiles := make([]*fileFormat, 0) - +// Keep going up a directory until we find an .import-restrictions file. +func recursiveRead(path string) (*fileFormat, string, error) { for { if _, err := os.Stat(path); err == nil { - rules, err := readFile(path) - if err != nil { - return nil, err - } - - restrictionFiles = append(restrictionFiles, rules) + ff, err := readFile(path) + return ff, path, err } nextPath, removedDir := removeLastDir(path) - if nextPath == path || isGoModRoot(path) || removedDir == "src" { + if nextPath == path || removedDir == "src" { break } - path = nextPath } - - return restrictionFiles, nil + return nil, "", nil } -func (irf importRuleFile) VerifyFile(f *generator.File, path string) error { - restrictionFiles, err := recursiveRead(filepath.Join(f.PackageSourcePath, f.Name)) +func (importRuleFile) VerifyFile(f *generator.File, path string) error { + rules, actualPath, err := recursiveRead(path) if err != nil { return fmt.Errorf("error finding rules file: %v", err) } - if err := irf.verifyRules(restrictionFiles, f); err != nil { - return err - } - - return irf.verifyInverseRules(restrictionFiles, f) -} - -func (irf importRuleFile) verifyRules(restrictionFiles []*fileFormat, f *generator.File) error { - selectors := make([][]*regexp.Regexp, len(restrictionFiles)) - for i, restrictionFile := range restrictionFiles { - for _, r := range restrictionFile.Rules { - re, err := regexp.Compile(r.SelectorRegexp) - if err != nil { - return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, restrictionFile.path, err) - } - - selectors[i] = append(selectors[i], re) - } + if rules == nil { + // No restrictions on this directory. + return nil } forbiddenImports := map[string]string{} allowedMismatchedImports := []string{} - - for v := range f.Imports { - explicitlyAllowed := false - - NextRestrictionFiles: - for i, rules := range restrictionFiles { - for j, r := range rules.Rules { - matching := selectors[i][j].MatchString(v) - klog.V(5).Infof("Checking %v matches %v: %v\n", r.SelectorRegexp, v, matching) - if !matching { - continue + for _, r := range rules.Rules { + re, err := regexp.Compile(r.SelectorRegexp) + if err != nil { + return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, actualPath, err) + } + for v := range f.Imports { + 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 { + klog.V(4).Infof("Checking %v against %v\n", v, forbidden) + if strings.HasPrefix(v, forbidden) { + forbiddenImports[v] = forbidden } - for _, forbidden := range r.ForbiddenPrefixes { - klog.V(4).Infof("Checking %v against %v\n", v, forbidden) - if strings.HasPrefix(v, forbidden) { - forbiddenImports[v] = forbidden - } - } - for _, allowed := range r.AllowedPrefixes { - klog.V(4).Infof("Checking %v against %v\n", v, allowed) - if strings.HasPrefix(v, allowed) { - explicitlyAllowed = true - break - } - } - - if !explicitlyAllowed { - allowedMismatchedImports = append(allowedMismatchedImports, v) - } else { - klog.V(2).Infof("%v importing %v allowed by %v\n", f.PackagePath, v, restrictionFiles[i].path) - break NextRestrictionFiles + } + found := false + for _, allowed := range r.AllowedPrefixes { + klog.V(4).Infof("Checking %v against %v\n", v, allowed) + if strings.HasPrefix(v, allowed) { + found = true + break } } + if !found { + allowedMismatchedImports = append(allowedMismatchedImports, v) + } } } @@ -294,85 +243,8 @@ func (irf importRuleFile) verifyRules(restrictionFiles []*fileFormat, f *generat } return errors.New(errorBuilder.String()) } - - return nil -} - -// verifyInverseRules checks that all packages that import a package are allowed to import it. -func (irf importRuleFile) verifyInverseRules(restrictionFiles []*fileFormat, f *generator.File) error { - // compile all Selector regex in all restriction files - selectors := make([][]*regexp.Regexp, len(restrictionFiles)) - for i, restrictionFile := range restrictionFiles { - for _, r := range restrictionFile.InverseRules { - re, err := regexp.Compile(r.SelectorRegexp) - if err != nil { - return fmt.Errorf("regexp `%s` in file %q doesn't compile: %v", r.SelectorRegexp, restrictionFile.path, err) - } - - selectors[i] = append(selectors[i], re) - } - } - - directImport := map[string]bool{} - for _, imp := range irf.context.IncomingImports()[f.PackagePath] { - directImport[imp] = true - } - - forbiddenImports := map[string]string{} - allowedMismatchedImports := []string{} - - for _, v := range irf.context.TransitiveIncomingImports()[f.PackagePath] { - explicitlyAllowed := false - - NextRestrictionFiles: - for i, rules := range restrictionFiles { - for j, r := range rules.InverseRules { - if !r.Transitive && !directImport[v] { - continue - } - - re := selectors[i][j] - matching := re.MatchString(v) - klog.V(4).Infof("Checking %v matches %v (importing %v: %v\n", r.SelectorRegexp, v, f.PackagePath, matching) - if !matching { - continue - } - for _, forbidden := range r.ForbiddenPrefixes { - klog.V(4).Infof("Checking %v against %v\n", v, forbidden) - if strings.HasPrefix(v, forbidden) { - forbiddenImports[v] = forbidden - } - } - for _, allowed := range r.AllowedPrefixes { - klog.V(4).Infof("Checking %v against %v\n", v, allowed) - if strings.HasPrefix(v, allowed) { - explicitlyAllowed = true - break - } - } - if !explicitlyAllowed { - allowedMismatchedImports = append(allowedMismatchedImports, v) - } else { - klog.V(2).Infof("%v importing %v allowed by %v\n", v, f.PackagePath, restrictionFiles[i].path) - break NextRestrictionFiles - } - } - } - } - - if len(forbiddenImports) > 0 || len(allowedMismatchedImports) > 0 { - var errorBuilder strings.Builder - for i, f := range forbiddenImports { - fmt.Fprintf(&errorBuilder, "(inverse): import %v has forbidden prefix %v\n", i, f) - } - if len(allowedMismatchedImports) > 0 { - sort.Sort(sort.StringSlice(allowedMismatchedImports)) - fmt.Fprintf(&errorBuilder, "(inverse): the following imports did not match any allowed prefix:\n") - for _, i := range allowedMismatchedImports { - fmt.Fprintf(&errorBuilder, " %v\n", i) - } - } - return errors.New(errorBuilder.String()) + if len(rules.Rules) > 0 { + klog.V(2).Infof("%v passes rules found in %v\n", path, actualPath) } return nil diff --git a/vendor/k8s.io/gengo/examples/import-boss/main.go b/vendor/k8s.io/gengo/examples/import-boss/main.go index 3e5f31b4d..44b0d63ee 100644 --- a/vendor/k8s.io/gengo/examples/import-boss/main.go +++ b/vendor/k8s.io/gengo/examples/import-boss/main.go @@ -16,37 +16,24 @@ limitations under the License. // import-boss enforces import restrictions in a given repository. // -// When a package is verified, import-boss looks for files called -// ".import-restrictions" in all directories between the package and -// the $GOPATH/src. +// When a directory is verified, import-boss looks for a file called +// ".import-restrictions". If this file is not found, parent directories will be +// recursively searched. // -// All imports of the package are checked against each "rule" in the -// found restriction files, climbing up the directory tree until the -// import matches one of the rules. -// -// If the import does not match any of the rules, it is accepted. -// -// In analogy, all incoming imports of the package are checked against each -// "inverse rule" in the found restriction files, climbing up the directory -// tree until the import matches one of the rules. -// -// If the incoming import does not match any of the inverse rules, it is accepted. -// -// A rule consists of three parts: +// If an ".import-restrictions" file is found, then all imports of the package +// are checked against each "rule" in the file. A rule consists of three parts: // * A SelectorRegexp, to select the import paths that the rule applies to. // * A list of AllowedPrefixes // * A list of ForbiddenPrefixes -// An import passes a rule of a matching selector if it matches at least one -// allowed prefix, but no forbidden prefix. -// -// An example file looks like this: +// An import is allowed if it matches at least one allowed prefix and does not +// match any forbidden prefix. An example file looks like this: // // { // "Rules": [ // { // "SelectorRegexp": "k8s[.]io", // "AllowedPrefixes": [ -// "k8s.io/gengo/examples", +// "k8s.io/gengo", // "k8s.io/kubernetes/third_party" // ], // "ForbiddenPrefixes": [ @@ -61,37 +48,11 @@ limitations under the License. // "" // ] // } -// ], -// "InverseRules": [{ -// "SelectorRegexp": "k8s[.]io", -// "AllowedPrefixes": [ -// "k8s.io/same-repo", -// "k8s.io/kubernetes/pkg/legacy" -// ], -// "ForbiddenPrefixes": [ -// "k8s.io/kubernetes/pkg/legacy/subpkg" -// ] -// }, -// { -// "SelectorRegexp": "k8s[.]io", -// "Transitive": true, -// "AllowedPrefixes": [ -// "k8s.io/ -// ], -// "ForbiddenPrefixes": [ -// "k8s.io/kubernetes/cmd/kubelet", -// "k8s.io/kubernetes/cmd/kubectl" -// ], // ] // } // -// Note the second (non-inverse) rule explicitly matches the unsafe package, and forbids it +// Note the secound block explicitly matches the unsafe package, and forbids it // ("" is a prefix of everything). -// -// An import from another package passes an inverse rule with a matching selector if -// it matches at least one allowed prefix, but no forbidden prefix. -// -// Note that the second InverseRule is transitive, the first only applies to direct imports. package main import ( diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/a/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/a/doc.go deleted file mode 100644 index 4a831853a..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/a/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// a only imports public packages. -package a - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/b/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/b/doc.go deleted file mode 100644 index c90441875..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/b/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// b only imports public and private packages. The latter it shouldn't. -package b - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/c/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/c/doc.go deleted file mode 100644 index 7438e478c..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/c/doc.go +++ /dev/null @@ -1,7 +0,0 @@ -// c imports the library root, which in turn imports the public and private packages. This is fine because -// the private package is not directly imported. -package c - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/d/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/d/doc.go deleted file mode 100644 index 3e61b6ceb..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/d/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// c imports non-prod code. It shouldn't. -package d - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/doc.go deleted file mode 100644 index 6ed837cd5..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -package lib - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/public" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/lib_test.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/lib_test.go deleted file mode 100644 index 78a02b2a3..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/lib_test.go +++ /dev/null @@ -1,5 +0,0 @@ -package lib - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/.import-restrictions deleted file mode 100644 index c0e2acff9..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/.import-restrictions +++ /dev/null @@ -1,9 +0,0 @@ -{ - "InverseRules": [{ - "Transitive": true, - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/inverse/lib" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/doc.go deleted file mode 100644 index aad4b53e2..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/nonprod/doc.go +++ /dev/null @@ -1,2 +0,0 @@ -// nonprod is non-production code that should not be linked into any outside package. -package nonprod diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/.import-restrictions deleted file mode 100644 index 9bcbd35e6..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/.import-restrictions +++ /dev/null @@ -1,11 +0,0 @@ -{ - "InverseRules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/inverse/lib" - ], - "ForbiddenPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/doc.go deleted file mode 100644 index 735e4dc81..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/private/doc.go +++ /dev/null @@ -1 +0,0 @@ -package private diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/public/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/public/doc.go deleted file mode 100644 index 9fd24e5c1..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/public/doc.go +++ /dev/null @@ -1 +0,0 @@ -package public diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine/doc.go deleted file mode 100644 index 82d777e47..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/inverse/lib/quarantine/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// quarantine is inside the library, but should not import the private package. But it does! -package quarantine - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/inverse/lib/private" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/.import-restrictions deleted file mode 100644 index 0edffb477..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/.import-restrictions +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Rules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/b" - ], - "ForbiddenPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/c" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/doc.go deleted file mode 100644 index a8478f9aa..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/a/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -package a - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/b" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/.import-restrictions deleted file mode 100644 index 49f2c7028..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/.import-restrictions +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Rules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - "" - ], - "ForbiddenPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/c" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/doc.go deleted file mode 100644 index 9cc55a68a..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/b/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// b only public and private packages. The latter it shouldn't. -package b - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/c" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/c/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/c/doc.go deleted file mode 100644 index 7f96c221c..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/c/doc.go +++ /dev/null @@ -1 +0,0 @@ -package c diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/.import-restrictions deleted file mode 100644 index e8c54579a..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/.import-restrictions +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Rules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - ], - "ForbiddenPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/c" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/doc.go deleted file mode 100644 index 45635d384..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -package nested - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/c" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/.import-restrictions deleted file mode 100644 index c32644254..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/.import-restrictions +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Rules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/c" - ], - "ForbiddenPrefixes": [ - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/doc.go deleted file mode 100644 index 45635d384..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -package nested - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/c" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/.import-restrictions b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/.import-restrictions deleted file mode 100644 index 1d49424e2..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/.import-restrictions +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Rules": [{ - "SelectorRegexp": "k8s[.]io/gengo", - "AllowedPrefixes": [ - ], - "ForbiddenPrefixes": [ - "k8s.io/gengo/examples/import-boss/tests/rules/c" - ] - }] -} diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/doc.go deleted file mode 100644 index 45635d384..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -package nested - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/c" -) diff --git a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/inherit/doc.go b/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/inherit/doc.go deleted file mode 100644 index 54c0f5d99..000000000 --- a/vendor/k8s.io/gengo/examples/import-boss/tests/rules/nested/nested/nested/inherit/doc.go +++ /dev/null @@ -1,5 +0,0 @@ -package inherit - -import ( - _ "k8s.io/gengo/examples/import-boss/tests/rules/c" -) diff --git a/vendor/k8s.io/gengo/generator/default_package.go b/vendor/k8s.io/gengo/generator/default_package.go index dcf088323..11517fc6a 100644 --- a/vendor/k8s.io/gengo/generator/default_package.go +++ b/vendor/k8s.io/gengo/generator/default_package.go @@ -26,8 +26,6 @@ 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 @@ -45,9 +43,8 @@ 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) SourcePath() string { return d.Source } +func (d *DefaultPackage) Name() string { return d.PackageName } +func (d *DefaultPackage) Path() string { return d.PackagePath } func (d *DefaultPackage) Filter(c *Context, t *types.Type) bool { if d.FilterFunc != nil { diff --git a/vendor/k8s.io/gengo/generator/execute.go b/vendor/k8s.io/gengo/generator/execute.go index d1b12258c..b5f5aaeb4 100644 --- a/vendor/k8s.io/gengo/generator/execute.go +++ b/vendor/k8s.io/gengo/generator/execute.go @@ -233,13 +233,11 @@ 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(), - PackagePath: p.Path(), - PackageSourcePath: p.SourcePath(), - Header: p.Header(g.Filename()), - Imports: map[string]struct{}{}, + Name: g.Filename(), + FileType: fileType, + PackageName: p.Name(), + Header: p.Header(g.Filename()), + Imports: map[string]struct{}{}, } files[f.Name] = f } else { diff --git a/vendor/k8s.io/gengo/generator/generator.go b/vendor/k8s.io/gengo/generator/generator.go index 4b48f503c..05a3f65fe 100644 --- a/vendor/k8s.io/gengo/generator/generator.go +++ b/vendor/k8s.io/gengo/generator/generator.go @@ -31,8 +31,6 @@ 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 @@ -52,16 +50,14 @@ type Package interface { } type File struct { - 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 + Name string + FileType string + PackageName string + Header []byte + Imports map[string]struct{} + Vars bytes.Buffer + Consts bytes.Buffer + Body bytes.Buffer } type FileType interface { @@ -160,12 +156,6 @@ 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 @@ -213,36 +203,11 @@ 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) } @@ -250,7 +215,5 @@ 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) } diff --git a/vendor/k8s.io/gengo/generator/import_tracker.go b/vendor/k8s.io/gengo/generator/import_tracker.go index 5d87de4ff..5d058410a 100644 --- a/vendor/k8s.io/gengo/generator/import_tracker.go +++ b/vendor/k8s.io/gengo/generator/import_tracker.go @@ -17,7 +17,6 @@ limitations under the License. package generator import ( - "go/token" "strings" "k8s.io/klog" @@ -59,11 +58,6 @@ 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) diff --git a/vendor/k8s.io/gengo/generator/import_tracker_test.go b/vendor/k8s.io/gengo/generator/import_tracker_test.go deleted file mode 100644 index d9a881971..000000000 --- a/vendor/k8s.io/gengo/generator/import_tracker_test.go +++ /dev/null @@ -1,75 +0,0 @@ -/* -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 ( - "reflect" - "testing" - - "k8s.io/gengo/types" -) - -func TestNewImportTracker(t *testing.T) { - tests := []struct { - name string - inputTypes []*types.Type - expectedImports []string - }{ - { - name: "empty", - inputTypes: []*types.Type{}, - expectedImports: []string{}, - }, - { - name: "builtin", - inputTypes: []*types.Type{ - {Name: types.Name{Package: "net/http"}}, - }, - expectedImports: []string{ - `http "net/http"`, - }, - }, - { - name: "sorting", - inputTypes: []*types.Type{ - {Name: types.Name{Package: "foo/bar/pkg2"}}, - {Name: types.Name{Package: "foo/bar/pkg1"}}, - }, - expectedImports: []string{ - `pkg1 "foo/bar/pkg1"`, - `pkg2 "foo/bar/pkg2"`, - }, - }, - { - name: "reserved-keyword", - inputTypes: []*types.Type{ - {Name: types.Name{Package: "my/reserved/pkg/struct"}}, - }, - expectedImports: []string{ - `_struct "my/reserved/pkg/struct"`, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - actualImports := NewImportTracker(tt.inputTypes...).ImportLines() - if !reflect.DeepEqual(actualImports, tt.expectedImports) { - t.Errorf("ImportLines(%v) = %v, want %v", tt.inputTypes, actualImports, tt.expectedImports) - } - }) - } -} diff --git a/vendor/k8s.io/gengo/generator/transitive_closure.go b/vendor/k8s.io/gengo/generator/transitive_closure.go deleted file mode 100644 index 385a49fce..000000000 --- a/vendor/k8s.io/gengo/generator/transitive_closure.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -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 -} diff --git a/vendor/k8s.io/gengo/generator/transitive_closure_test.go b/vendor/k8s.io/gengo/generator/transitive_closure_test.go deleted file mode 100644 index 917f8f7af..000000000 --- a/vendor/k8s.io/gengo/generator/transitive_closure_test.go +++ /dev/null @@ -1,64 +0,0 @@ -/* -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 ( - "reflect" - "testing" -) - -func TestTransitiveClosure(t *testing.T) { - cases := []struct { - name string - in map[string][]string - expected map[string][]string - }{ - { - name: "no transition", - in: map[string][]string{ - "a": {"b"}, - "c": {"d"}, - }, - expected: map[string][]string{ - "a": {"b"}, - "c": {"d"}, - }, - }, - { - name: "simple", - in: map[string][]string{ - "a": {"b"}, - "b": {"c"}, - "c": {"d"}, - }, - expected: map[string][]string{ - "a": {"b", "c", "d"}, - "b": {"c", "d"}, - "c": {"d"}, - }, - }, - } - - for _, c := range cases { - t.Run(c.name, func(t *testing.T) { - out := transitiveClosure(c.in) - if !reflect.DeepEqual(c.expected, out) { - t.Errorf("expected: %#v, got %#v", c.expected, out) - } - }) - } -} diff --git a/vendor/k8s.io/gengo/parser/parse.go b/vendor/k8s.io/gengo/parser/parse.go index 1e457979e..6a3d53b25 100644 --- a/vendor/k8s.io/gengo/parser/parse.go +++ b/vendor/k8s.io/gengo/parser/parse.go @@ -227,16 +227,12 @@ func (b *Builder) AddDirRecursive(dir string) error { klog.Warningf("Ignoring directory %v: %v", dir, err) } - // filepath.Walk does not follow symlinks. We therefore evaluate symlinks and use that with - // filepath.Walk. - realPath, err := filepath.EvalSymlinks(b.buildPackages[dir].Dir) - if err != nil { - return err - } - + // filepath.Walk includes the root dir, but we already did that, so we'll + // remove that prefix and rebuild a package import path. + prefix := b.buildPackages[dir].Dir fn := func(filePath string, info os.FileInfo, err error) error { if info != nil && info.IsDir() { - rel := filepath.ToSlash(strings.TrimPrefix(filePath, realPath)) + rel := filepath.ToSlash(strings.TrimPrefix(filePath, prefix)) if rel != "" { // Make a pkg path. pkg := path.Join(string(canonicalizeImportPath(b.buildPackages[dir].ImportPath)), rel) @@ -249,7 +245,7 @@ func (b *Builder) AddDirRecursive(dir string) error { } return nil } - if err := filepath.Walk(realPath, fn); err != nil { + if err := filepath.Walk(b.buildPackages[dir].Dir, fn); err != nil { return err } return nil diff --git a/vendor/k8s.io/kubernetes/CHANGELOG-1.16.md b/vendor/k8s.io/kubernetes/CHANGELOG-1.16.md index 22cd57cd5..bd489fbeb 100644 --- a/vendor/k8s.io/kubernetes/CHANGELOG-1.16.md +++ b/vendor/k8s.io/kubernetes/CHANGELOG-1.16.md @@ -1,16 +1,22 @@ -- [v1.16.1](#v1161) - - [Downloads for v1.16.1](#downloads-for-v1161) +- [v1.16.2](#v1162) + - [Downloads for v1.16.2](#downloads-for-v1162) - [Client Binaries](#client-binaries) - [Server Binaries](#server-binaries) - [Node Binaries](#node-binaries) + - [Changelog since v1.16.1](#changelog-since-v1161) +- [v1.16.1](#v1161) + - [Downloads for v1.16.1](#downloads-for-v1161) + - [Client Binaries](#client-binaries-1) + - [Server Binaries](#server-binaries-1) + - [Node Binaries](#node-binaries-1) - [Changelog since v1.16.0](#changelog-since-v1160) - [Other notable changes](#other-notable-changes) - [v1.16.0](#v1160) - [Downloads for v1.16.0](#downloads-for-v1160) - - [Client Binaries](#client-binaries-1) - - [Server Binaries](#server-binaries-1) - - [Node Binaries](#node-binaries-1) + - [Client Binaries](#client-binaries-2) + - [Server Binaries](#server-binaries-2) + - [Node Binaries](#node-binaries-2) - [Kubernetes v1.16.0 Release Notes](#kubernetes-v1160-release-notes) - [What’s New (Major Themes)](#whats-new-major-themes) - [Additional Notable Feature Updates](#additional-notable-feature-updates) @@ -54,54 +60,54 @@ - [Removed](#removed-1) - [v1.16.0-rc.2](#v1160-rc2) - [Downloads for v1.16.0-rc.2](#downloads-for-v1160-rc2) - - [Client Binaries](#client-binaries-2) - - [Server Binaries](#server-binaries-2) - - [Node Binaries](#node-binaries-2) + - [Client Binaries](#client-binaries-3) + - [Server Binaries](#server-binaries-3) + - [Node Binaries](#node-binaries-3) - [Changelog since v1.16.0-rc.1](#changelog-since-v1160-rc1) - [Other notable changes](#other-notable-changes-2) - [v1.16.0-rc.1](#v1160-rc1) - [Downloads for v1.16.0-rc.1](#downloads-for-v1160-rc1) - - [Client Binaries](#client-binaries-3) - - [Server Binaries](#server-binaries-3) - - [Node Binaries](#node-binaries-3) + - [Client Binaries](#client-binaries-4) + - [Server Binaries](#server-binaries-4) + - [Node Binaries](#node-binaries-4) - [Changelog since v1.16.0-beta.2](#changelog-since-v1160-beta2) - [Other notable changes](#other-notable-changes-3) - [v1.16.0-beta.2](#v1160-beta2) - [Downloads for v1.16.0-beta.2](#downloads-for-v1160-beta2) - - [Client Binaries](#client-binaries-4) - - [Server Binaries](#server-binaries-4) - - [Node Binaries](#node-binaries-4) + - [Client Binaries](#client-binaries-5) + - [Server Binaries](#server-binaries-5) + - [Node Binaries](#node-binaries-5) - [Changelog since v1.16.0-beta.1](#changelog-since-v1160-beta1) - [Other notable changes](#other-notable-changes-4) - [v1.16.0-beta.1](#v1160-beta1) - [Downloads for v1.16.0-beta.1](#downloads-for-v1160-beta1) - - [Client Binaries](#client-binaries-5) - - [Server Binaries](#server-binaries-5) - - [Node Binaries](#node-binaries-5) + - [Client Binaries](#client-binaries-6) + - [Server Binaries](#server-binaries-6) + - [Node Binaries](#node-binaries-6) - [Changelog since v1.16.0-alpha.3](#changelog-since-v1160-alpha3) - [Action Required](#action-required) - [Other notable changes](#other-notable-changes-5) - [v1.16.0-alpha.3](#v1160-alpha3) - [Downloads for v1.16.0-alpha.3](#downloads-for-v1160-alpha3) - - [Client Binaries](#client-binaries-6) - - [Server Binaries](#server-binaries-6) - - [Node Binaries](#node-binaries-6) + - [Client Binaries](#client-binaries-7) + - [Server Binaries](#server-binaries-7) + - [Node Binaries](#node-binaries-7) - [Changelog since v1.16.0-alpha.2](#changelog-since-v1160-alpha2) - [Action Required](#action-required-1) - [Other notable changes](#other-notable-changes-6) - [v1.16.0-alpha.2](#v1160-alpha2) - [Downloads for v1.16.0-alpha.2](#downloads-for-v1160-alpha2) - - [Client Binaries](#client-binaries-7) - - [Server Binaries](#server-binaries-7) - - [Node Binaries](#node-binaries-7) + - [Client Binaries](#client-binaries-8) + - [Server Binaries](#server-binaries-8) + - [Node Binaries](#node-binaries-8) - [Changelog since v1.16.0-alpha.1](#changelog-since-v1160-alpha1) - [Action Required](#action-required-2) - [Other notable changes](#other-notable-changes-7) - [v1.16.0-alpha.1](#v1160-alpha1) - [Downloads for v1.16.0-alpha.1](#downloads-for-v1160-alpha1) - - [Client Binaries](#client-binaries-8) - - [Server Binaries](#server-binaries-8) - - [Node Binaries](#node-binaries-8) + - [Client Binaries](#client-binaries-9) + - [Server Binaries](#server-binaries-9) + - [Node Binaries](#node-binaries-9) - [Changelog since v1.15.0](#changelog-since-v1150) - [Action Required](#action-required-3) - [Other notable changes](#other-notable-changes-8) @@ -110,6 +116,70 @@ +# v1.16.2 + +[Documentation](https://docs.k8s.io) + +## Downloads for v1.16.2 + + +filename | sha512 hash +-------- | ----------- +[kubernetes.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes.tar.gz) | `9e21ab6317fe209dabac72444273b493f5f7639f73c489cc233da3a0205a93f8779964fe2cf2237bb6ca7535560c7c8ac48e25e75a1fbe97dc5b51f248ed7eeb` +[kubernetes-src.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-src.tar.gz) | `2e52029a8669f51020f689b0da481f56ab922ecd2c4495e37cb8456e9b10fee50f97bf9faa6a3bc947e4142aa4e5374d7f905a22e5f18830610eacfdf47adbc6` + +### Client Binaries + +filename | sha512 hash +-------- | ----------- +[kubernetes-client-darwin-386.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-darwin-386.tar.gz) | `6424b3047c5d7557b6c5536f29139bb6f71e4357b5e181d62bfd5fbf7d5575c9d5eeeab531b0afcc72ac17dd6609162bebc1045932ee58cbeb3093a4107cbf3a` +[kubernetes-client-darwin-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-darwin-amd64.tar.gz) | `791d2a4f965130ea1d7033f807b29015520afa317f97643f27480a6530213fd3fa06817ba9ce04e81f843b8420f05baa25e597e5880f99cc2ffbfc8b8ebf18cf` +[kubernetes-client-linux-386.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-386.tar.gz) | `fd727fe3200975f71d1f5b21991e5b8d2471e92dc3185df29b8ef21a9aa87d270baa1bd2f9f2dbe61abe9e9541ee806709d6ed08aa13254a5953ddc1f1ddb5a6` +[kubernetes-client-linux-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-amd64.tar.gz) | `69bb92c9b16c0286d7401d87cc73b85c88d6f9a17d2cf1748060e44525194b5be860daf7554c4c6319a546c9ff10f2b4df42a27e32d8f95a4052993b17ef57c0` +[kubernetes-client-linux-arm.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-arm.tar.gz) | `f846f6018eb3d82741e6d2e8fd2f9f7ca8768ead56c3e2c330ba7e7dbba3209dd66f793b37d330134d3e8f38a03d6492e0054e55fcf32f74743b7b26f3159210` +[kubernetes-client-linux-arm64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-arm64.tar.gz) | `49cb3495fa8bbe64cefdb9aab83d4cfbe6a0f3a0e58b1685a49244df02e5ee8bbfaf0be133f5cf5231b1470bb62bd699cd6aba8072cb6ea3542f3ccfd42d3813` +[kubernetes-client-linux-ppc64le.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-ppc64le.tar.gz) | `35a8b25309150cf5e1dab2af1d5118a24d296e21cdaf4bdec615badbc27a109ffb8b0e1cd93439fb728ec4905178eae2eb9d2ec2760053211b495c103d76fe3b` +[kubernetes-client-linux-s390x.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-linux-s390x.tar.gz) | `ffd5ab012d38b7a7b9e0acd8339c30545a60bcabba5642f5020464846391ae41930e84c0103231f850f0f0c86e064c18f47bff95ccf11b410c0216a4d887b2fb` +[kubernetes-client-windows-386.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-windows-386.tar.gz) | `c04d33b31734c7b25c54daa361986fcb745178320daa54d76b7627c475346a87c65443f7b139e1c86436b27eb9d10ed4a61ba5a64e0420bb6ce2f68fbad0a1b0` +[kubernetes-client-windows-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-client-windows-amd64.tar.gz) | `e81fcf83523dd1dc79de7b498df6115465eb83d31a400853cdf143870a281322f24be5609d0c541810f90047a3c4e75530b9a6e872e51ed00d268530f2ed7ca9` + +### Server Binaries + +filename | sha512 hash +-------- | ----------- +[kubernetes-server-linux-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-server-linux-amd64.tar.gz) | `4aa3da6d146db878f4605ea6334925e925268808856f482ea7f9d131dce76ee30d4ba077a6b35de34a68d8d9ca005cccd2e7e4866b775c1f7eaba1320a1b8ec5` +[kubernetes-server-linux-arm.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-server-linux-arm.tar.gz) | `0a9cea07a1172038d300277f1d305d99b147ae5949df3dd63856944cc0e4724105a0d79bf9ea39dface923d794b71e9f40d4104218167e56096a9e82a422864a` +[kubernetes-server-linux-arm64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-server-linux-arm64.tar.gz) | `b1aadb87ff310aec7292df5386613c4c0036c0e3c20e0a4ab7bd3d5eea8fff0116c8b8b47289e894950b249be4207daac58449ec9a587353873890b47217ecd8` +[kubernetes-server-linux-ppc64le.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-server-linux-ppc64le.tar.gz) | `2aecda7fb53efd23c34cfe90ae37d55efec513996573c9124d9bf94809ea5a86bcd786e84d646039fbaff2e42d7e8f9c5db179beec3fac1f0a420920c93dce35` +[kubernetes-server-linux-s390x.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-server-linux-s390x.tar.gz) | `74fd3d5dbedac211570ef011f14e98d37848587b670038c69354c0162668aa2c6789835a5dbfc82f43fb9662444756f974de75917f75f59ab51e6ae9183e5c20` + +### Node Binaries + +filename | sha512 hash +-------- | ----------- +[kubernetes-node-linux-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-linux-amd64.tar.gz) | `d1e139006e1ce6b66a1c0b9dd90509db712e5e024e1c5a4c0a1bb185211dd138cbcf201e6a9cdf7df9b78b6817523da23097c8396c0afb98481052447d329cc9` +[kubernetes-node-linux-arm.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-linux-arm.tar.gz) | `5779c23d4f77edf5d5c3b8bb55fd190bf180f13c782e44a50a96572477af30008685c4e670c07ceb56c8e64390be7e7cbf14a9b25c894c66f90131a993bda4fc` +[kubernetes-node-linux-arm64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-linux-arm64.tar.gz) | `f09bc220a05b8f5fca6d4575198ac2b7625fcbceb09ffd6da587c8b13a5b93365b601b94a25fb8cc360c7521ccc30d11d86d88490f5a48369f6078c4395593c2` +[kubernetes-node-linux-ppc64le.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-linux-ppc64le.tar.gz) | `96b3f8578e4f5e5261489ba392e7167bfdbe5ec6fb60a369455edffbc027b3086bd99055f7e3cabbf56426b7b181764d5cd5979bacd3ad8c26b541cd94ce62d8` +[kubernetes-node-linux-s390x.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-linux-s390x.tar.gz) | `4c9c7e541164781231378091cae0ab693c29b517b7737be191436c5e85ea4702cdd640890ae7c1295273270cb7944e2a250e2791a9a07bb415dac67d3129d1c1` +[kubernetes-node-windows-amd64.tar.gz](https://dl.k8s.io/v1.16.2/kubernetes-node-windows-amd64.tar.gz) | `a88e7a1c6f72ea6073dbb4ddfe2e7c8bd37c9a56d94a33823f531e303a9915e7a844ac5880097724e44dfa7f4a9659d14b79cc46e2067f6b13e6df3f3f1b0f64` + +## Changelog since v1.16.1 + +### Other notable changes + +* Fixed panic when accessing CustomResources of a CRD with x-kubernetes-int-or-string. ([#83789](https://github.com/kubernetes/kubernetes/pull/83789), [@sttts](https://github.com/sttts)) +* Fixed a bug in the single-numa-node policy of the TopologyManager. Previously, pods that only requested CPU resources and did not request any third-party devices would fail to launch with a TopologyAffinity error. Now they will launch successfully. ([#83697](https://github.com/kubernetes/kubernetes/pull/83697), [@klueska](https://github.com/klueska)) +* Fixes kube-proxy bug accessing self nodeip:port on windows ([#83027](https://github.com/kubernetes/kubernetes/pull/83027), [@liggitt](https://github.com/liggitt)) +* Fix error where metrics related to dynamic kubelet config isn't registered ([#83184](https://github.com/kubernetes/kubernetes/pull/83184), [@odinuge](https://github.com/odinuge)) +* Use online nodes instead of possible nodes when discovering available NUMA nodes ([#83196](https://github.com/kubernetes/kubernetes/pull/83196), [@zouyee](https://github.com/zouyee)) +* Update Azure load balancer to prevent orphaned public IP addresses ([#82890](https://github.com/kubernetes/kubernetes/pull/82890), [@chewong](https://github.com/chewong)) +* Fixes a goroutine leak in kube-apiserver when a request times out. ([#83333](https://github.com/kubernetes/kubernetes/pull/83333), [@lavalamp](https://github.com/lavalamp)) +* Fix aggressive VM calls for Azure VMSS ([#83102](https://github.com/kubernetes/kubernetes/pull/83102), [@feiskyer](https://github.com/feiskyer)) +* Fixes a flaw (CVE-2019-11253) in json/yaml decoding where large or malformed documents could consume excessive server resources. Request bodies for normal API requests (create/delete/update/patch operations of regular resources) are now limited to 3MB. ([#83261](https://github.com/kubernetes/kubernetes/pull/83261), [@liggitt](https://github.com/liggitt)) + + + # v1.16.1 [Documentation](https://docs.k8s.io) @@ -253,6 +323,7 @@ The main themes of this release are: - Systems running `iptables` 1.8.0 or newer should start it in legacy mode. Please note that this affects all versions of Kubernetes and not only v1.16.0. For more detailed information about the issue and how to apply a workaround, please refer to the official documentation - Generating informers for packages in directories containing dots in their name is broken. This will be fixed in v1.16.1. ([#82860](https://github.com/kubernetes/kubernetes/issues/82860)) - kube-scheduler won't be able to report scheduling Events if `events.k8s.io/v1beta1` API is disabled. We are targeting the fix for v1.16.2 ([#83203](https://github.com/kubernetes/kubernetes/issues/83203)) +- The etcd client library vendored in v1.16 (github.com/coreos/etcd/clientv3) has a bug where IPv6 IP addresses get incorrectly trimmed to the first occurance of the `:` character. This affects all users of the client library including the kube-apiserver and kubeadm. We are targeting the fix for this bug in v1.16.3. ([#83550](https://github.com/kubernetes/kubernetes/issues/83550)) ## Urgent Upgrade Notes diff --git a/vendor/k8s.io/kubernetes/api/openapi-spec/swagger.json b/vendor/k8s.io/kubernetes/api/openapi-spec/swagger.json index c63207305..57efdce42 100644 --- a/vendor/k8s.io/kubernetes/api/openapi-spec/swagger.json +++ b/vendor/k8s.io/kubernetes/api/openapi-spec/swagger.json @@ -20106,7 +20106,7 @@ }, "info": { "title": "Kubernetes", - "version": "v1.16.2" + "version": "v1.16.3" }, "paths": { "/api/": { diff --git a/vendor/k8s.io/kubernetes/build/build-image/cross/Dockerfile b/vendor/k8s.io/kubernetes/build/build-image/cross/Dockerfile index efcc54f1b..18b8fccfb 100644 --- a/vendor/k8s.io/kubernetes/build/build-image/cross/Dockerfile +++ b/vendor/k8s.io/kubernetes/build/build-image/cross/Dockerfile @@ -15,7 +15,7 @@ # This file creates a standard build environment for building cross # platform go binary for the architecture kubernetes cares about. -FROM golang:1.12.10 +FROM golang:1.12.12 ENV GOARM 7 ENV KUBE_DYNAMIC_CROSSPLATFORMS \ diff --git a/vendor/k8s.io/kubernetes/build/build-image/cross/VERSION b/vendor/k8s.io/kubernetes/build/build-image/cross/VERSION index 22276e2bf..1a8543adf 100644 --- a/vendor/k8s.io/kubernetes/build/build-image/cross/VERSION +++ b/vendor/k8s.io/kubernetes/build/build-image/cross/VERSION @@ -1 +1 @@ -v1.12.10-1 +v1.12.12-1 diff --git a/vendor/k8s.io/kubernetes/build/dependencies.yaml b/vendor/k8s.io/kubernetes/build/dependencies.yaml index 7a5310e3c..3a3d328ba 100644 --- a/vendor/k8s.io/kubernetes/build/dependencies.yaml +++ b/vendor/k8s.io/kubernetes/build/dependencies.yaml @@ -34,7 +34,7 @@ dependencies: - name: "golang" - version: 1.12.10 + version: 1.12.12 refPaths: - path: build/build-image/cross/Dockerfile match: "golang:" diff --git a/vendor/k8s.io/kubernetes/build/lib/release.sh b/vendor/k8s.io/kubernetes/build/lib/release.sh index 73c0bcca6..470cfbd14 100644 --- a/vendor/k8s.io/kubernetes/build/lib/release.sh +++ b/vendor/k8s.io/kubernetes/build/lib/release.sh @@ -337,7 +337,10 @@ function kube::release::create_docker_images_for_server() { local images_dir="${RELEASE_IMAGES}/${arch}" mkdir -p "${images_dir}" - local -r docker_registry="${KUBE_DOCKER_REGISTRY}" + # k8s.gcr.io is the constant tag in the docker archives, this is also the default for config scripts in GKE. + # We can use KUBE_DOCKER_REGISTRY to include and extra registry in the docker archive. + # If we use KUBE_DOCKER_REGISTRY="k8s.gcr.io", then the extra tag (same) is ignored, see release_docker_image_tag below. + local -r docker_registry="k8s.gcr.io" # Docker tags cannot contain '+' local docker_tag="${KUBE_GIT_VERSION/+/_}" if [[ -z "${docker_tag}" ]]; then diff --git a/vendor/k8s.io/kubernetes/build/root/.bazelrc b/vendor/k8s.io/kubernetes/build/root/.bazelrc index bb4b4679e..123d0ed92 100644 --- a/vendor/k8s.io/kubernetes/build/root/.bazelrc +++ b/vendor/k8s.io/kubernetes/build/root/.bazelrc @@ -10,6 +10,7 @@ build --verbose_failures test --test_output=errors # Include git version info +build --stamp build --workspace_status_command hack/print-workspace-status.sh # Make /tmp hermetic diff --git a/vendor/k8s.io/kubernetes/build/root/WORKSPACE b/vendor/k8s.io/kubernetes/build/root/WORKSPACE index 7b3cafc1c..cf2e01649 100644 --- a/vendor/k8s.io/kubernetes/build/root/WORKSPACE +++ b/vendor/k8s.io/kubernetes/build/root/WORKSPACE @@ -44,8 +44,8 @@ http_archive( http_archive( name = "io_bazel_rules_go", - sha256 = "5c02dd4436332f8efa982ce2102daf7c041ae95c2bc7f2d26aceed20dc47def8", - urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/v0.18.11/rules_go-v0.18.11.tar.gz"), + sha256 = "b480589f57e8b09f4b0892437b9afe889e0d6660e92f5d53d3f0546c01e67ca5", + urls = mirror("https://github.com/bazelbuild/rules_go/releases/download/v0.19.7/rules_go-v0.19.7.tar.gz"), ) load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") @@ -53,7 +53,7 @@ load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_depe go_rules_dependencies() go_register_toolchains( - go_version = "1.12.10", + go_version = "1.12.12", ) http_archive( diff --git a/vendor/k8s.io/kubernetes/cluster/gce/gci/configure.sh b/vendor/k8s.io/kubernetes/cluster/gce/gci/configure.sh index 77b558e6f..d3fbfe3c9 100644 --- a/vendor/k8s.io/kubernetes/cluster/gce/gci/configure.sh +++ b/vendor/k8s.io/kubernetes/cluster/gce/gci/configure.sh @@ -131,7 +131,7 @@ function get-credentials { } function valid-storage-scope { - curl --fail --retry 5 --retry-delay 3 ${CURL_RETRY_CONNREFUSED} --silent --show-error "${GCE_METADATA_INTERNAL}/service-accounts/default/scopes" -H "Metadata-Flavor: Google" -s | grep -q "auth/devstorage" + curl --fail --retry 5 --retry-delay 3 ${CURL_RETRY_CONNREFUSED} --silent --show-error "${GCE_METADATA_INTERNAL}/service-accounts/default/scopes" -H "Metadata-Flavor: Google" -s | grep -E "auth/devstorage|auth/cloud-platform" } # Retry a download until we get it. Takes a hash and a set of URLs. diff --git a/vendor/k8s.io/kubernetes/cluster/get-kube-binaries.sh b/vendor/k8s.io/kubernetes/cluster/get-kube-binaries.sh index e7160fc8a..6004072f7 100755 --- a/vendor/k8s.io/kubernetes/cluster/get-kube-binaries.sh +++ b/vendor/k8s.io/kubernetes/cluster/get-kube-binaries.sh @@ -151,7 +151,7 @@ function get-credentials { } function valid-storage-scope { - curl "${GCE_METADATA_INTERNAL}/service-accounts/default/scopes" -H "Metadata-Flavor: Google" -s | grep -q "auth/devstorage" + curl "${GCE_METADATA_INTERNAL}/service-accounts/default/scopes" -H "Metadata-Flavor: Google" -s | grep -E "auth/devstorage|auth/cloud-platform" } function download_tarball() { @@ -166,7 +166,7 @@ function download_tarball() { mkdir -p "${download_path}" if [[ $(which curl) ]]; then # if the url belongs to GCS API we should use oauth2_token in the headers - local curl_headers="" + curl_headers="" if { [[ "${KUBERNETES_PROVIDER:-gce}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]] ; } && [[ "$url" =~ ^https://storage.googleapis.com.* ]] && valid-storage-scope ; then curl_headers="Authorization: Bearer $(get-credentials)" diff --git a/vendor/k8s.io/kubernetes/cluster/get-kube.sh b/vendor/k8s.io/kubernetes/cluster/get-kube.sh index ac1fd9765..510ef378c 100755 --- a/vendor/k8s.io/kubernetes/cluster/get-kube.sh +++ b/vendor/k8s.io/kubernetes/cluster/get-kube.sh @@ -122,6 +122,17 @@ function create_cluster { ) } +# Get default service account credentials of the VM. +GCE_METADATA_INTERNAL="http://metadata.google.internal/computeMetadata/v1/instance" +function get-credentials { + curl "${GCE_METADATA_INTERNAL}/service-accounts/default/token" -H "Metadata-Flavor: Google" -s | python -c \ + 'import sys; import json; print(json.loads(sys.stdin.read())["access_token"])' +} + +function valid-storage-scope { + curl "${GCE_METADATA_INTERNAL}/service-accounts/default/scopes" -H "Metadata-Flavor: Google" -s | grep -E "auth/devstorage|auth/cloud-platform" +} + if [[ -n "${KUBERNETES_SKIP_DOWNLOAD-}" ]]; then create_cluster exit 0 @@ -228,7 +239,13 @@ fi if "${need_download}"; then if [[ $(which curl) ]]; then - curl -fL --retry 5 --keepalive-time 2 "${kubernetes_tar_url}" -o "${file}" + # if the url belongs to GCS API we should use oauth2_token in the headers + curl_headers="" + if { [[ "${KUBERNETES_PROVIDER:-gce}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]] ; } && + [[ "$kubernetes_tar_url" =~ ^https://storage.googleapis.com.* ]] && valid-storage-scope ; then + curl_headers="Authorization: Bearer $(get-credentials)" + fi + curl ${curl_headers:+-H "${curl_headers}"} -fL --retry 3 --keepalive-time 2 "${kubernetes_tar_url}" -o "${file}" elif [[ $(which wget) ]]; then wget "${kubernetes_tar_url}" else diff --git a/vendor/k8s.io/kubernetes/pkg/controller/disruption/disruption.go b/vendor/k8s.io/kubernetes/pkg/controller/disruption/disruption.go index 6fe7d16b2..8be258d10 100644 --- a/vendor/k8s.io/kubernetes/pkg/controller/disruption/disruption.go +++ b/vendor/k8s.io/kubernetes/pkg/controller/disruption/disruption.go @@ -21,7 +21,7 @@ import ( "time" apps "k8s.io/api/apps/v1beta1" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/api/extensions/v1beta1" policy "k8s.io/api/policy/v1beta1" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -363,7 +363,19 @@ func (dc *DisruptionController) updateDb(old, cur interface{}) { } func (dc *DisruptionController) removeDb(obj interface{}) { - pdb := obj.(*policy.PodDisruptionBudget) + pdb, ok := obj.(*policy.PodDisruptionBudget) + if !ok { + tombstone, ok := obj.(cache.DeletedFinalStateUnknown) + if !ok { + klog.Errorf("Couldn't get object from tombstone %+v", obj) + return + } + pdb, ok = tombstone.Obj.(*policy.PodDisruptionBudget) + if !ok { + klog.Errorf("Tombstone contained object that is not a pdb %+v", obj) + return + } + } klog.V(4).Infof("remove DB %q", pdb.Name) dc.enqueuePdb(pdb) } diff --git a/vendor/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go b/vendor/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go index 8feac0810..5a4b657ca 100644 --- a/vendor/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go +++ b/vendor/k8s.io/kubernetes/staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go @@ -315,6 +315,11 @@ func (ss *scaleSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) { } else if vm.InstanceView != nil && vm.InstanceView.PlatformFaultDomain != nil { // Availability zone is not used for the node, falling back to fault domain. failureDomain = strconv.Itoa(int(*vm.InstanceView.PlatformFaultDomain)) + } else { + err = fmt.Errorf("failed to get zone info") + klog.Errorf("GetZoneByNodeName: got unexpected error %v", err) + ss.deleteCacheForNode(name) + return cloudprovider.Zone{}, err } return cloudprovider.Zone{ diff --git a/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/BUILD b/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/BUILD index b2f713a16..754926a78 100644 --- a/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/BUILD +++ b/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/BUILD @@ -43,7 +43,6 @@ go_library( "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/csi-translation-lib:go_default_library", "//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library", - "//test/e2e/common:go_default_library", "//test/e2e/framework:go_default_library", "//test/e2e/framework/log:go_default_library", "//test/e2e/framework/metrics:go_default_library", diff --git a/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/volumemode.go b/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/volumemode.go index 12735181d..0f5d7e4f9 100644 --- a/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/volumemode.go +++ b/vendor/k8s.io/kubernetes/test/e2e/storage/testsuites/volumemode.go @@ -19,6 +19,7 @@ package testsuites import ( "fmt" "strings" + "time" "github.com/onsi/ginkgo" "github.com/onsi/gomega" @@ -27,10 +28,10 @@ import ( storagev1 "k8s.io/api/storage/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/fields" + "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" volevents "k8s.io/kubernetes/pkg/controller/volume/events" "k8s.io/kubernetes/pkg/kubelet/events" - "k8s.io/kubernetes/test/e2e/common" "k8s.io/kubernetes/test/e2e/framework" e2elog "k8s.io/kubernetes/test/e2e/framework/log" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" @@ -221,7 +222,7 @@ func (t *volumeModeTestSuite) defineTests(driver TestDriver, pattern testpattern }.AsSelector().String() msg := "Unable to attach or mount volumes" - err = common.WaitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.PodStartTimeout) + err = waitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.PodStartTimeout) // Events are unreliable, don't depend on the event. It's used only to speed up the test. if err != nil { e2elog.Logf("Warning: did not get event about FailedMountVolume") @@ -258,7 +259,7 @@ func (t *volumeModeTestSuite) defineTests(driver TestDriver, pattern testpattern }.AsSelector().String() msg := "does not support block volume provisioning" - err = common.WaitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.ClaimProvisionTimeout) + err = waitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.ClaimProvisionTimeout) // Events are unreliable, don't depend on the event. It's used only to speed up the test. if err != nil { e2elog.Logf("Warning: did not get event about provisioing failed") @@ -308,7 +309,7 @@ func (t *volumeModeTestSuite) defineTests(driver TestDriver, pattern testpattern } else { msg = "has volumeMode Filesystem, but is specified in volumeDevices" } - err = common.WaitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.PodStartTimeout) + err = waitTimeoutForEvent(l.cs, l.ns.Name, eventSelector, msg, framework.PodStartTimeout) // Events are unreliable, don't depend on them. They're used only to speed up the test. if err != nil { e2elog.Logf("Warning: did not get event about mismatched volume use") @@ -426,3 +427,32 @@ func swapVolumeMode(podTemplate *v1.Pod) *v1.Pod { } return pod } + +// NOTE(avalluri): The below code is intentionally copied from e2e/common package. +// Testsuites depending on common package is not desirable as that pulls quite +// many tests which are not interested by storage suites. +// +// waitTimeoutForEvent waits the given timeout duration for an event to occur. +func waitTimeoutForEvent(c clientset.Interface, namespace, eventSelector, msg string, timeout time.Duration) error { + interval := 2 * time.Second + return wait.PollImmediate(interval, timeout, eventOccurred(c, namespace, eventSelector, msg)) +} + +// NOTE(avalluri): The below code is intentionally copied from e2e/common package. +// Testsuites depending on common package is not desirable as that pulls quite +// many tests which are not interested by storage suites. +func eventOccurred(c clientset.Interface, namespace, eventSelector, msg string) wait.ConditionFunc { + options := metav1.ListOptions{FieldSelector: eventSelector} + return func() (bool, error) { + events, err := c.CoreV1().Events(namespace).List(options) + if err != nil { + return false, fmt.Errorf("got error while getting events: %v", err) + } + for _, event := range events.Items { + if strings.Contains(event.Message, msg) { + return true, nil + } + } + return false, nil + } +} diff --git a/vendor/k8s.io/kubernetes/test/e2e_node/startup_probe_test.go b/vendor/k8s.io/kubernetes/test/e2e_node/startup_probe_test.go index d7b50c2be..077395845 100644 --- a/vendor/k8s.io/kubernetes/test/e2e_node/startup_probe_test.go +++ b/vendor/k8s.io/kubernetes/test/e2e_node/startup_probe_test.go @@ -38,9 +38,12 @@ const ( defaultObservationTimeout = time.Minute * 4 ) -var _ = framework.KubeDescribe("StartupProbe [Serial] [Disruptive] [NodeFeature:StartupProbe]", func() { - f := framework.NewDefaultFramework("critical-pod-test") +var _ = framework.KubeDescribe("StartupProbe [Serial] [Disruptive] [NodeAlphaFeature:StartupProbe]", func() { + f := framework.NewDefaultFramework("startup-probe-test") var podClient *framework.PodClient + ginkgo.BeforeEach(func() { + podClient = f.PodClient() + }) /* These tests are located here as they require tempSetCurrentKubeletConfig to enable the feature gate for startupProbe. diff --git a/vendor/k8s.io/kubernetes/test/images/Makefile b/vendor/k8s.io/kubernetes/test/images/Makefile index ead09b114..9c566db63 100644 --- a/vendor/k8s.io/kubernetes/test/images/Makefile +++ b/vendor/k8s.io/kubernetes/test/images/Makefile @@ -17,7 +17,7 @@ include ../../hack/make-rules/Makefile.manifest REGISTRY ?= gcr.io/kubernetes-e2e-test-images GOARM ?= 7 QEMUVERSION=v2.9.1 -GOLANG_VERSION=1.12.10 +GOLANG_VERSION=1.12.12 export ifndef WHAT