mirror of https://github.com/easzlab/kubeasz.git
style: trim trailing whitespace & add logger source line number
parent
b2b66f922e
commit
8d17c08eda
38
ezctl
38
ezctl
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Create & manage k8s clusters
|
||||
# shellcheck disable=SC2155
|
||||
|
||||
set -o nounset
|
||||
set -o errexit
|
||||
|
@ -39,23 +40,24 @@ EOF
|
|||
}
|
||||
|
||||
function logger() {
|
||||
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
||||
case "$1" in
|
||||
debug)
|
||||
echo -e "$TIMESTAMP \033[36mDEBUG\033[0m $2"
|
||||
;;
|
||||
info)
|
||||
echo -e "$TIMESTAMP \033[32mINFO\033[0m $2"
|
||||
;;
|
||||
warn)
|
||||
echo -e "$TIMESTAMP \033[33mWARN\033[0m $2"
|
||||
;;
|
||||
error)
|
||||
echo -e "$TIMESTAMP \033[31mERROR\033[0m $2"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
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 "\033[36m$TIMESTAMP\033[0m $SOURCE \033[36mDEBUG $2\033[0m"
|
||||
;;
|
||||
info)
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[32mINFO $2\033[0m"
|
||||
;;
|
||||
warn)
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[33mWARN $2\033[0m"
|
||||
;;
|
||||
error)
|
||||
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[31mERROR $2\033[0m"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function help-info() {
|
||||
|
@ -169,7 +171,7 @@ function new() {
|
|||
grep registry-mirrors /etc/docker/daemon.json > /dev/null 2>&1 || { logger debug "disable registry mirrors"; registryMirror=false; }
|
||||
|
||||
sed -i -e "s/__k8s_ver__/$k8sVer/g" \
|
||||
-e "s/__flannel__/$flannelVer/g" \
|
||||
-e "s/__flannel__/$flannelVer/g" \
|
||||
-e "s/__calico__/$calicoVer/g" \
|
||||
-e "s/__cilium__/$ciliumVer/g" \
|
||||
-e "s/__kube_ovn__/$kubeOvnVer/g" \
|
||||
|
|
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