Sha256: 757c6a8d7c31ec2abc06ebe5356d94de069a9e60dfa9214728c4c35f69215b33

Contents?: true

Size: 997 Bytes

Versions: 8

Compression:

Stored size: 997 Bytes

Contents

require 'itamae'

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

8 entries across 8 versions & 1 rubygems

Version Path
itamae-1.10.3 lib/itamae/resource/link.rb
itamae-1.10.2 lib/itamae/resource/link.rb
itamae-1.10.1 lib/itamae/resource/link.rb
itamae-1.10.0 lib/itamae/resource/link.rb
itamae-1.9.13 lib/itamae/resource/link.rb
itamae-1.9.12 lib/itamae/resource/link.rb
itamae-1.9.11 lib/itamae/resource/link.rb
itamae-1.9.10 lib/itamae/resource/link.rb