Sha256: a4591f1444f66dfec29a18d92e6c144585ea12200e19c13c39a31433b91d3022

Contents?: true

Size: 807 Bytes

Versions: 17

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

require 'json'
require_relative '../bolt/error'
require_relative '../bolt/util'

module Bolt
  class PlanResult
    attr_accessor :status, :value

    # This must be called from inside a compiler
    def self.from_pcore(result, status)
      result = Bolt::Util.walk_vals(result) do |v|
        if v.is_a?(Puppet::DataTypes::Error)
          Bolt::PuppetError.from_error(v)
        else
          v
        end
      end
      new(result, status)
    end

    def initialize(value, status)
      @value = value
      @status = status
    end

    def ok?
      @status == 'success'
    end

    def ==(other)
      value == other.value && status == other.status
    end

    def to_json(*args)
      @value.to_json(*args)
    end

    def to_s
      to_json
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
bolt-3.29.0 lib/bolt/plan_result.rb
bolt-3.28.0 lib/bolt/plan_result.rb
bolt-3.27.4 lib/bolt/plan_result.rb
bolt-3.27.2 lib/bolt/plan_result.rb
bolt-3.27.1 lib/bolt/plan_result.rb
bolt-3.26.2 lib/bolt/plan_result.rb
bolt-3.26.1 lib/bolt/plan_result.rb
bolt-3.25.0 lib/bolt/plan_result.rb
bolt-3.24.0 lib/bolt/plan_result.rb
bolt-3.23.1 lib/bolt/plan_result.rb
bolt-3.23.0 lib/bolt/plan_result.rb
bolt-3.22.1 lib/bolt/plan_result.rb
bolt-3.22.0 lib/bolt/plan_result.rb
bolt-3.21.0 lib/bolt/plan_result.rb
bolt-3.20.0 lib/bolt/plan_result.rb
bolt-3.19.0 lib/bolt/plan_result.rb
bolt-3.18.0 lib/bolt/plan_result.rb