update-translations.sh: use kube::util::ensure-temp-dir instead of static path.

Use a temporary directory to hold the generated temporary file. This
helps prevent a class of potential security issues on various platforms.
pull/8/head
Ismo Puustinen 2018-03-12 14:41:06 +02:00
parent abc6fe6dbb
commit 14ccb8cf52
1 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/util.sh"
KUBECTL_FILES="pkg/kubectl/cmd/*.go pkg/kubectl/cmd/*/*.go"
generate_pot="false"
@ -62,8 +65,9 @@ if [[ "${generate_pot}" == "true" ]]; then
perl -pi -e 's/CHARSET/UTF-8/' tmp.pot
perl -pi -e 's/\\\(/\\\\\(/g' tmp.pot
perl -pi -e 's/\\\)/\\\\\)/g' tmp.pot
if msgcat -s tmp.pot > /tmp/template.pot; then
mv /tmp/template.pot translations/kubectl/template.pot
kube::util::ensure-temp-dir
if msgcat -s tmp.pot > "${KUBE_TEMP}/template.pot"; then
mv "${KUBE_TEMP}/template.pot" translations/kubectl/template.pot
rm tmp.pot
else
echo "Failed to update template.pot"