os.getenv doesn't take default value in lua

This commit is contained in:
Karol Wypchlo 2021-07-26 01:54:03 +02:00
parent b31d3bf680
commit 278482ab72
4 changed files with 8 additions and 8 deletions

View File

@ -273,7 +273,7 @@ server {
access_by_lua_block { access_by_lua_block {
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "0" then return end
local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true })
if res.status == ngx.HTTP_OK then if res.status == ngx.HTTP_OK then
@ -310,7 +310,7 @@ server {
# access_by_lua_block { # access_by_lua_block {
# -- this block runs only when accounts are enabled # -- this block runs only when accounts are enabled
# if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end # if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
# ngx.var.upload_limit_rate = 5 * 1024 * 1024 # ngx.var.upload_limit_rate = 5 * 1024 * 1024
# local res = ngx.location.capture("/accounts/user", { copy_all_vars = true }) # local res = ngx.location.capture("/accounts/user", { copy_all_vars = true })
@ -352,7 +352,7 @@ server {
ngx.req.set_header("SkynetMaxUploadSize", 1073741824) ngx.req.set_header("SkynetMaxUploadSize", 1073741824)
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
-- fetch account limits and set max upload size accordingly -- fetch account limits and set max upload size accordingly
local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true })
@ -441,7 +441,7 @@ server {
end end
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true }) local res = ngx.location.capture("/accounts/user/limits", { copy_all_vars = true })
if res.status == ngx.HTTP_OK then if res.status == ngx.HTTP_OK then
@ -527,7 +527,7 @@ server {
content_by_lua_block { content_by_lua_block {
local json = require('cjson') local json = require('cjson')
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then if os.getenv("ACCOUNTS_ENABLED") ~= "1" then
ngx.say(json.encode{authenticated = false}) ngx.say(json.encode{authenticated = false})
return ngx.exit(ngx.HTTP_OK) return ngx.exit(ngx.HTTP_OK)
end end

View File

@ -1,7 +1,7 @@
# register the download in accounts service (cookies should contain jwt) # register the download in accounts service (cookies should contain jwt)
log_by_lua_block { log_by_lua_block {
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
local skylink = ngx.header["Skynet-Skylink"] local skylink = ngx.header["Skynet-Skylink"]
if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then

View File

@ -1,7 +1,7 @@
# register the registry access in accounts service (cookies should contain jwt) # register the registry access in accounts service (cookies should contain jwt)
log_by_lua_block { log_by_lua_block {
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
if ngx.status == ngx.HTTP_OK or ngx.status == ngx.HTTP_NOT_FOUND then if ngx.status == ngx.HTTP_OK or ngx.status == ngx.HTTP_NOT_FOUND then
local http = require("socket.http") local http = require("socket.http")

View File

@ -1,7 +1,7 @@
# register the upload in accounts service (cookies should contain jwt) # register the upload in accounts service (cookies should contain jwt)
log_by_lua_block { log_by_lua_block {
-- this block runs only when accounts are enabled -- this block runs only when accounts are enabled
if os.getenv("ACCOUNTS_ENABLED", "0") == "0" then return end if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
local skylink = ngx.header["Skynet-Skylink"] local skylink = ngx.header["Skynet-Skylink"]
if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then if skylink and ngx.status >= ngx.HTTP_OK and ngx.status < ngx.HTTP_SPECIAL_RESPONSE then