Bumping k8s dependencies to 1.13
This commit is contained in:
25
vendor/k8s.io/kubernetes/pkg/util/coverage/BUILD
generated
vendored
Normal file
25
vendor/k8s.io/kubernetes/pkg/util/coverage/BUILD
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"coverage_disabled.go",
|
||||
"fake_test_deps.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/util/coverage",
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
8
vendor/k8s.io/kubernetes/pkg/util/coverage/OWNERS
generated
vendored
Normal file
8
vendor/k8s.io/kubernetes/pkg/util/coverage/OWNERS
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
approvers:
|
||||
- bentheelder
|
||||
- spiffxp
|
||||
reviewers:
|
||||
- bentheelder
|
||||
- spiffxp
|
||||
labels:
|
||||
- sig/testing
|
91
vendor/k8s.io/kubernetes/pkg/util/coverage/coverage.go
generated
vendored
Normal file
91
vendor/k8s.io/kubernetes/pkg/util/coverage/coverage.go
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
// +build coverage
|
||||
|
||||
/*
|
||||
Copyright 2018 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 coverage provides tools for coverage-instrumented binaries to collect and
|
||||
// flush coverage information.
|
||||
package coverage
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
var coverageFile string
|
||||
|
||||
// tempCoveragePath returns a temporary file to write coverage information to.
|
||||
// The file is in the same directory as the destination, ensuring os.Rename will work.
|
||||
func tempCoveragePath() string {
|
||||
return coverageFile + ".tmp"
|
||||
}
|
||||
|
||||
// InitCoverage is called from the dummy unit test to prepare Go's coverage framework.
|
||||
// Clients should never need to call it.
|
||||
func InitCoverage(name string) {
|
||||
// We read the coverage destination in from the KUBE_COVERAGE_FILE env var,
|
||||
// or if it's empty we just use a default in /tmp
|
||||
coverageFile = os.Getenv("KUBE_COVERAGE_FILE")
|
||||
if coverageFile == "" {
|
||||
coverageFile = "/tmp/k8s-" + name + ".cov"
|
||||
}
|
||||
fmt.Println("Dumping coverage information to " + coverageFile)
|
||||
|
||||
flushInterval := 5 * time.Second
|
||||
requestedInterval := os.Getenv("KUBE_COVERAGE_FLUSH_INTERVAL")
|
||||
if requestedInterval != "" {
|
||||
if duration, err := time.ParseDuration(requestedInterval); err == nil {
|
||||
flushInterval = duration
|
||||
} else {
|
||||
panic("Invalid KUBE_COVERAGE_FLUSH_INTERVAL value; try something like '30s'.")
|
||||
}
|
||||
}
|
||||
|
||||
// Set up the unit test framework with the required arguments to activate test coverage.
|
||||
flag.CommandLine.Parse([]string{"-test.coverprofile", tempCoveragePath()})
|
||||
|
||||
// Begin periodic logging
|
||||
go wait.Forever(FlushCoverage, flushInterval)
|
||||
}
|
||||
|
||||
// FlushCoverage flushes collected coverage information to disk.
|
||||
// The destination file is configured at startup and cannot be changed.
|
||||
// Calling this function also sends a line like "coverage: 5% of statements" to stdout.
|
||||
func FlushCoverage() {
|
||||
// We're not actually going to run any tests, but we need Go to think we did so it writes
|
||||
// coverage information to disk. To achieve this, we create a bunch of empty test suites and
|
||||
// have it "run" them.
|
||||
tests := []testing.InternalTest{}
|
||||
benchmarks := []testing.InternalBenchmark{}
|
||||
examples := []testing.InternalExample{}
|
||||
|
||||
var deps fakeTestDeps
|
||||
|
||||
dummyRun := testing.MainStart(deps, tests, benchmarks, examples)
|
||||
dummyRun.Run()
|
||||
|
||||
// Once it writes to the temporary path, we move it to the intended path.
|
||||
// This gets us atomic updates from the perspective of another process trying to access
|
||||
// the file.
|
||||
if err := os.Rename(tempCoveragePath(), coverageFile); err != nil {
|
||||
glog.Errorf("Couldn't move coverage file from %s to %s", coverageFile, tempCoveragePath())
|
||||
}
|
||||
}
|
29
vendor/k8s.io/kubernetes/pkg/util/coverage/coverage_disabled.go
generated
vendored
Normal file
29
vendor/k8s.io/kubernetes/pkg/util/coverage/coverage_disabled.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// +build !coverage
|
||||
|
||||
/*
|
||||
Copyright 2018 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 coverage
|
||||
|
||||
// InitCoverage is illegal when not running with coverage.
|
||||
func InitCoverage(name string) {
|
||||
panic("Called InitCoverage when not built with coverage instrumentation.")
|
||||
}
|
||||
|
||||
// FlushCoverage is a no-op when not running with coverage.
|
||||
func FlushCoverage() {
|
||||
|
||||
}
|
54
vendor/k8s.io/kubernetes/pkg/util/coverage/fake_test_deps.go
generated
vendored
Normal file
54
vendor/k8s.io/kubernetes/pkg/util/coverage/fake_test_deps.go
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2018 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 coverage
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// This is an implementation of testing.testDeps. It doesn't need to do anything, because
|
||||
// no tests are actually run. It does need a concrete implementation of at least ImportPath,
|
||||
// which is called unconditionally when running tests.
|
||||
type fakeTestDeps struct{}
|
||||
|
||||
func (fakeTestDeps) ImportPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (fakeTestDeps) MatchString(pat, str string) (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (fakeTestDeps) StartCPUProfile(io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakeTestDeps) StopCPUProfile() {}
|
||||
|
||||
func (fakeTestDeps) StartTestLog(io.Writer) {}
|
||||
|
||||
func (fakeTestDeps) StopTestLog() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakeTestDeps) WriteHeapProfile(io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fakeTestDeps) WriteProfileTo(string, io.Writer, int) error {
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user