Skip to content

Commit

Permalink
Try resolving key paths from cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
Temikus committed Oct 29, 2017
1 parent 8542431 commit 0b2dcbf
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/vagrant-google/action/connect_google.rb
Expand Up @@ -36,9 +36,9 @@ def call(env)
:google_client_email => provider_config.google_client_email
}
if provider_config.google_json_key_location.nil?
fog_config[:google_key_location] = provider_config.google_key_location
fog_config[:google_key_location] = find_key(provider_config.google_key_location, env)
else
fog_config[:google_json_key_location] = provider_config.google_json_key_location
fog_config[:google_json_key_location] = find_key(provider_config.google_json_key_location, env)
end

@logger.info("Connecting to Google...")
Expand All @@ -47,6 +47,15 @@ def call(env)
@app.call(env)
@logger.info("...Connected!")
end

# If the key is not found, try expanding from root location (see #159)
def find_key(location, env)
if File.file?(location)
return location
else
return File.expand_path(location, env[:root_path])
end
end
end
end
end
Expand Down

0 comments on commit 0b2dcbf

Please sign in to comment.