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
Conversation
spec/broadside/target_spec.rb
Outdated
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) )} |
There was a problem hiding this comment.
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 }.
spec/broadside/target_spec.rb
Outdated
|
||
shared_examples 'valid_configuration?' do |succeeds, config_hash| | ||
#let(:command) { %w(do something) } |
There was a problem hiding this comment.
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 #.
lib/broadside/configuration.rb
Outdated
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!" } |
There was a problem hiding this comment.
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) | ||
|
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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.
lib/broadside/command.rb
Outdated
debug "Getting status information about #{family}" | ||
|
There was a problem hiding this comment.
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/command.rb
Outdated
family = target.family | ||
pastel = Pastel.new | ||
|
||
target = Broadside.config.get_target_by_name!(options[:target]) |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
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}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh dip great catch
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea
lib/broadside/configuration.rb
Outdated
@@ -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] |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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 @
?
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
lib/broadside/configuration.rb
Outdated
cmd << " -o ProxyCommand=\"ssh #{proxy[:host]} nc #{ip} #{proxy[:port]}\"" | ||
end | ||
cmd << " #{@ssh[:user]}@#{ip}" | ||
cmd << " #{@ssh[:user]}@" if @ssh[:user] | ||
cmd << "#{ip}" |
There was a problem hiding this comment.
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.
target_from_name!
toget_target_by_name!
there are no functionality changes in here except getting rid of
predeploy_commands.rb
; everything else is just style.