mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #53685 from joonas/hack/cleanup-dangling-functions
Automatic merge from submit-queue (batch tested with PRs 53965, 54117, 53685). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Remove dangling shell functions **What this PR does / why we need it**: This is clean up for shell functionality that was left over from when something was first added and subsequently removed, but didn't include cleaning up all of the logic they references. **Special notes for your reviewer**: I traced back the functions to when they were added and had their references removed, so I thought I'd share that for context: * `kube::golang::current_platform` was added in5d33ce46cc
, but never ended up being used. My understanding is that this is due to having more or less the same logic available in `kube::golang::host_platform`, which is what's being used. * `kube::util::gen-analytics` was added in553f9f822b
and had the use of it removed in902ffd53bc
when docs * `kube::util::analytics-link` was added in553f9f822b
and had the use of it removed inffcc6cadb0
* `kube::util::get_random_port` was added in5d08dcf837
and superseded by `kubectl proxy --port=0` in22b43d8f82
* `kube::util::test_host_port_free` was added in5d08dcf837
and superseded by `kubectl proxy --port=0` in22b43d8f82
I should also note that [`kube::golang::unset_platform_envs()`](e8e72a4444/hack/lib/golang.sh (L301-L307)
) was introduced in5d33ce46cc
and is currently unused, but was referenced in9848d6cc8d
and subsequently removed in38690ff7a7
. If that's something worth including here, I'd be happy to add that also. **Release note**: ```release-note NONE ```
This commit is contained in:
commit
be8f1cea80
@ -249,20 +249,6 @@ kube::golang::host_platform() {
|
||||
echo "$(go env GOHOSTOS)/$(go env GOHOSTARCH)"
|
||||
}
|
||||
|
||||
kube::golang::current_platform() {
|
||||
local os="${GOOS-}"
|
||||
if [[ -z $os ]]; then
|
||||
os=$(go env GOHOSTOS)
|
||||
fi
|
||||
|
||||
local arch="${GOARCH-}"
|
||||
if [[ -z $arch ]]; then
|
||||
arch=$(go env GOHOSTARCH)
|
||||
fi
|
||||
|
||||
echo "$os/$arch"
|
||||
}
|
||||
|
||||
# Takes the platform name ($1) and sets the appropriate golang env variables
|
||||
# for that platform.
|
||||
kube::golang::set_platform_envs() {
|
||||
|
@ -42,32 +42,6 @@ kube::util::wait_for_url() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# returns a random port
|
||||
kube::util::get_random_port() {
|
||||
awk -v min=1024 -v max=65535 'BEGIN{srand(); print int(min+rand()*(max-min+1))}'
|
||||
}
|
||||
|
||||
# use netcat to check if the host($1):port($2) is free (return 0 means free, 1 means used)
|
||||
kube::util::test_host_port_free() {
|
||||
local host=$1
|
||||
local port=$2
|
||||
local success=0
|
||||
local fail=1
|
||||
|
||||
which nc >/dev/null || {
|
||||
kube::log::usage "netcat isn't installed, can't verify if ${host}:${port} is free, skipping the check..."
|
||||
return ${success}
|
||||
}
|
||||
|
||||
if [ ! $(nc -vz "${host}" "${port}") ]; then
|
||||
kube::log::status "${host}:${port} is free, proceeding..."
|
||||
return ${success}
|
||||
else
|
||||
kube::log::status "${host}:${port} is already used"
|
||||
return ${fail}
|
||||
fi
|
||||
}
|
||||
|
||||
# Example: kube::util::trap_add 'echo "in trap DEBUG"' DEBUG
|
||||
# See: http://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
|
||||
kube::util::trap_add() {
|
||||
@ -264,50 +238,6 @@ kube::util::remove-gen-docs() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Takes a path $1 to traverse for md files to append the ga-beacon tracking
|
||||
# link to, if needed. If $2 is set, just print files that are missing
|
||||
# the link.
|
||||
kube::util::gen-analytics() {
|
||||
local path="$1"
|
||||
local dryrun="${2:-}"
|
||||
local mdfiles dir link
|
||||
# find has some strange inconsistencies between darwin/linux. The
|
||||
# path to search must end in '/' for linux, but darwin will put an extra
|
||||
# slash in results if there is a trailing '/'.
|
||||
if [[ $( uname ) == 'Linux' ]]; then
|
||||
dir="${path}/"
|
||||
else
|
||||
dir="${path}"
|
||||
fi
|
||||
# We don't touch files in special dirs, and the kubectl docs are
|
||||
# autogenerated by gendocs.
|
||||
# Don't descend into .directories
|
||||
mdfiles=($( find "${dir}" -name "*.md" -type f \
|
||||
-not -path '*/\.*' \
|
||||
-not -path "${path}/vendor/*" \
|
||||
-not -path "${path}/staging/*" \
|
||||
-not -path "${path}/third_party/*" \
|
||||
-not -path "${path}/_gopath/*" \
|
||||
-not -path "${path}/_output/*" \
|
||||
-not -path "${path}/docs/user-guide/kubectl/kubectl*" ))
|
||||
for f in "${mdfiles[@]}"; do
|
||||
link=$(kube::util::analytics-link "${f#${path}/}")
|
||||
if grep -q -F -x "${link}" "${f}"; then
|
||||
continue
|
||||
elif [[ -z "${dryrun}" ]]; then
|
||||
echo -e "\n\n${link}" >> "${f}"
|
||||
else
|
||||
echo "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Prints analytics link to append to a file at path $1.
|
||||
kube::util::analytics-link() {
|
||||
local path="$1"
|
||||
echo "[]()"
|
||||
}
|
||||
|
||||
# Takes a group/version and returns the path to its location on disk, sans
|
||||
# "pkg". E.g.:
|
||||
# * default behavior: extensions/v1beta1 -> apis/extensions/v1beta1
|
||||
|
Loading…
Reference in New Issue
Block a user