aw-was-here commented on code in PR #254:
URL: https://github.com/apache/yetus/pull/254#discussion_r855377244
##########
precommit/src/main/shell/core.d/00-yetuslib.sh:
##########
@@ -528,3 +528,65 @@ function yetus_set_trap_handler
trap "${func} ${signal}" "${signal}"
done
}
+
+## @description Determine if running in a container
+## @audience public
+## @stability evolving
+## @replaceable no
+function yetus_is_container
+{
+ declare mounts
+ declare cgroups
+
+ if [[ -n "${YETUS_CONTAINER_STATE}" ]]; then
+ if [[ "${YETUS_CONTAINER_STATE}" == "true" ]]; then
+ return 0
+ fi
+ return 1
+ fi
+
+ if [[ -f /.dockerenv ]]; then
+ YETUS_CONTAINER_STATE=true
+ return 0
+ fi
+
+ if [[ -n "${container}" ]]; then
+ YETUS_CONTAINER_STATE=true
+ return 0
+ fi
+
+ if [[ -d /proc/self/mountinfo ]]; then
Review Comment:
Looking at this again, I realize why I didn't use a for loop: awk is
involved so the quoting gets a bit involved when any of this is in an
environment variable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]