Skip to content

Commit

Permalink
Merge pull request #190 from xenit-eu/XM2C-105-h2
Browse files Browse the repository at this point in the history
XM2C-105 remove terminal formatting in echo
  • Loading branch information
hechmi-dammak-xenit authored Oct 16, 2023
2 parents 6d48eb2 + 6beb035 commit 40f2ebf
Showing 1 changed file with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/bash

currentDate=$(date +%s)
if [ -z "${BUILD_DATE}" ]
then
1>&2 echo "$(tput -Txterm setaf 3)"'{ "timestamp" : '"$(date -d @$currentDate +"%s")"' ,"severity" : "WARN", "type" : "application","component" : "docker-entrypoint" ,"fullMessage" : "Unable to determine image age: BUILD_DATE is not set"}'"$(tput -Txterm sgr0)"
if [ -z "${BUILD_DATE}" ]; then
echo '{ "timestamp" : '"$(date -d @$currentDate +"%s")"' ,"severity" : "WARN", "type" : "application","component" : "docker-entrypoint" ,"fullMessage" : "Unable to determine image age: BUILD_DATE is not set"}'
else
printf -v buildDate "%.0f\n" "$BUILD_DATE"
timeelapsed=`expr ${currentDate} - ${buildDate}`
if [ $timeelapsed -ge 2592000 ] # 30 days
then
1>&2 echo "$(tput -Txterm setaf 3)"'{ "timestamp" : '"$(date -d @$currentDate +"%s")"' ,"severity" : "WARN", "type" : "application","component" : "docker-entrypoint" , "fullMessage" : "This is an old image: BUILD_DATE='"$(date -d @$BUILD_DATE +"%Y-%m-%d %H:%M:%S")"' and currentDate='"$(date -d @$currentDate +"%Y-%m-%d %H:%M:%S")"'"}'"$(tput -Txterm sgr0)"
fi
printf -v buildDate "%.0f\n" "$BUILD_DATE"
timeelapsed=$(expr ${currentDate} - ${buildDate})
if [ $timeelapsed -ge 2592000 ]; then # 30 days
echo '{ "timestamp" : '"$(date -d @$currentDate +"%s")"' ,"severity" : "WARN", "type" : "application","component" : "docker-entrypoint" , "fullMessage" : "This is an old image: BUILD_DATE='"$(date -d @$BUILD_DATE +"%Y-%m-%d %H:%M:%S")"' and currentDate='"$(date -d @$currentDate +"%Y-%m-%d %H:%M:%S")"'"}'
fi
fi

0 comments on commit 40f2ebf

Please sign in to comment.