From bbe6158ef3261e566a6f7e360089ed577f32ff0a Mon Sep 17 00:00:00 2001 From: Jeff Grafton Date: Mon, 5 Jun 2017 16:37:19 -0700 Subject: [PATCH] Convert go_binary linkstamp to x_defs Kubernetes-commit: 64bd79fad78d39788bd1073b836cd5fe89cc29e3 --- pkg/version/def.bzl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pkg/version/def.bzl diff --git a/pkg/version/def.bzl b/pkg/version/def.bzl new file mode 100644 index 00000000..bca85ab4 --- /dev/null +++ b/pkg/version/def.bzl @@ -0,0 +1,24 @@ +# 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