Dealing with environmental variables not defined in our environment
A common problem we have been running into with importing customer channels is they often use environmental variables which we do not have set up on our Iguana instances.
To deal with this one little tool we have in the importer in the shim library is to override os.getenv with a little wrapper which give default values for undefined environmental variables and it stored them all in a global table which you view.
The shim populates an environmental variable _EnvVarList. This means you can inspect it with a trace statement so that you can see all the env variables which a component is using:
This is the source code:
_EnvVarList = {}
-- WHY DO WE DO THIS?
-- In working with customers we frequently ran into problems running scripts without environmental variables defined
-- So this shim sets them to something obviously wrong and builds up a catalogue of variables in _EnvVarList
_GetEnv = os.getenv
os.getenv = function(K)
local X = _GetEnv(K)
if (X == nil) then
X = "ENVIRONMENTAL VARIABLE "..K.." is not defined - this is in iguana_shim.lua!"
end
_EnvVarList[K] = X
return X
end
Â