Commit 64bd79fa authored by Jeff Grafton's avatar Jeff Grafton

Convert go_binary linkstamp to x_defs

parent 14e18893
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "cloud-controller-manager",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -8,12 +8,13 @@ load(
"go_library",
"go_test",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "hyperkube",
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_test(
......
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kube-apiserver",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kube-controller-manager",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kube-proxy",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kubeadm",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -5,6 +5,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kubectl",
......@@ -15,11 +16,11 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
visibility = [
"//build/visible_to:COMMON_release",
],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -7,12 +7,13 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kubelet",
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
......@@ -118,12 +118,15 @@ kube::version::ldflag() {
local key=${1}
local val=${2}
# If you update these, also update the list pkg/version/def.bzl.
echo "-X ${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}"
echo "-X ${KUBE_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.${key}=${val}"
}
# Prints the value that needs to be passed to the -ldflags parameter of go build
# in order to set the Kubernetes based on the git tree status.
# IMPORTANT: if you update any of these, also update the lists in
# pkg/version/def.bzl and hack/print-workspace-status.sh.
kube::version::ldflags() {
kube::version::get_version_vars
......
......@@ -29,6 +29,8 @@ kube::version::get_version_vars
# instead of volatile-status.txt.
# Stamped rules will be retriggered by changes to stable-status.txt, but not by
# changes to volatile-status.txt.
# IMPORTANT: the camelCase vars should match the lists in hack/lib/version.sh
# and pkg/version/def.bzl.
cat <<EOF
STABLE_BUILD_GIT_COMMIT ${KUBE_GIT_COMMIT-}
STABLE_BUILD_SCM_STATUS ${KUBE_GIT_TREE_STATE-}
......
# Implements hack/lib/version.sh's kube::version::ldflags() for Bazel.
def version_x_defs():
# This should match the list of packages in kube::version::ldflag
stamp_pkgs = [
"k8s.io/kubernetes/pkg/version",
# In hack/lib/version.sh, this has a vendor/ prefix. That isn't needed here?
"k8s.io/client-go/pkg/version",
]
# This should match the list of vars in kube::version::ldflags
# It should also match the list of vars set in hack/print-workspace-status.sh.
stamp_vars = [
"buildDate",
"gitCommit",
"gitMajor",
"gitMinor",
"gitTreeState",
"gitVersion",
]
# Generate the cross-product.
x_defs = {}
for pkg in stamp_pkgs:
for var in stamp_vars:
x_defs["%s.%s" % (pkg, var)] = "{%s}" % var
return x_defs
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kube-scheduler",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
# Implements hack/lib/version.sh's kube::version::ldflags() for Bazel.
def version_x_defs():
# This should match the list of packages in kube::version::ldflag
stamp_pkgs = [
"k8s.io/kubernetes/pkg/version",
# In hack/lib/version.sh, this has a vendor/ prefix. That isn't needed here?
"k8s.io/client-go/pkg/version",
]
# This should match the list of vars in kube::version::ldflags
# It should also match the list of vars set in hack/print-workspace-status.sh.
stamp_vars = [
"buildDate",
"gitCommit",
"gitMajor",
"gitMinor",
"gitTreeState",
"gitVersion",
]
# Generate the cross-product.
x_defs = {}
for pkg in stamp_pkgs:
for var in stamp_vars:
x_defs["%s.%s" % (pkg, var)] = "{%s}" % var
return x_defs
......@@ -7,6 +7,7 @@ load(
"go_binary",
"go_library",
)
load("//vendor/k8s.io/client-go/pkg/version:def.bzl", "version_x_defs")
go_binary(
name = "kube-aggregator",
......@@ -17,8 +18,8 @@ go_binary(
"-static",
],
library = ":go_default_library",
linkstamp = "k8s.io/kubernetes/pkg/version",
tags = ["automanaged"],
x_defs = version_x_defs(),
)
go_library(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment