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
1b18987e
Unverified
Commit
1b18987e
authored
May 06, 2019
by
Christoph Blecker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't use mapfile as it isn't bash 3 compatible
parent
28f25269
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
golang.sh
hack/lib/golang.sh
+11
-11
util.sh
hack/lib/util.sh
+17
-0
No files found.
hack/lib/golang.sh
View file @
1b18987e
...
...
@@ -137,8 +137,8 @@ readonly KUBE_NODE_BINARIES_WIN=("${KUBE_NODE_BINARIES[@]/%/.exe}")
# NOTE: All functions that return lists should use newlines.
# bash functions can't return arrays, and spaces are tricky, so newline
# separators are the preferred pattern.
# To transform a string of newline-separated items to an array, use
mapfile -t
:
#
mapfile -t FOO <<< "$(kube::golang::dups a b c a)"
# To transform a string of newline-separated items to an array, use
kube::util::read-array
:
#
kube::util::read-array FOO < <(kube::golang::dups a b c a)
#
# ALWAYS remember to quote your subshells. Not doing so will break in
# bash 4.3, and potentially cause other issues.
...
...
@@ -172,33 +172,33 @@ kube::golang::setup_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
[@]
}
"
)
"
kube::util::read-array 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
\
kube::util::read-array KUBE_SERVER_PLATFORMS < <
(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_SERVER_PLATFORMS
[@]
}
"
\
)
"
)
readonly
KUBE_SERVER_PLATFORMS
mapfile
-t
KUBE_NODE_PLATFORMS
<<<
"
$
(
kube::golang::dups
\
kube::util::read-array KUBE_NODE_PLATFORMS < <
(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_NODE_PLATFORMS
[@]
}
"
\
)
"
)
readonly
KUBE_NODE_PLATFORMS
mapfile
-t
KUBE_TEST_PLATFORMS
<<<
"
$
(
kube::golang::dups
\
kube::util::read-array KUBE_TEST_PLATFORMS < <
(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_TEST_PLATFORMS
[@]
}
"
\
)
"
)
readonly
KUBE_TEST_PLATFORMS
mapfile
-t
KUBE_CLIENT_PLATFORMS
<<<
"
$
(
kube::golang::dups
\
kube::util::read-array KUBE_CLIENT_PLATFORMS < <
(
kube::golang::dups
\
"
${
platforms
[@]
}
"
\
"
${
KUBE_SUPPORTED_CLIENT_PLATFORMS
[@]
}
"
\
)
"
)
readonly
KUBE_CLIENT_PLATFORMS
elif
[[
"
${
KUBE_FASTBUILD
:-}
"
==
"true"
]]
;
then
...
...
hack/lib/util.sh
View file @
1b18987e
...
...
@@ -817,6 +817,23 @@ function kube::util::require-jq {
fi
}
# kube::util::read-array
# Reads in stdin and adds it line by line to the array provided. This can be
# used instead of "mapfile -t", and is bash 3 compatible.
#
# Assumed vars:
# $1 (name of array to create/modify)
#
# Example usage:
# kube::util::read-array files < <(ls -1)
#
function
kube::util::read-array
{
local
i
=
0
unset
-v
"
$1
"
while
IFS
=
read
-r
"
$1
[i++]"
;
do
:
;
done
eval
"[[
\$
{
$1
[--i]} ]]"
||
unset
"
$1
[i]"
# ensures last element isn't empty
}
# Some useful colors.
if
[[
-z
"
${
color_start
-
}
"
]]
;
then
declare
-r
color_start
=
"
\0
33["
...
...
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