Sha256: 5e567d4ce5aca66b9d00fefbc59946b4469a26a8f09d451ae60e7885cbbcaa47

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

module Terraspace::Cloud
  class Update < Base
    def create(success, stream)
      return unless Terraspace.cloud?
      return unless record?

      build(success)
      upload = cloud_upload.create(type: "update", stream_id: stream['data']['id'])
      params = {
        upload_id: upload['data']['id'],
        stack_uid: upload['data']['attributes']['stack_id'], # use stack_uid since stack_id is friendly url name
        update: stage_attrs(success),
      }
      api.create_update(params)
    end

    def build(success)
      clean_cache2_stage
      # .terraspace-cache/dev/stacks/demo
      Dir.chdir(@mod.cache_dir) do
        cache2_path = ".terraspace-cache/.cache2/update"
        FileUtils.mkdir_p(cache2_path)

        IO.write("#{cache2_path}/update.log", Terraspace::Logger.logs)
        return unless success

        sh "terraform state pull > #{cache2_path}/state.json"
        sh "terraform output -json > #{cache2_path}/output.json"
      end
    end

    def cani?(exit_on_error: true)
      return true unless Terraspace.cloud?
      api.create_update(cani: 1, exit_on_error: exit_on_error)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
terraspace-2.2.8 lib/terraspace/cloud/update.rb
terraspace-2.2.7 lib/terraspace/cloud/update.rb
terraspace-2.2.6 lib/terraspace/cloud/update.rb
terraspace-2.2.5 lib/terraspace/cloud/update.rb
terraspace-2.2.4 lib/terraspace/cloud/update.rb
terraspace-2.2.3 lib/terraspace/cloud/update.rb
terraspace-2.2.2 lib/terraspace/cloud/update.rb
terraspace-2.2.1 lib/terraspace/cloud/update.rb
terraspace-2.2.0 lib/terraspace/cloud/update.rb
terraspace-2.1.7 lib/terraspace/cloud/update.rb
terraspace-2.1.6 lib/terraspace/cloud/update.rb
terraspace-2.1.5 lib/terraspace/cloud/update.rb
terraspace-2.1.4 lib/terraspace/cloud/update.rb
terraspace-2.1.3 lib/terraspace/cloud/update.rb
terraspace-2.1.2 lib/terraspace/cloud/update.rb
terraspace-2.1.1 lib/terraspace/cloud/update.rb
terraspace-2.1.0 lib/terraspace/cloud/update.rb