Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of default predeploy_commands.rb #59

Merged
merged 19 commits into from Feb 3, 2017
Merged

Get rid of default predeploy_commands.rb #59

merged 19 commits into from Feb 3, 2017

Conversation

apurvis
Copy link
Contributor

@apurvis apurvis commented Feb 2, 2017

  • rename target_from_name! to get_target_by_name!
  • trivial style changes to cut down on some lines
  • fix bug with missing SSH user

there are no functionality changes in here except getting rid of predeploy_commands.rb; everything else is just style.

let(:valid_options) { { scale: 100 } }
let(:target) { described_class.new(target_name, valid_options.merge(config_hash) )}
let(:target) { described_class.new(test_target_name, valid_options.merge(config_hash) )}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/SpaceInsideParens: Space inside parentheses detected.
Style/SpaceInsideBlockBraces: Space missing inside }.


shared_examples 'valid_configuration?' do |succeeds, config_hash|
#let(:command) { %w(do something) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/LeadingCommentSpace: Missing space after #.

def target_from_name!(name)
@targets.fetch(name) { |k| raise Error, "Deploy target '#{name}' does not exist!" }
def get_target_by_name!(name)
@targets.fetch(name) { |k| raise ArgumentError, "Deploy target '#{name}' does not exist!" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UnusedBlockArgument: Unused block argument - k. You can omit the argument if you don't care about it.

lib/broadside.rb Outdated
end

raise ArgumentError, "#{config_file} does not exist" unless File.exist?(config_file)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/TrailingWhitespace: Trailing whitespace detected.

lib/broadside.rb Outdated
raise e
[config_file, USER_CONFIG_FILE].each { |file| load file if File.exist?(file) }
rescue LoadError
error "Encountered an error loading broadside Configuration"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

apurvis@lumoslabs.com added 2 commits February 2, 2017 11:37
debug "Getting status information about #{family}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/TrailingWhitespace: Trailing whitespace detected.

family = target.family
pastel = Pastel.new

target = Broadside.config.get_target_by_name!(options[:target])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UselessAssignment: Useless assignment to variable - target.

lib/broadside.rb Outdated
rescue LoadError => e
error "Encountered an error loading required configuration file '#{config_file}' !"
raise e
[config_file, USER_CONFIG_FILE].each { |file| load file if File.exist?(file) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config_file should be loaded last, as it has precedence. also, could we add debug statements before each load? Like

debug "Loading broadside configuration at #{file}"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh dip great catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(i now officially feel guilty for deleting the spec that checks load order - when i was unifying all the spec contexts that particular spec caused some difficulties and i thought these lines would force a call order but i just checked and they do not. 😞 )

lib/broadside.rb Outdated
[config_file, USER_CONFIG_FILE].each { |file| load file if File.exist?(file) }
rescue LoadError
error 'Encountered an error loading broadside configuration'
raise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, does this just reraise the same error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea

@@ -25,15 +25,17 @@ class Configuration
validates_each(:aws) do |record, _, val|
[:region, :credentials].each { |v| record.errors.add("aws.#{v}") unless val.public_send(v) }
end
validates_each :ssh, allow_nil: true do |record, attr, val|
record.errors.add(attr, 'is not a hash') unless val.is_a?(Hash)
record.errors.add(attr, 'must contain a user') unless val[:user]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the user requirement (someone may have configured a default user in ~/.ssh/config)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would the command then be ssh @123.123.123.123? wouldn't you need to ditch the @?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. i'll address the @ with #11

@@ -63,17 +63,16 @@ def get_running_instance_ips(cluster, family, task_arns = nil)
end

def get_task_arns(cluster, family, filter = {})
opts = {
options = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@@ -30,24 +28,21 @@
it_behaves_like 'valid_configuration?', true, env_files: ['file', 'file2']

it_behaves_like 'valid_configuration?', true, command: nil
it_behaves_like 'valid_configuration?', true, command: ['bundle', 'exec', 'resque:work']
it_behaves_like 'valid_configuration?', false, command: 'bundle exec rails s'
it_behaves_like 'valid_configuration?', true, command: %w(do something)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW i am super annoyed that you can't use let(:command) { %w(do something) } in an it_behaves_like expression. oh well.

cmd << " -o ProxyCommand=\"ssh #{proxy[:host]} nc #{ip} #{proxy[:port]}\""
end
cmd << " #{@ssh[:user]}@#{ip}"
cmd << " #{@ssh[:user]}@" if @ssh[:user]
cmd << "#{ip}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/UnneededInterpolation: Prefer to_s over string interpolation.

@apurvis apurvis merged commit 1c8f9e0 into master Feb 3, 2017
@apurvis apurvis deleted the tweaks branch February 3, 2017 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants