Sha256: 75f01663429b4539455dbe6c3b4526df7b486cb3ab155be34e78ee3781f3ec66

Contents?: true

Size: 979 Bytes

Versions: 21

Compression:

Stored size: 979 Bytes

Contents

module Itamae
  module Resource
    class Link < Base
      define_attribute :action, default: :create
      define_attribute :link, type: String, default_name: true
      define_attribute :to, type: String, required: true
      define_attribute :force, type: [TrueClass, FalseClass], default: false

      def pre_action
        case @current_action
        when :create
          attributes.exist = true
        end
      end

      def set_current_attributes
        current.exist = run_specinfra(:check_file_is_link, attributes.link)

        if current.exist
          current.to = run_specinfra(:get_file_link_target, attributes.link).stdout.strip
        end
      end

      def action_create(options)
        unless run_specinfra(:check_file_is_linked_to, attributes.link, attributes.to)
          run_specinfra(:link_file_to, attributes.link, attributes.to,
            force: attributes.force, no_dereference: attributes.force)
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
itamae-1.14.1 lib/itamae/resource/link.rb
itamae-1.14.0 lib/itamae/resource/link.rb
itamae-1.13.1 lib/itamae/resource/link.rb
itamae-1.13.0 lib/itamae/resource/link.rb
itamae-1.12.6 lib/itamae/resource/link.rb
itamae-1.12.5 lib/itamae/resource/link.rb
itamae-1.12.4 lib/itamae/resource/link.rb
itamae-1.12.3 lib/itamae/resource/link.rb
itamae-1.12.2 lib/itamae/resource/link.rb
itamae-1.12.1 lib/itamae/resource/link.rb
itamae-1.12.0 lib/itamae/resource/link.rb
itamae-1.11.2 lib/itamae/resource/link.rb
itamae-1.11.1 lib/itamae/resource/link.rb
itamae-1.11.0 lib/itamae/resource/link.rb
itamae-1.10.10 lib/itamae/resource/link.rb
itamae-1.10.9 lib/itamae/resource/link.rb
itamae-1.10.8 lib/itamae/resource/link.rb
itamae-1.10.7 lib/itamae/resource/link.rb
itamae-1.10.6 lib/itamae/resource/link.rb
itamae-1.10.5 lib/itamae/resource/link.rb