biosphere 0.2.1 → 0.2.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/bin/biosphere +15 -0
- data/lib/biosphere.rb +1 -0
- data/lib/biosphere/cli/updatemanager.rb +31 -0
- data/lib/biosphere/deployment.rb +19 -4
- data/lib/biosphere/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 81c2cd041ce9dde3053f5fe132759eb1b613bca0
         | 
| 4 | 
            +
              data.tar.gz: 3e8b438a25f87f2d0768f95e0b9d869ac4e84e08
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c860e5fb498ea64939b51c7ff6b224ba8da60c8e81f3b438152f6d1a7ac88edd3b278c95e9edfc39f9719ad30d907276c59010e763701e6f3a6dcf13db33c710
         | 
| 7 | 
            +
              data.tar.gz: 8e9593ac3d4dad87d535983b2150b5a986c52dc6b16dee8baa7a20a560ea94553de4aced5c91ca42a2fb6a5725aebb5b1981a501fbbad72d5f8675902eaefb9d
         | 
    
        data/bin/biosphere
    CHANGED
    
    | @@ -244,6 +244,21 @@ elsif ARGV[0] == "commit" && options.src | |
| 244 244 | 
             
                        puts "The child process exited!"
         | 
| 245 245 | 
             
                    end
         | 
| 246 246 |  | 
| 247 | 
            +
                    # Refresh outputs to make sure they are available in the state file
         | 
| 248 | 
            +
                    command_output = ""
         | 
| 249 | 
            +
                    begin
         | 
| 250 | 
            +
                        puts "Refreshing terraform outputs"
         | 
| 251 | 
            +
                        PTY.spawn("terraform refresh -state=#{state_file} #{options.build_dir}") do |stdout, stdin, pid|
         | 
| 252 | 
            +
                        begin
         | 
| 253 | 
            +
                            stdout.each { |line| command_output << line }
         | 
| 254 | 
            +
                            rescue Errno::EIO
         | 
| 255 | 
            +
                            end
         | 
| 256 | 
            +
                        end
         | 
| 257 | 
            +
                    rescue PTY::ChildExited
         | 
| 258 | 
            +
                        puts "Error executing terraform refresh.:\n"
         | 
| 259 | 
            +
                        puts command_output
         | 
| 260 | 
            +
                    end
         | 
| 261 | 
            +
             | 
| 247 262 | 
             
                    puts "Loading outputs for #{deployment} from #{state_file}"
         | 
| 248 263 | 
             
                    suite.deployments[deployment].load_outputs(state_file)
         | 
| 249 264 | 
             
                    state.save()
         | 
    
        data/lib/biosphere.rb
    CHANGED
    
    
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require 'pp'
         | 
| 2 | 
            +
            require 'treetop'
         | 
| 3 | 
            +
            require 'colorize'
         | 
| 4 | 
            +
            require 'net/http'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Biosphere
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                class CLI
         | 
| 9 | 
            +
                    class UpdateManager
         | 
| 10 | 
            +
             | 
| 11 | 
            +
             | 
| 12 | 
            +
                        def check_for_update(version = ::Biosphere::Version)
         | 
| 13 | 
            +
                            url = URI('https://rubygems.org/api/v1/versions/biosphere/latest.json')
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                            response = get_response_with_redirect(url)
         | 
| 16 | 
            +
                            pp response
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                            return info
         | 
| 19 | 
            +
                        end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                        private
         | 
| 22 | 
            +
                        def get_response_with_redirect(uri)
         | 
| 23 | 
            +
                            r = Net::HTTP.get_response(uri)
         | 
| 24 | 
            +
                            if r.code == "301"
         | 
| 25 | 
            +
                                r = Net::HTTP.get_response(URI.parse(r.header['location']))
         | 
| 26 | 
            +
                            end
         | 
| 27 | 
            +
                            r
         | 
| 28 | 
            +
                        end
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
            end
         | 
    
        data/lib/biosphere/deployment.rb
    CHANGED
    
    | @@ -169,8 +169,19 @@ class Biosphere | |
| 169 169 | 
             
                        end
         | 
| 170 170 |  | 
| 171 171 | 
             
                        @outputs.each do |output|
         | 
| 172 | 
            -
                             | 
| 173 | 
            -
             | 
| 172 | 
            +
                            begin
         | 
| 173 | 
            +
                                value = outputs[output[:resource_name]]
         | 
| 174 | 
            +
                                instance_exec(self.name, output[:name], value["value"], value, &output[:block])
         | 
| 175 | 
            +
                            rescue NoMethodError => e
         | 
| 176 | 
            +
                                STDERR.puts "Error evaluating output #{output}. error: #{e}"
         | 
| 177 | 
            +
                                puts "output:"
         | 
| 178 | 
            +
                                pp output
         | 
| 179 | 
            +
                                puts "value:"
         | 
| 180 | 
            +
                                pp value
         | 
| 181 | 
            +
                                puts "outputs:"
         | 
| 182 | 
            +
                                pp outputs
         | 
| 183 | 
            +
                                STDERR.puts "This is an internal error. You should be able to run biosphere commit again to try to fix this."
         | 
| 184 | 
            +
                            end
         | 
| 174 185 | 
             
                        end
         | 
| 175 186 | 
             
                    end
         | 
| 176 187 |  | 
| @@ -184,8 +195,12 @@ class Biosphere | |
| 184 195 | 
             
                        end
         | 
| 185 196 |  | 
| 186 197 | 
             
                        outputs = tf_state["modules"].first["outputs"]
         | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 198 | 
            +
                        if outputs.length == 0
         | 
| 199 | 
            +
                            STDERR.puts "WARNING: No outputs found from the terraform state file #{tfstate_filename}. This might be a bug in terraform."
         | 
| 200 | 
            +
                            STDERR.puts "Try to run \"biosphere commit\" again."
         | 
| 201 | 
            +
                        else
         | 
| 202 | 
            +
                            evaluate_outputs(outputs)
         | 
| 203 | 
            +
                        end
         | 
| 189 204 | 
             
                    end
         | 
| 190 205 |  | 
| 191 206 | 
             
                    def evaluate_resources()
         | 
    
        data/lib/biosphere/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: biosphere
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 4 | 
            +
              version: 0.2.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Juho Mäkinen
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017-05- | 
| 11 | 
            +
            date: 2017-05-16 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rspec
         | 
| @@ -164,6 +164,7 @@ files: | |
| 164 164 | 
             
            - examples/example.rb
         | 
| 165 165 | 
             
            - lib/biosphere.rb
         | 
| 166 166 | 
             
            - lib/biosphere/cli/terraformplanning.rb
         | 
| 167 | 
            +
            - lib/biosphere/cli/updatemanager.rb
         | 
| 167 168 | 
             
            - lib/biosphere/deployment.rb
         | 
| 168 169 | 
             
            - lib/biosphere/ipaddressallocator.rb
         | 
| 169 170 | 
             
            - lib/biosphere/kube.rb
         |