Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
74a70262
Unverified
Commit
74a70262
authored
Apr 29, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Apr 29, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76974 from mtaufen/fix-golang-sh
Restrict builds to officially supported platforms
parents
16193d83
dcee810a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
142 additions
and
67 deletions
+142
-67
golang.sh
hack/lib/golang.sh
+142
-67
No files found.
hack/lib/golang.sh
View file @
74a70262
...
@@ -18,6 +18,52 @@
...
@@ -18,6 +18,52 @@
readonly
KUBE_GO_PACKAGE
=
k8s.io/kubernetes
readonly
KUBE_GO_PACKAGE
=
k8s.io/kubernetes
readonly
KUBE_GOPATH
=
"
${
KUBE_OUTPUT
}
/go"
readonly
KUBE_GOPATH
=
"
${
KUBE_OUTPUT
}
/go"
# The server platform we are building on.
readonly
KUBE_SUPPORTED_SERVER_PLATFORMS
=(
linux/amd64
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
)
# The node platforms we build for
readonly
KUBE_SUPPORTED_NODE_PLATFORMS
=(
linux/amd64
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
windows/amd64
)
# If we update this we should also update the set of platforms whose standard
# library is precompiled for in build/build-image/cross/Dockerfile
readonly
KUBE_SUPPORTED_CLIENT_PLATFORMS
=(
linux/amd64
linux/386
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
darwin/amd64
darwin/386
windows/amd64
windows/386
)
# Which platforms we should compile test targets for.
# Not all client platforms need these tests
readonly
KUBE_SUPPORTED_TEST_PLATFORMS
=(
linux/amd64
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
darwin/amd64
windows/amd64
)
# The set of server targets that we are only building for Linux
# The set of server targets that we are only building for Linux
# If you update this list, please also update build/BUILD.
# If you update this list, please also update build/BUILD.
kube::golang::server_targets
()
{
kube::golang::server_targets
()
{
...
@@ -87,77 +133,106 @@ readonly KUBE_NODE_TARGETS
...
@@ -87,77 +133,106 @@ readonly KUBE_NODE_TARGETS
readonly
KUBE_NODE_BINARIES
=(
"
${
KUBE_NODE_TARGETS
[@]##*/
}
"
)
readonly
KUBE_NODE_BINARIES
=(
"
${
KUBE_NODE_TARGETS
[@]##*/
}
"
)
readonly
KUBE_NODE_BINARIES_WIN
=(
"
${
KUBE_NODE_BINARIES
[@]/%/.exe
}
"
)
readonly
KUBE_NODE_BINARIES_WIN
=(
"
${
KUBE_NODE_BINARIES
[@]/%/.exe
}
"
)
if
[[
-n
"
${
KUBE_BUILD_PLATFORMS
:-}
"
]]
;
then
# ------------
IFS
=
" "
read
-ra
KUBE_SERVER_PLATFORMS
<<<
"
${
KUBE_BUILD_PLATFORMS
}
"
# NOTE: All functions that return lists should use newlines.
IFS
=
" "
read
-ra
KUBE_NODE_PLATFORMS
<<<
"
${
KUBE_BUILD_PLATFORMS
}
"
# bash functions can't return arrays, and spaces are tricky, so newline
IFS
=
" "
read
-ra
KUBE_TEST_PLATFORMS
<<<
"
${
KUBE_BUILD_PLATFORMS
}
"
# separators are the preferred pattern.
IFS
=
" "
read
-ra
KUBE_CLIENT_PLATFORMS
<<<
"
${
KUBE_BUILD_PLATFORMS
}
"
# To transform a string of newline-separated items to an array, use mapfile -t:
readonly
KUBE_SERVER_PLATFORMS
# mapfile -t FOO <<< "$(kube::golang::dups a b c a)"
readonly
KUBE_NODE_PLATFORMS
#
readonly
KUBE_TEST_PLATFORMS
# ALWAYS remember to quote your subshells. Not doing so will break in
readonly
KUBE_CLIENT_PLATFORMS
# bash 4.3, and potentially cause other issues.
elif
[[
"
${
KUBE_FASTBUILD
:-}
"
==
"true"
]]
;
then
# ------------
readonly
KUBE_SERVER_PLATFORMS
=(
linux/amd64
)
readonly
KUBE_NODE_PLATFORMS
=(
linux/amd64
)
# Returns a sorted newline-separated list containing only duplicated items.
if
[[
"
${
KUBE_BUILDER_OS
:-}
"
==
"darwin"
*
]]
;
then
kube::golang::dups
()
{
readonly
KUBE_TEST_PLATFORMS
=(
# We use printf to insert newlines, which are required by sort.
darwin/amd64
printf
"%s
\n
"
"
$@
"
|
sort
|
uniq
-d
linux/amd64
}
)
readonly
KUBE_CLIENT_PLATFORMS
=(
# Returns a sorted newline-separated list with duplicated items removed.
darwin/amd64
kube::golang::dedup
()
{
linux/amd64
# We use printf to insert newlines, which are required by sort.
)
printf
"%s
\n
"
"
$@
"
|
sort
-u
}
# Depends on values of user-facing KUBE_BUILD_PLATFORMS, KUBE_FASTBUILD,
# and KUBE_BUILDER_OS.
# Configures KUBE_SERVER_PLATFORMS, KUBE_NODE_PLATFOMRS,
# KUBE_TEST_PLATFORMS, and KUBE_CLIENT_PLATFORMS, then sets them
# to readonly.
# The configured vars will only contain platforms allowed by the
# KUBE_SUPPORTED* vars at the top of this file.
kube::golang::setup_platforms
()
{
if
[[
-n
"
${
KUBE_BUILD_PLATFORMS
:-}
"
]]
;
then
# KUBE_BUILD_PLATFORMS needs to be read into an array before the next
# step, or quoting treats it all as one element.
local
-a
platforms
IFS
=
" "
read
-ra
platforms
<<<
"
${
KUBE_BUILD_PLATFORMS
}
"
# Deduplicate to ensure the intersection trick with kube::golang::dups
# is not defeated by duplicates in user input.
mapfile
-t
platforms
<<<
"
$(
kube::golang::dedup
"
${
platforms
[@]
}
"
)
"
# Use kube::golang::dups to restrict the builds to the platforms in
# KUBE_SUPPORTED_*_PLATFORMS. Items should only appear at most once in each
# set, so if they appear twice after the merge they are in the intersection.
mapfile
-t
KUBE_SERVER_PLATFORMS
<<<
"
$(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_SERVER_PLATFORMS
[@]
}
"
\
)
"
readonly
KUBE_SERVER_PLATFORMS
mapfile
-t
KUBE_NODE_PLATFORMS
<<<
"
$(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_NODE_PLATFORMS
[@]
}
"
\
)
"
readonly
KUBE_NODE_PLATFORMS
mapfile
-t
KUBE_TEST_PLATFORMS
<<<
"
$(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_TEST_PLATFORMS
[@]
}
"
\
)
"
readonly
KUBE_TEST_PLATFORMS
mapfile
-t
KUBE_CLIENT_PLATFORMS
<<<
"
$(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_CLIENT_PLATFORMS
[@]
}
"
\
)
"
readonly
KUBE_CLIENT_PLATFORMS
elif
[[
"
${
KUBE_FASTBUILD
:-}
"
==
"true"
]]
;
then
readonly
KUBE_SERVER_PLATFORMS
=(
linux/amd64
)
readonly
KUBE_NODE_PLATFORMS
=(
linux/amd64
)
if
[[
"
${
KUBE_BUILDER_OS
:-}
"
==
"darwin"
*
]]
;
then
readonly
KUBE_TEST_PLATFORMS
=(
darwin/amd64
linux/amd64
)
readonly
KUBE_CLIENT_PLATFORMS
=(
darwin/amd64
linux/amd64
)
else
readonly
KUBE_TEST_PLATFORMS
=(
linux/amd64
)
readonly
KUBE_CLIENT_PLATFORMS
=(
linux/amd64
)
fi
else
else
readonly
KUBE_TEST_PLATFORMS
=(
linux/amd64
)
KUBE_SERVER_PLATFORMS
=(
"
${
KUBE_SUPPORTED_SERVER_PLATFORMS
[@]
}
"
)
readonly
KUBE_CLIENT_PLATFORMS
=(
linux/amd64
)
readonly
KUBE_SERVER_PLATFORMS
fi
else
# The server platform we are building on.
readonly
KUBE_SERVER_PLATFORMS
=(
linux/amd64
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
)
# The node platforms we build for
KUBE_NODE_PLATFORMS
=(
"
${
KUBE_SUPPORTED_NODE_PLATFORMS
[@]
}
"
)
readonly
KUBE_NODE_PLATFORMS
=(
readonly
KUBE_NODE_PLATFORMS
linux/amd64
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
windows/amd64
)
# If we update this we should also update the set of platforms whose standard library is precompiled for in build/build-image/cross/Dockerfile
KUBE_CLIENT_PLATFORMS
=(
"
${
KUBE_SUPPORTED_CLIENT_PLATFORMS
[@]
}
"
)
readonly
KUBE_CLIENT_PLATFORMS
=(
readonly
KUBE_CLIENT_PLATFORMS
linux/amd64
linux/386
linux/arm
linux/arm64
linux/s390x
linux/ppc64le
darwin/amd64
darwin/386
windows/amd64
windows/386
)
# Which platforms we should compile test targets for. Not all client platforms need these tests
KUBE_TEST_PLATFORMS
=(
"
${
KUBE_SUPPORTED_TEST_PLATFORMS
[@]
}
"
)
readonly
KUBE_TEST_PLATFORMS
=(
readonly
KUBE_TEST_PLATFORMS
linux/amd64
fi
linux/arm
}
linux/arm64
linux/s390x
kube::golang::setup_platforms
linux/ppc64le
darwin/amd64
windows/amd64
)
fi
# The set of client targets that we are building for all platforms
# The set of client targets that we are building for all platforms
# If you update this list, please also update build/BUILD.
# If you update this list, please also update build/BUILD.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment