Class: MuxTf::Cli::Current::PlanCommand
- Inherits:
-
Object
- Object
- MuxTf::Cli::Current::PlanCommand
- Extended by:
- PiotrbCliUtils::Util
- Includes:
- TerraformHelpers, PiotrbCliUtils::CriCommandSupport
- Defined in:
- lib/mux_tf/cli/current/plan_command.rb
Instance Attribute Summary collapse
-
#last_lock_info ⇒ Object
readonly
Returns the value of attribute last_lock_info.
Instance Method Summary collapse
- #plan_cmd ⇒ Object
- #run_plan(targets: [], level: 1, retry_count: 0) ⇒ Object
-
#run_validate(level: 1) ⇒ Object
returns boolean true if succeeded.
Methods included from TerraformHelpers
#tf_apply, #tf_force_unlock, #tf_init, #tf_plan, #tf_show, #tf_stream_helper, #tf_validate
Instance Attribute Details
#last_lock_info ⇒ Object (readonly)
Returns the value of attribute last_lock_info.
11 12 13 |
# File 'lib/mux_tf/cli/current/plan_command.rb', line 11 def last_lock_info @last_lock_info end |
Instance Method Details
#plan_cmd ⇒ Object
13 14 15 16 17 |
# File 'lib/mux_tf/cli/current/plan_command.rb', line 13 def plan_cmd define_cmd("plan", summary: "Re-run plan") do |_opts, _args, _cmd| run_validate && run_plan end end |
#run_plan(targets: [], level: 1, retry_count: 0) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/mux_tf/cli/current/plan_command.rb', line 29 def run_plan(targets: [], level: 1, retry_count: 0) plan_status, = Current.remedy_retry_helper(from: :plan, level: level, attempt: retry_count) { @last_lock_info = nil plan_filename = PlanFilenameGenerator.for_path plan_status, = create_plan(plan_filename, targets: targets) Current.print_errors_and_warnings() remedies = detect_remedies_from_plan() if remedies.include?(:unlock) @last_lock_info = extract_lock_info() throw :abort, [plan_status, ] end throw :abort, [plan_status, ] if remedies.include?(:auth) [remedies, plan_status, ] } case plan_status when :ok log "no changes", depth: 1 when :error log "something went wrong", depth: 1 when :changes if ENV["JSON_PLAN"] plan_filename = PlanFilenameGenerator.for_path plan = PlanSummaryHandler.from_file(plan_filename) log plan.plan_text_output log "" plan.simple_summary do |line| log line, depth: 2 end else log "Printing Plan Summary ...", depth: 1 plan_filename = PlanFilenameGenerator.for_path plan = PlanSummaryHandler.from_file(plan_filename) plan.simple_summary do |line| log line, depth: 2 end end when :unknown # nothing end plan_status end |
#run_validate(level: 1) ⇒ Object
returns boolean true if succeeded
20 21 22 23 24 25 26 27 |
# File 'lib/mux_tf/cli/current/plan_command.rb', line 20 def run_validate(level: 1) Current.remedy_retry_helper(from: :validate, level: level) do validation_info = validate PlanFormatter.print_validation_errors(validation_info) remedies = PlanFormatter.process_validation(validation_info) [remedies, validation_info] end end |