Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Federation] Remove unnecessary functions from develop.sh as part of … #38902

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 6 additions & 39 deletions federation/develop/develop.sh
Expand Up @@ -74,15 +74,6 @@ function dirty_sha() {
GIT_ALTERNATE_OBJECT_DIRECTORIES="${objects_dir}" GIT_OBJECT_DIRECTORY="${tmp_objects_dir}" GIT_INDEX_FILE="${tmp_index}" git write-tree
}

function update_config() {
local -r q="${1:-}"
local -r cfile="${2:-}"
local -r bname="$(basename ${cfile})"

jq "${q}" "${cfile}" > "${TMP_DIR}/${bname}"
mv "${TMP_DIR}/${bname}" "${cfile}"
}

function build_binaries() {
cd "${KUBE_ROOT}"
kube::build::verify_prereqs
Expand All @@ -107,8 +98,9 @@ function build_image() {
# Write the generated version to the output versions file so that we can
# reuse it.
mkdir -p "${FEDERATION_OUTPUT_ROOT}"
jq -n --arg ver "${kube_version}" \
'{"KUBE_VERSION": $ver}' > "${VERSIONS_FILE}"
echo "{
\"KUBE_VERSION\": \"${kube_version}\"
}" > "${VERSIONS_FILE}"
kube::log::status "Wrote to version file ${VERSIONS_FILE}: ${kube_version}"

BASEIMAGE="ubuntu:16.04" \
Expand All @@ -123,7 +115,9 @@ function get_version() {
kube_version="${KUBE_VERSION}"
else
# Read the version back from the versions file if no version is given.
kube_version="$(jq -r '.KUBE_VERSION' ${VERSIONS_FILE})"
kube_version="$(cat ${VERSIONS_FILE} | python -c '\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if this is the best way to do this.
Feel free to cc someone else who would know more about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @ixdy.

This was a page taken straight out of @ixdy's book - kubernetes/release#207

import json, sys;\
print json.load(sys.stdin)["KUBE_VERSION"]')"
fi
echo "${kube_version}"
}
Expand All @@ -133,33 +127,6 @@ function push() {

kube::log::status "Pushing hyperkube image to the registry"
gcloud docker -- push "${KUBE_REGISTRY}/hyperkube-amd64:${kube_version}"

# Update config after build and push, but before turning up the clusters
# to ensure the config has the right image version tags.
gen_or_update_config "${kube_version}"
}

function gen_or_update_config() {
local -r kube_version="${1:-}"

mkdir -p "${FEDERATION_OUTPUT_ROOT}"
cp "${DEPLOY_ROOT}/config.json.sample" "${FEDERATION_OUTPUT_ROOT}/config.json"

update_config \
'[.[] | .phase1.gce.project |= "'"${KUBE_PROJECT}"'"]' \
"${FEDERATION_OUTPUT_ROOT}/config.json"

# Not chaining for readability
update_config \
'[.[] | .phase2 = { docker_registry: "'"${KUBE_REGISTRY}"'", kubernetes_version: "'"${kube_version}"'" } ]' \
"${FEDERATION_OUTPUT_ROOT}/config.json"

cat <<EOF> "${FEDERATION_OUTPUT_ROOT}/values.yaml"
apiserverRegistry: "${KUBE_REGISTRY}"
apiserverVersion: "${kube_version}"
controllerManagerRegistry: "${KUBE_REGISTRY}"
controllerManagerVersion: "${kube_version}"
EOF
}

readonly ACTION="${1:-}"
Expand Down