mux_tf 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mux_tf/once_helper.rb +39 -0
- data/lib/mux_tf/plan_formatter.rb +22 -19
- data/lib/mux_tf/version.rb +1 -1
- data/lib/mux_tf.rb +1 -0
- metadata +4 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0fa8aa05ed298ad8e22d12b7fdab99ac1cf4f5a1fe8d947c01bf3a47249b8b77
         | 
| 4 | 
            +
              data.tar.gz: 9f65f9b7f183c80be4af4fa5e4c84f4396e0aecc9469f5f3dc20a4c2abef35ab
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7b65a09e45cdf7997a6f8b79f29061f49456f456b8d5063abd4e588230075e66ce945f0fbd3e8e6a0a2dd05a2c6d66c23a74569180bf48380810b474a64ed42b
         | 
| 7 | 
            +
              data.tar.gz: 17ae22572a91f31b6305f2637639fb21e6fa433fe20aa6bb9c07db7071ffe9ddf83cf3afe6425e98c223b9fd906a9323660febbe9282c0246b0290d3ceea5d96
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            module MuxTf
         | 
| 2 | 
            +
              class OnceHelper
         | 
| 3 | 
            +
                # once = OnceHelper.new
         | 
| 4 | 
            +
                # once.for(:phase).once { ... }.otherwise { ... }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                class StateEvaluator
         | 
| 7 | 
            +
                  def initialize(once_helper, new_state)
         | 
| 8 | 
            +
                    if once_helper.state != new_state
         | 
| 9 | 
            +
                      once_helper.state = new_state
         | 
| 10 | 
            +
                      @path = :once
         | 
| 11 | 
            +
                    else
         | 
| 12 | 
            +
                      @path = :otherwise
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  def once(&block)
         | 
| 17 | 
            +
                    if @path == :then
         | 
| 18 | 
            +
                      yield
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  def otherwise(&block)
         | 
| 23 | 
            +
                    if @path == :otherwise
         | 
| 24 | 
            +
                      yield
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                def initialize
         | 
| 30 | 
            +
                  @state = nil
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                attr_accessor :state
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                def for(new_state)
         | 
| 36 | 
            +
                  StateEvaluator.new(self, new_state)
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -9,14 +9,15 @@ module MuxTf | |
| 9 9 | 
             
                  def pretty_plan(filename, targets: [])
         | 
| 10 10 | 
             
                    pastel = Pastel.new
         | 
| 11 11 |  | 
| 12 | 
            -
                     | 
| 12 | 
            +
                    once = OnceHelper.new
         | 
| 13 13 |  | 
| 14 14 | 
             
                    meta = {}
         | 
| 15 15 |  | 
| 16 16 | 
             
                    parser = StatefulParser.new(normalizer: pastel.method(:strip))
         | 
| 17 17 | 
             
                    parser.state(:info, /^Acquiring state lock/)
         | 
| 18 18 | 
             
                    parser.state(:error, /(╷|Error locking state|Error:)/, %i[none blank info reading])
         | 
| 19 | 
            -
                    parser.state(:reading, /: (Reading...|Read complete after)/, %i[none info])
         | 
| 19 | 
            +
                    parser.state(:reading, /: (Reading...|Read complete after)/, %i[none info reading])
         | 
| 20 | 
            +
                    parser.state(:none, /^$/, [:reading])
         | 
| 20 21 | 
             
                    parser.state(:refreshing, /^.+: Refreshing state... \[id=/, %i[none info reading])
         | 
| 21 22 | 
             
                    parser.state(:refreshing, /Refreshing Terraform state in-memory prior to plan.../, %i[none blank info reading])
         | 
| 22 23 | 
             
                    parser.state(:refresh_done, /^----------+$/, [:refreshing])
         | 
| @@ -24,6 +25,9 @@ module MuxTf | |
| 24 25 | 
             
                    parser.state(:plan_info, /Terraform will perform the following actions:/, [:refresh_done, :none])
         | 
| 25 26 | 
             
                    parser.state(:plan_summary, /^Plan:/, [:plan_info])
         | 
| 26 27 |  | 
| 28 | 
            +
                    parser.state(:plan_legend, /^Terraform used the selected providers to generate the following execution$/)
         | 
| 29 | 
            +
                    parser.state(:none, /^$/, [:plan_legend])
         | 
| 30 | 
            +
             | 
| 27 31 | 
             
                    parser.state(:error_lock_info, /Lock Info/, [:error])
         | 
| 28 32 | 
             
                    parser.state(:error, /^$/, [:error_lock_info])
         | 
| 29 33 |  | 
| @@ -40,9 +44,9 @@ module MuxTf | |
| 40 44 | 
             
                          end
         | 
| 41 45 | 
             
                        when :reading
         | 
| 42 46 | 
             
                          clean_line = pastel.strip(line)
         | 
| 43 | 
            -
                          if clean_line.match | 
| 47 | 
            +
                          if clean_line.match(/^(.+): Reading...$/)
         | 
| 44 48 | 
             
                            log "Reading: #{$LAST_MATCH_INFO[1]} ...", depth: 2
         | 
| 45 | 
            -
                          elsif clean_line.match | 
| 49 | 
            +
                          elsif clean_line.match(/^(.+): Read complete after ([^\[]+)(?: \[(.+)\])?$/)
         | 
| 46 50 | 
             
                            if $LAST_MATCH_INFO[3]
         | 
| 47 51 | 
             
                              log "Reading Complete: #{$LAST_MATCH_INFO[1]} after #{$LAST_MATCH_INFO[2]} [#{$LAST_MATCH_INFO[3]}]", depth: 3
         | 
| 48 52 | 
             
                            else
         | 
| @@ -61,10 +65,7 @@ module MuxTf | |
| 61 65 | 
             
                          meta["error"] = "lock"
         | 
| 62 66 | 
             
                          log Paint[line, :red], depth: 2
         | 
| 63 67 | 
             
                        when :plan_error
         | 
| 64 | 
            -
                           | 
| 65 | 
            -
                            puts
         | 
| 66 | 
            -
                            phase = :plan_error
         | 
| 67 | 
            -
                          end
         | 
| 68 | 
            +
                          once.for(state).once { puts }
         | 
| 68 69 | 
             
                          meta["error"] = "refresh"
         | 
| 69 70 | 
             
                          log Paint[line, :red], depth: 2
         | 
| 70 71 | 
             
                        when :error_lock_info
         | 
| @@ -73,20 +74,22 @@ module MuxTf | |
| 73 74 | 
             
                          end
         | 
| 74 75 | 
             
                          log Paint[line, :red], depth: 2
         | 
| 75 76 | 
             
                        when :refreshing
         | 
| 76 | 
            -
                           | 
| 77 | 
            -
                            phase = :refreshing
         | 
| 77 | 
            +
                          once.for(state).once {
         | 
| 78 78 | 
             
                            log "Refreshing state ", depth: 2, newline: false
         | 
| 79 | 
            -
                           | 
| 79 | 
            +
                          }.otherwise {
         | 
| 80 80 | 
             
                            print "."
         | 
| 81 | 
            -
                           | 
| 81 | 
            +
                          }
         | 
| 82 | 
            +
                        when :plan_legend
         | 
| 83 | 
            +
                          once.for(state).once { puts }
         | 
| 84 | 
            +
                          log line, depth: 2
         | 
| 82 85 | 
             
                        when :refresh_done
         | 
| 83 | 
            -
                           | 
| 84 | 
            -
                            phase = :refresh_done
         | 
| 86 | 
            +
                          once.for(state).once {
         | 
| 85 87 | 
             
                            puts
         | 
| 86 | 
            -
                           | 
| 87 | 
            -
                            # | 
| 88 | 
            -
                           | 
| 88 | 
            +
                          }.otherwise {
         | 
| 89 | 
            +
                            #nothing
         | 
| 90 | 
            +
                          }
         | 
| 89 91 | 
             
                        when :plan_info
         | 
| 92 | 
            +
                          once.for(state).once { puts }
         | 
| 90 93 | 
             
                          log line, depth: 2
         | 
| 91 94 | 
             
                        when :plan_summary
         | 
| 92 95 | 
             
                          log line, depth: 2
         | 
| @@ -120,10 +123,10 @@ module MuxTf | |
| 120 123 |  | 
| 121 124 | 
             
                    parser = StatefulParser.new(normalizer: pastel.method(:strip))
         | 
| 122 125 |  | 
| 123 | 
            -
                    parser.state(:modules_init, /^Initializing modules | 
| 126 | 
            +
                    parser.state(:modules_init, /^Initializing modules\.\.\./, [:none, :backend])
         | 
| 124 127 | 
             
                    parser.state(:modules_upgrade, /^Upgrading modules\.\.\./)
         | 
| 125 128 | 
             
                    parser.state(:backend, /^Initializing the backend\.\.\./, [:none, :modules_init, :modules_upgrade])
         | 
| 126 | 
            -
                    parser.state(:plugins, /^Initializing provider plugins\.\.\./, [:backend])
         | 
| 129 | 
            +
                    parser.state(:plugins, /^Initializing provider plugins\.\.\./, [:backend, :modules_init])
         | 
| 127 130 |  | 
| 128 131 | 
             
                    parser.state(:plugin_warnings, /^$/, [:plugins])
         | 
| 129 132 | 
             
                    parser.state(:backend_error, /Error:/, [:backend])
         | 
    
        data/lib/mux_tf/version.rb
    CHANGED
    
    
    
        data/lib/mux_tf.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: mux_tf
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.8. | 
| 4 | 
            +
              version: 0.8.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Piotr Banasik
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-05-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -141,6 +141,7 @@ files: | |
| 141 141 | 
             
            - lib/mux_tf/cli/current.rb
         | 
| 142 142 | 
             
            - lib/mux_tf/cli/mux.rb
         | 
| 143 143 | 
             
            - lib/mux_tf/cli/plan_summary.rb
         | 
| 144 | 
            +
            - lib/mux_tf/once_helper.rb
         | 
| 144 145 | 
             
            - lib/mux_tf/plan_formatter.rb
         | 
| 145 146 | 
             
            - lib/mux_tf/plan_summary_handler.rb
         | 
| 146 147 | 
             
            - lib/mux_tf/resource_tokenizer.rb
         | 
| @@ -171,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 171 172 | 
             
                - !ruby/object:Gem::Version
         | 
| 172 173 | 
             
                  version: '0'
         | 
| 173 174 | 
             
            requirements: []
         | 
| 174 | 
            -
            rubygems_version: 3. | 
| 175 | 
            +
            rubygems_version: 3.4.10
         | 
| 175 176 | 
             
            signing_key:
         | 
| 176 177 | 
             
            specification_version: 4
         | 
| 177 178 | 
             
            summary: Terraform Multiplexing Scripts
         |