Skip to content

Commit b7a1d61

Browse files
authored
Merge pull request kubernetes#87658 from dims/enable-selinux-tags-in-make-targets
Enable selinux tags in make targets
2 parents f812429 + dfd8e4e commit b7a1d61

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

hack/lib/golang.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ kube::golang::build_binaries_for_platform() {
700700
-gcflags "${gogcflags:-}"
701701
-asmflags "${goasmflags:-}"
702702
-ldflags "${goldflags:-}"
703+
-tags "${gotags:-}"
703704
)
704705
CGO_ENABLED=0 kube::golang::build_some_binaries "${statics[@]}"
705706
fi
@@ -710,6 +711,7 @@ kube::golang::build_binaries_for_platform() {
710711
-gcflags "${gogcflags:-}"
711712
-asmflags "${goasmflags:-}"
712713
-ldflags "${goldflags:-}"
714+
-tags "${gotags:-}"
713715
)
714716
kube::golang::build_some_binaries "${nonstatics[@]}"
715717
fi
@@ -725,6 +727,7 @@ kube::golang::build_binaries_for_platform() {
725727
-gcflags "${gogcflags:-}" \
726728
-asmflags "${goasmflags:-}" \
727729
-ldflags "${goldflags:-}" \
730+
-tags "${gotags:-}" \
728731
-o "${outfile}" \
729732
"${testpkg}"
730733
done
@@ -776,7 +779,7 @@ kube::golang::build_binaries() {
776779
local host_platform
777780
host_platform=$(kube::golang::host_platform)
778781

779-
local goflags goldflags goasmflags gogcflags
782+
local goflags goldflags goasmflags gogcflags gotags
780783
# If GOLDFLAGS is unset, then set it to the a default of "-s -w".
781784
# Disable SC2153 for this, as it will throw a warning that the local
782785
# variable goldflags will exist, and it suggest changing it to this.
@@ -785,6 +788,10 @@ kube::golang::build_binaries() {
785788
goasmflags="-trimpath=${KUBE_ROOT}"
786789
gogcflags="${GOGCFLAGS:-} -trimpath=${KUBE_ROOT}"
787790

791+
# extract tags if any specified in GOFLAGS
792+
# shellcheck disable=SC2001
793+
gotags="selinux,$(echo "${GOFLAGS:-}" | sed -e 's|.*-tags=\([^-]*\).*|\1|')"
794+
788795
local -a targets=()
789796
local arg
790797

test/typecheck/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ func newAnalyzer(platform string) *analyzer {
105105
ctx.BuildTags = append(ctx.BuildTags, tagsSplit...)
106106
}
107107

108+
// add selinux tag explicitly
109+
ctx.BuildTags = append(ctx.BuildTags, "selinux")
110+
108111
a := &analyzer{
109112
platform: platform,
110113
fset: token.NewFileSet(),

0 commit comments

Comments
 (0)