mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Enable selinux tags in make targets
In 24d105995d
, a fix was made in bazel
based builds to ensure that we add `selinux` tag when we build all
binaries especially the `kubelet`. We need to do the same for in our
hack scripts so things like `make release` will work properly as well.
Some scripts use `GOFLAGS=-tags=providerless` for example, So we should
support the tags to be specified in GOFLAGS as well. We parse out the
tags from there and ensure selinux is added to the list of tags we used
for building the binaries. Note that we add our own `-tags` with the
full set of tags and since we specify our parameter at the end, ours
full list takes precendence
This commit is contained in:
parent
b32725b80b
commit
dfd8e4e467
@ -700,6 +700,7 @@ kube::golang::build_binaries_for_platform() {
|
||||
-gcflags "${gogcflags:-}"
|
||||
-asmflags "${goasmflags:-}"
|
||||
-ldflags "${goldflags:-}"
|
||||
-tags "${gotags:-}"
|
||||
)
|
||||
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
|
||||
fi
|
||||
@ -710,6 +711,7 @@ kube::golang::build_binaries_for_platform() {
|
||||
-gcflags "${gogcflags:-}"
|
||||
-asmflags "${goasmflags:-}"
|
||||
-ldflags "${goldflags:-}"
|
||||
-tags "${gotags:-}"
|
||||
)
|
||||
kube::golang::build_some_binaries "${nonstatics[@]}"
|
||||
fi
|
||||
@ -725,6 +727,7 @@ kube::golang::build_binaries_for_platform() {
|
||||
-gcflags "${gogcflags:-}" \
|
||||
-asmflags "${goasmflags:-}" \
|
||||
-ldflags "${goldflags:-}" \
|
||||
-tags "${gotags:-}" \
|
||||
-o "${outfile}" \
|
||||
"${testpkg}"
|
||||
done
|
||||
@ -776,7 +779,7 @@ kube::golang::build_binaries() {
|
||||
local host_platform
|
||||
host_platform=$(kube::golang::host_platform)
|
||||
|
||||
local goflags goldflags goasmflags gogcflags
|
||||
local goflags goldflags goasmflags gogcflags gotags
|
||||
# If GOLDFLAGS is unset, then set it to the a default of "-s -w".
|
||||
# Disable SC2153 for this, as it will throw a warning that the local
|
||||
# variable goldflags will exist, and it suggest changing it to this.
|
||||
@ -785,6 +788,10 @@ kube::golang::build_binaries() {
|
||||
goasmflags="-trimpath=${KUBE_ROOT}"
|
||||
gogcflags="${GOGCFLAGS:-} -trimpath=${KUBE_ROOT}"
|
||||
|
||||
# extract tags if any specified in GOFLAGS
|
||||
# shellcheck disable=SC2001
|
||||
gotags="selinux,$(echo "${GOFLAGS:-}" | sed -e 's|.*-tags=\([^-]*\).*|\1|')"
|
||||
|
||||
local -a targets=()
|
||||
local arg
|
||||
|
||||
|
@ -105,6 +105,9 @@ func newAnalyzer(platform string) *analyzer {
|
||||
ctx.BuildTags = append(ctx.BuildTags, tagsSplit...)
|
||||
}
|
||||
|
||||
// add selinux tag explicitly
|
||||
ctx.BuildTags = append(ctx.BuildTags, "selinux")
|
||||
|
||||
a := &analyzer{
|
||||
platform: platform,
|
||||
fset: token.NewFileSet(),
|
||||
|
Loading…
Reference in New Issue
Block a user