lib/command/run.rb in cpl-0.7.0 vs lib/command/run.rb in cpl-1.0.0
- old
+ new
@@ -54,28 +54,30 @@
```
EX
attr_reader :location, :workload, :one_off, :container
- def call
+ def call # rubocop:disable Metrics/MethodLength
@location = config[:default_location]
@workload = config.options["workload"] || config[:one_off_workload]
@one_off = "#{workload}-run-#{rand(1000..9999)}"
- clone_workload
+ step("Cloning workload '#{workload}' on app '#{config.options[:app]}' to '#{one_off}'") do
+ clone_workload
+ end
+
wait_for_workload(one_off)
wait_for_replica(one_off, location)
run_in_replica
ensure
+ progress.puts
ensure_workload_deleted(one_off)
end
private
def clone_workload # rubocop:disable Metrics/MethodLength
- progress.puts "- Cloning workload '#{workload}' on '#{config.options[:app]}' to '#{one_off}'"
-
# Create a base copy of workload props
spec = cp.fetch_workload!(workload).fetch("spec")
container_spec = spec["containers"].detect { _1["name"] == workload } || spec["containers"].first
@container = container_spec["name"]
@@ -125,20 +127,20 @@
# NOTE: fixes terminal size to match local terminal
if config.current[:fix_terminal_size] || config.options[:terminal_size]
if config.options[:terminal_size]
rows, cols = config.options[:terminal_size].split(",")
else
- rows, cols = `stty -a`.match(/(\d+)\s*rows;\s*(\d+)\s*columns/).captures
+ rows, cols = `stty size`.split(/\s+/)
end
script += "stty rows #{rows}\nstty cols #{cols}\n" if rows && cols
end
script += args_join(config.args)
script
end
def run_in_replica
- progress.puts "- Connecting"
+ progress.puts("Connecting...\n\n")
command = %(bash -c 'eval "$CONTROLPLANE_RUNNER"')
cp.workload_exec(one_off, location: location, container: container, command: command)
end
end
end