Sha256: b1b277de6324645ba86546c7f5e3cffa38797c65f17ff5114d1f1efaeebb644b

Contents?: true

Size: 783 Bytes

Versions: 120

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

require 'json'
require 'bolt/error'
require 'bolt/util'

module Bolt
  class PlanResult
    attr_accessor :value, :status

    # 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

120 entries across 120 versions & 1 rubygems

Version Path
bolt-2.6.0 lib/bolt/plan_result.rb
bolt-2.5.0 lib/bolt/plan_result.rb
bolt-2.4.0 lib/bolt/plan_result.rb
bolt-2.3.1 lib/bolt/plan_result.rb
bolt-2.3.0 lib/bolt/plan_result.rb
bolt-2.2.0 lib/bolt/plan_result.rb
bolt-2.1.0 lib/bolt/plan_result.rb
bolt-2.0.1 lib/bolt/plan_result.rb
bolt-2.0.0 lib/bolt/plan_result.rb
bolt-1.49.0 lib/bolt/plan_result.rb
bolt-1.48.0 lib/bolt/plan_result.rb
bolt-1.47.0 lib/bolt/plan_result.rb
bolt-1.45.0 lib/bolt/plan_result.rb
bolt-1.44.0 lib/bolt/plan_result.rb
bolt-1.43.0 lib/bolt/plan_result.rb
bolt-1.42.0 lib/bolt/plan_result.rb
bolt-1.41.0 lib/bolt/plan_result.rb
bolt-1.40.0 lib/bolt/plan_result.rb
bolt-1.39.0 lib/bolt/plan_result.rb
bolt-1.38.0 lib/bolt/plan_result.rb