aw-was-here commented on code in PR #254:
URL: https://github.com/apache/yetus/pull/254#discussion_r855356581


##########
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:
   From the bit of playing I've done, not really.  But I should really optimize 
the code to use a for loop now that I think about it.



-- 
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]

Reply via email to