mirror of https://github.com/easzlab/kubeasz.git
style: trim trailing whitespace & add logger source line number
parent
b2b66f922e
commit
8d17c08eda
14
ezctl
14
ezctl
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Create & manage k8s clusters
|
||||
# shellcheck disable=SC2155
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
@ -40,21 +41,22 @@ EOF
|
|||
|
||||
function logger() {
|
||||
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
local FNAME=$(basename "${BASH_SOURCE[1]}")
|
||||
local SOURCE="\033[36m[$FNAME:${BASH_LINENO[0]}]\033[0m"
|
||||
case "$1" in
|
||||
debug)
|
||||
echo -e "$TIMESTAMP \033[36mDEBUG\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[36mDEBUG $2\033[0m"
|
||||
;;
|
||||
info)
|
||||
echo -e "$TIMESTAMP \033[32mINFO\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[32mINFO $2\033[0m"
|
||||
;;
|
||||
warn)
|
||||
echo -e "$TIMESTAMP \033[33mWARN\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[33mWARN $2\033[0m"
|
||||
;;
|
||||
error)
|
||||
echo -e "$TIMESTAMP \033[31mERROR\033[0m $2"
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[31mERROR $2\033[0m"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
18
ezdown
18
ezdown
|
@ -7,6 +7,7 @@
|
|||
# @usage: ./ezdown
|
||||
# @repo: https://github.com/easzlab/kubeasz
|
||||
#--------------------------------------------------
|
||||
# shellcheck disable=SC2155
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
set -o pipefail
|
||||
|
@ -119,21 +120,22 @@ EOF
|
|||
|
||||
function logger() {
|
||||
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
local FNAME=$(basename "${BASH_SOURCE[1]}")
|
||||
local SOURCE="\033[36m[$FNAME:${BASH_LINENO[0]}]\033[0m"
|
||||
case "$1" in
|
||||
debug)
|
||||
echo -e "$TIMESTAMP \033[36mDEBUG\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[36mDEBUG $2\033[0m"
|
||||
;;
|
||||
info)
|
||||
echo -e "$TIMESTAMP \033[32mINFO\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[32mINFO $2\033[0m"
|
||||
;;
|
||||
warn)
|
||||
echo -e "$TIMESTAMP \033[33mWARN\033[0m $2"
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[33mWARN $2\033[0m"
|
||||
;;
|
||||
error)
|
||||
echo -e "$TIMESTAMP \033[31mERROR\033[0m $2"
|
||||
;;
|
||||
*)
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[31mERROR $2\033[0m"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
@ -703,9 +705,9 @@ function main() {
|
|||
imageDir="$BASE/down"
|
||||
|
||||
# check if use bash shell
|
||||
readlink /proc/$$/exe|grep -q "bash" || { logger error "you should use bash shell, not sh"; exit 1; }
|
||||
# readlink /proc/$$/exe|grep -q "bash" || { logger error "you should use bash shell, not sh"; exit 1; }
|
||||
# check if use with root
|
||||
[[ "$EUID" -ne 0 ]] && { logger error "you should run this script as root"; exit 1; }
|
||||
# [[ "$EUID" -ne 0 ]] && { logger error "you should run this script as root"; exit 1; }
|
||||
|
||||
# get architecture
|
||||
ARCH=$(uname -m)
|
||||
|
|
Loading…
Reference in New Issue