Skip to content

Commit

Permalink
Merge pull request #179 from Temikus/fix_key_lookup
Browse files Browse the repository at this point in the history
Fix key lookup
  • Loading branch information
erjohnso authored Oct 31, 2017
2 parents 203a6c2 + 8f5b459 commit c73200b
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 118 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ AllCops:

Style/EmptyLinesAroundBlockBody:
Enabled: false

Style/StringLiterals:
Enabled: false
247 changes: 152 additions & 95 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,65 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-03-25 19:11:49 +0100 using RuboCop version 0.38.0.
# on 2017-10-29 18:43:35 +1100 using RuboCop version 0.51.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/IndentHash:
EnforcedStyle: consistent

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'lib/vagrant-google/action/connect_google.rb'

# Offense count: 1
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'

# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Exclude:
- 'test/unit/common/config_test.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SupportedStylesForEmptyBraces.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'
- 'tasks/acceptance.rake'

# Offense count: 2
Lint/LiteralInCondition:
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideBlockBraces:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'

# Offense count: 2
Lint/LiteralAsCondition:
Exclude:
- 'lib/vagrant-google/action/run_instance.rb'
- 'lib/vagrant-google/action/start_instance.rb'
Expand All @@ -22,9 +74,14 @@ Lint/RescueException:
Exclude:
- 'lib/vagrant-google/action/read_state.rb'

# Offense count: 1
Lint/RescueWithoutErrorClass:
Exclude:
- 'lib/vagrant-google/action/run_instance.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'
Expand All @@ -40,44 +97,79 @@ Lint/UselessAssignment:
Exclude:
- 'lib/vagrant-google/plugin.rb'

# Offense count: 11
# Offense count: 12
Metrics/AbcSize:
Max: 54
Max: 59

# Offense count: 7
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 224

# Offense count: 4
Metrics/CyclomaticComplexity:
Max: 16
Max: 19

# Offense count: 71
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# Offense count: 84
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 131

# Offense count: 15
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 35
Max: 43

# Offense count: 3
Metrics/PerceivedComplexity:
Max: 16
Max: 19

# Offense count: 1
Style/AccessorMethodName:
Naming/AccessorMethodName:
Exclude:
- 'test/unit/common/config_test.rb'

# Offense count: 8
# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'lib/vagrant-google.rb'
- 'vagrant-spec.config.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/HashEachMethods:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'example_boxes/gce-test/Vagrantfile'
- 'lib/vagrant-google/config.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Style/BracesAroundHashParameters:
Exclude:
- 'test/unit/common/config_test.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'lib/vagrant-google/config.rb'

# Offense count: 18
Style/Documentation:
Exclude:
Expand All @@ -96,64 +188,36 @@ Style/Documentation:
- 'lib/vagrant-google/provider.rb'
- 'lib/vagrant-google/util/timer.rb'

# Offense count: 1
# Offense count: 49
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Style/DotPosition:
# SupportedStyles: when_needed, always, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Exclude:


# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundClassBody:
Exclude:
- 'lib/vagrant-google/action/stop_instance.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundModuleBody:
Exclude:
- 'lib/vagrant-google/action/stop_instance.rb'

# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Exclude:
- 'lib/vagrant-google.rb'
- 'vagrant-spec.config.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Style/FirstParameterIndentation:
Exclude:
- 'lib/vagrant-google/action/run_instance.rb'

# Offense count: 1
# Offense count: 4
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/vagrant-google/action/connect_google.rb'
- 'lib/vagrant-google/action/run_instance.rb'
- 'lib/vagrant-google/plugin.rb'

# Offense count: 40
# Offense count: 45
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
Style/HashSyntax:
Enabled: false
Exclude:
- 'lib/vagrant-google/action/connect_google.rb'
- 'lib/vagrant-google/action/read_ssh_info.rb'
- 'lib/vagrant-google/action/run_instance.rb'
- 'lib/vagrant-google/action/start_instance.rb'
- 'lib/vagrant-google/action/stop_instance.rb'
- 'lib/vagrant-google/action/sync_folders.rb'
- 'tasks/acceptance.rake'
- 'tasks/boxes.rake'
- 'test/unit/common/config_test.rb'

# Offense count: 2
# Cop supports --auto-correct.
Expand All @@ -164,9 +228,9 @@ Style/InfiniteLoop:

# Offense count: 1
# Cop supports --auto-correct.
Style/LeadingCommentSpace:
Style/MultilineIfThen:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'
- 'lib/vagrant-google/action/read_ssh_info.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand All @@ -182,17 +246,25 @@ Style/NilComparison:
Exclude:
- 'test/unit/common/config_test.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'tasks/acceptance.rake'

# Offense count: 1
# Cop supports --auto-correct.
Style/PerlBackrefs:
Exclude:
- 'lib/vagrant-google/action/sync_folders.rb'

# Offense count: 2
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'lib/vagrant-google/action/connect_google.rb'
- 'lib/vagrant-google/action/read_ssh_info.rb'
- 'lib/vagrant-google/action/read_state.rb'

Expand All @@ -212,49 +284,34 @@ Style/RegexpLiteral:

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/SpaceBeforeComma:
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
Style/SafeNavigation:
Exclude:
- 'Gemfile'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Style/SpaceInsideBlockBraces:
Enabled: false

# Offense count: 392
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false
- 'lib/vagrant-google/action/run_instance.rb'
- 'lib/vagrant-google/action/terminate_instance.rb'

# Offense count: 7
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiteralsInInterpolation:
Enabled: false
Exclude:
- 'lib/vagrant-google/action/run_instance.rb'
- 'lib/vagrant-google/action/start_instance.rb'
- 'lib/vagrant-google/config.rb'
- 'tasks/acceptance.rake'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: MinSize, SupportedStyles.
# SupportedStyles: percent, brackets
Style/SymbolArray:
EnforcedStyle: brackets

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'test/unit/common/config_test.rb'
13 changes: 11 additions & 2 deletions lib/vagrant-google/action/connect_google.rb
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit c73200b

Please sign in to comment.