kontena
kontena copied to clipboard
CLI: Add --master to commands that accept --grid
Fixes #2922
Adds --master
option to select master by name from config to all commands that accept --grid
as an option.
Replaces #1911
The kontena master list
command defines a current_master_name
that overlaps the new Kontena::Cli::Common#current_master_name
and goes off into an infinite recursion:
....
/home/kontena/kontena/kontena/cli/lib/kontena/cli/common.rb:259:in `current_master'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:11:in `current_master_name'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/common.rb:259:in `current_master'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:11:in `current_master_name'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/common.rb:259:in `current_master'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:11:in `current_master_name'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/common.rb:259:in `current_master'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:11:in `current_master_name'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/common.rb:259:in `current_master'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:11:in `current_master_name'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:16:in `mark_if_current'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:81:in `format_row'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:90:in `block in rows'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:90:in `map'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:90:in `rows'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:67:in `table'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:74:in `render'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:35:in `generate_table'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/table_generator.rb:39:in `print_table'
/home/kontena/kontena/kontena/cli/lib/kontena/cli/master/list_command.rb:21:in `execute'
/home/kontena/kontena/kontena/cli/lib/kontena/command.rb:213:in `run'
/home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/home/kontena/kontena/kontena/cli/lib/kontena/command.rb:213:in `run'
/home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/home/kontena/kontena/kontena/cli/lib/kontena/command.rb:213:in `run'
/home/kontena/kontena/kontena/cli/vendor/bundle/ruby/2.3.0/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
bin/kontena:18:in `<top (required)>'
The implementation of --platform
in the cloud plugin looks much more reasonable: https://github.com/kontena/kontena-plugin-cloud/blob/e68198337c41678f981811b5ea40c622e055c10f/lib/kontena_cli_plugin.rb#L12-L15
option '--platform', 'PLATFORM', 'Specify Kontena Cloud platform to use' do |platform|
config.current_master = platform
config.current_grid = platform.split('/')[1]
end
AFAIK that handles all the side-effect-ness of config.current_master=
neatly, and also avoids the mess of coupling different mixin modules together via stuff like if self.respond_to?(:current_master_name) && self.current_master_name
...
Looks like our spec_helper swallows SystemExit and makes the specs pass instead of failing
Without the rescue SystemExit
it will end running the specs and say "success" Also SystemExit is not an error most of the time.
Looks like our spec_helper swallows SystemExit and makes the specs pass instead of failing
Without the rescue SystemExit it will end running the specs and say "success" Also SystemExit is not an error most of the time.
It seems to cause any spec that hits exit_with_error
to bypass any expect(...)
checks and unconditionally succeed, unless the specs explicitly expect{...}.to raise_error(SystemExit)
:confused:
I tried changing the puts
to a fail
, which should catch that kind of exit_with_error
case.
Dunno how to handle exit(0)
- does that happen in the CLI? It seems like that would likely bypass any rspec expect(...)
assertions unless the specs themselves trap it.
This would be nice but the PR has a lot of strange stuff in it. Also it's a bit complex to make it work seamlessly, so this will need some rewriting/factoring.