Class: Jatai::Commands::Scale
Instance Method Summary collapse
Methods inherited from Base
#api, #app_slug, #error, #info, #pastel, #project_config, #require_auth!, #success
Instance Method Details
#execute(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jatai/commands/scale.rb', line 7 def execute( = {}) require_auth! slug = app_slug body = {} body[:replicas] = ["replicas"].to_i if ["replicas"] body[:preset] = ["preset"] if ["preset"] if body.empty? error("Informe ao menos --replicas ou --preset. Ex: jatai scale --replicas 3") return end estimate = api.post("/api/v1/apps/#{slug}/scale/estimate", body: body) info("Preset: #{estimate["preset"]}") info("Réplicas: #{estimate["replicas"]}") if estimate["replicas"] info("CPU: #{estimate["cpu_limit"]} | RAM: #{estimate["memory_limit"]}") if estimate["cpu_limit"] info("Custo estimado: R$ #{estimate["monthly_cost"]}/mês") prompt = TTY::Prompt.new unless prompt.yes?("Confirmar escalonamento?") info("Escalonamento cancelado.") return end api.put("/api/v1/apps/#{slug}/scale", body: body) success("Escalonamento aplicado com sucesso!") rescue Api::Client::ApiError => e error("Erro: #{e.}") end |