Skip to content

Commit

Permalink
fix pl.path can't resolve the path started with ~
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Nov 26, 2023
1 parent 64a20c2 commit 49f0d46
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/resty/aws/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ do
-- returns an empty table if the section does not exist
local function load_file(filename, section)
assert(type(filename) == "string", "expected filename to be a string")
if not pl_path.isfile(filename) then
if not pl_path.isfile(pl_path.expanduser(filename)) then
return nil, "not a file: '"..filename.."'"
end

Expand Down Expand Up @@ -228,7 +228,7 @@ end
-- table if the config file does not exist.
-- @return options table as gotten from the configuration file, or nil+err.
function config.load_config()
if not pl_path.isfile(env_vars.AWS_CONFIG_FILE.value) then
if not pl_path.isfile(pl_path.expanduser(env_vars.AWS_CONFIG_FILE.value)) then
-- file doesn't exist
return {}
end
Expand All @@ -243,7 +243,7 @@ end
-- @return credentials table as gotten from the credentials file, or a table
-- with the key, id, and token from the configuration file, table can be empty.
function config.load_credentials()
if pl_path.isfile(env_vars.AWS_SHARED_CREDENTIALS_FILE.value) then
if pl_path.isfile(pl_path.expanduser(env_vars.AWS_SHARED_CREDENTIALS_FILE.value)) then
local creds = config.load_credentials_file(env_vars.AWS_SHARED_CREDENTIALS_FILE.value, env_vars.AWS_PROFILE.value)
if creds then -- ignore error, already logged
return creds
Expand Down Expand Up @@ -279,7 +279,7 @@ end
function config.get_config()
local cfg = config.load_config() or {} -- ignore error, already logged

if pl_path.isfile(env_vars.AWS_SHARED_CREDENTIALS_FILE.value) then
if pl_path.isfile(pl_path.expanduser(env_vars.AWS_SHARED_CREDENTIALS_FILE.value)) then
-- there is a creds file, so override creds with creds file
local creds = config.load_credentials_file(
env_vars.AWS_SHARED_CREDENTIALS_FILE.value, env_vars.AWS_PROFILE.value) -- ignore error, already logged
Expand Down

0 comments on commit 49f0d46

Please sign in to comment.