mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #96011 from mikedanese/bazel
build: Update bazel to 3.4.1 and k/repo-infra to v0.2.0
This commit is contained in:
commit
0fe6f72d9b
@ -17,7 +17,7 @@ dependencies:
|
|||||||
|
|
||||||
# Bazel
|
# Bazel
|
||||||
- name: "repo-infra"
|
- name: "repo-infra"
|
||||||
version: 0.1.3
|
version: 0.2.0
|
||||||
refPaths:
|
refPaths:
|
||||||
- path: build/root/WORKSPACE
|
- path: build/root/WORKSPACE
|
||||||
match: strip_prefix = "repo-infra-\d+.\d+.\d+"
|
match: strip_prefix = "repo-infra-\d+.\d+.\d+"
|
||||||
|
@ -1 +1 @@
|
|||||||
2.2.0
|
3.4.1
|
||||||
|
@ -5,10 +5,10 @@ load("//build:workspace_mirror.bzl", "mirror")
|
|||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "io_k8s_repo_infra",
|
name = "io_k8s_repo_infra",
|
||||||
strip_prefix = "repo-infra-0.1.3",
|
sha256 = "2f30f87259fed7262d9b95b2665e3d3ecd928d174a4f0356063bc99056b6f84c",
|
||||||
sha256 = "46933bedbd22bc6a26ec6116d0d3e1475ad6b23447648d19abd6493241323311",
|
strip_prefix = "repo-infra-0.2.0",
|
||||||
urls = [
|
urls = [
|
||||||
"https://github.com/kubernetes/repo-infra/archive/v0.1.3.tar.gz",
|
"https://github.com/kubernetes/repo-infra/archive/v0.2.0.tar.gz",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ load("@io_k8s_repo_infra//:repos.bzl", repo_infra_configure = "configure", repo_
|
|||||||
# by kubernetes/repo-infra
|
# by kubernetes/repo-infra
|
||||||
repo_infra_configure(
|
repo_infra_configure(
|
||||||
go_version = "1.15.5",
|
go_version = "1.15.5",
|
||||||
minimum_bazel_version = "2.2.0",
|
minimum_bazel_version = "3.4.1",
|
||||||
)
|
)
|
||||||
|
|
||||||
repo_infra_go_repositories()
|
repo_infra_go_repositories()
|
||||||
|
@ -17,10 +17,10 @@ limitations under the License.
|
|||||||
package fixtures
|
package fixtures
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -38,24 +38,9 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
_, thisFile, _, ok := runtime.Caller(0)
|
fixturesDir, err := pkgPath()
|
||||||
if !ok {
|
|
||||||
panic("Cannot get path to the fixtures")
|
|
||||||
}
|
|
||||||
|
|
||||||
fixturesDir := filepath.Dir(thisFile)
|
|
||||||
|
|
||||||
cwd, err := os.Getwd()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("Cannot get CWD: " + err.Error())
|
panic(fmt.Sprintf("Cannot get path to the fixtures: %s", err))
|
||||||
}
|
|
||||||
|
|
||||||
// When tests run in a bazel sandbox `runtime.Caller()`
|
|
||||||
// returns a relative path, when run with plain `go test` the path
|
|
||||||
// returned is absolute. To make those fixtures work in both those cases,
|
|
||||||
// we prepend the CWD iff the CWD is not yet part of the path to the fixtures.
|
|
||||||
if !strings.HasPrefix(fixturesDir, cwd) {
|
|
||||||
fixturesDir = filepath.Join(cwd, fixturesDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CaCertPath = filepath.Join(fixturesDir, "ca.pem")
|
CaCertPath = filepath.Join(fixturesDir, "ca.pem")
|
||||||
@ -63,3 +48,33 @@ func init() {
|
|||||||
ServerKeyPath = filepath.Join(fixturesDir, "server.key")
|
ServerKeyPath = filepath.Join(fixturesDir, "server.key")
|
||||||
InvalidCertPath = filepath.Join(fixturesDir, "invalid.pem")
|
InvalidCertPath = filepath.Join(fixturesDir, "invalid.pem")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pkgPath returns the absolute file path to this package's directory. With go
|
||||||
|
// test, we can just look at the runtime call stack. However, bazel compiles go
|
||||||
|
// binaries with the -trimpath option so the simple approach fails however we
|
||||||
|
// can consult environment variables to derive the path.
|
||||||
|
//
|
||||||
|
// The approach taken here works for both go test and bazel on the assumption
|
||||||
|
// that if and only if trimpath is passed, we are running under bazel.
|
||||||
|
func pkgPath() (string, error) {
|
||||||
|
_, thisFile, _, ok := runtime.Caller(1)
|
||||||
|
if !ok {
|
||||||
|
return "", fmt.Errorf("failed to get current file")
|
||||||
|
}
|
||||||
|
|
||||||
|
pkgPath := filepath.Dir(thisFile)
|
||||||
|
|
||||||
|
// If we find bazel env variables, then -trimpath was passed so we need to
|
||||||
|
// construct the path from the environment.
|
||||||
|
if testSrcdir, testWorkspace := os.Getenv("TEST_SRCDIR"), os.Getenv("TEST_WORKSPACE"); testSrcdir != "" && testWorkspace != "" {
|
||||||
|
pkgPath = filepath.Join(testSrcdir, testWorkspace, pkgPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the path is still not absolute, something other than bazel compiled
|
||||||
|
// with -trimpath.
|
||||||
|
if !filepath.IsAbs(pkgPath) {
|
||||||
|
return "", fmt.Errorf("can't construct an absolute path from %q", pkgPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pkgPath, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user