Commit be8f1cea authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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 in 5d33ce46, 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 in 553f9f82 and had the use of it removed in 902ffd53 when docs * `kube::util::analytics-link` was added in 553f9f82 and had the use of it removed in ffcc6cad * `kube::util::get_random_port` was added in 5d08dcf8 and superseded by `kubectl proxy --port=0` in 22b43d8f * `kube::util::test_host_port_free` was added in 5d08dcf8 and superseded by `kubectl proxy --port=0` in 22b43d8f I should also note that [`kube::golang::unset_platform_envs()`](https://github.com/kubernetes/kubernetes/blob/e8e72a44444d9ded58bcba13d650c98dab2cb465/hack/lib/golang.sh#L301-L307) was introduced in 5d33ce46 and is currently unused, but was referenced in 9848d6cc and subsequently removed in 38690ff7. If that's something worth including here, I'd be happy to add that also. **Release note**: ```release-note NONE ```
parents 4c413ae9 0c9725d5
......@@ -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 "[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/${path}?pixel)]()"
}
# Takes a group/version and returns the path to its location on disk, sans
# "pkg". E.g.:
# * default behavior: extensions/v1beta1 -> apis/extensions/v1beta1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment