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
|
#!/bin/bash
|
||||||
# Create & manage k8s clusters
|
# Create & manage k8s clusters
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o errexit
|
set -o errexit
|
||||||
|
@ -39,23 +40,24 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
function logger() {
|
function logger() {
|
||||||
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
||||||
case "$1" in
|
local FNAME=$(basename "${BASH_SOURCE[1]}")
|
||||||
debug)
|
local SOURCE="\033[36m[$FNAME:${BASH_LINENO[0]}]\033[0m"
|
||||||
echo -e "$TIMESTAMP \033[36mDEBUG\033[0m $2"
|
case "$1" in
|
||||||
;;
|
debug)
|
||||||
info)
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[36mDEBUG $2\033[0m"
|
||||||
echo -e "$TIMESTAMP \033[32mINFO\033[0m $2"
|
;;
|
||||||
;;
|
info)
|
||||||
warn)
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[32mINFO $2\033[0m"
|
||||||
echo -e "$TIMESTAMP \033[33mWARN\033[0m $2"
|
;;
|
||||||
;;
|
warn)
|
||||||
error)
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[33mWARN $2\033[0m"
|
||||||
echo -e "$TIMESTAMP \033[31mERROR\033[0m $2"
|
;;
|
||||||
;;
|
error)
|
||||||
*)
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[31mERROR $2\033[0m"
|
||||||
;;
|
;;
|
||||||
esac
|
*) ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function help-info() {
|
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; }
|
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" \
|
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/__calico__/$calicoVer/g" \
|
||||||
-e "s/__cilium__/$ciliumVer/g" \
|
-e "s/__cilium__/$ciliumVer/g" \
|
||||||
-e "s/__kube_ovn__/$kubeOvnVer/g" \
|
-e "s/__kube_ovn__/$kubeOvnVer/g" \
|
||||||
|
|
18
ezdown
18
ezdown
|
@ -7,6 +7,7 @@
|
||||||
# @usage: ./ezdown
|
# @usage: ./ezdown
|
||||||
# @repo: https://github.com/easzlab/kubeasz
|
# @repo: https://github.com/easzlab/kubeasz
|
||||||
#--------------------------------------------------
|
#--------------------------------------------------
|
||||||
|
# shellcheck disable=SC2155
|
||||||
set -o nounset
|
set -o nounset
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
@ -119,21 +120,22 @@ EOF
|
||||||
|
|
||||||
function logger() {
|
function logger() {
|
||||||
TIMESTAMP=$(date +'%Y-%m-%d %H:%M:%S')
|
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
|
case "$1" in
|
||||||
debug)
|
debug)
|
||||||
echo -e "$TIMESTAMP \033[36mDEBUG\033[0m $2"
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[36mDEBUG $2\033[0m"
|
||||||
;;
|
;;
|
||||||
info)
|
info)
|
||||||
echo -e "$TIMESTAMP \033[32mINFO\033[0m $2"
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[32mINFO $2\033[0m"
|
||||||
;;
|
;;
|
||||||
warn)
|
warn)
|
||||||
echo -e "$TIMESTAMP \033[33mWARN\033[0m $2"
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[33mWARN $2\033[0m"
|
||||||
;;
|
;;
|
||||||
error)
|
error)
|
||||||
echo -e "$TIMESTAMP \033[31mERROR\033[0m $2"
|
echo -e "\033[36m$TIMESTAMP\033[0m $SOURCE \033[31mERROR $2\033[0m"
|
||||||
;;
|
|
||||||
*)
|
|
||||||
;;
|
;;
|
||||||
|
*) ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,9 +705,9 @@ function main() {
|
||||||
imageDir="$BASE/down"
|
imageDir="$BASE/down"
|
||||||
|
|
||||||
# check if use bash shell
|
# 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
|
# 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
|
# get architecture
|
||||||
ARCH=$(uname -m)
|
ARCH=$(uname -m)
|
||||||
|
|
Loading…
Reference in New Issue