Sha256: f5eb0f13261ba5feb3d422fb51bffd8b02ec2e9f5dce7a8eb010c9cea2c26a25

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

module Cloudspin
  module Stack
    module Rake

      class ArtefactTask < ::Rake::TaskLib

        def initialize(definition_folder:, dist_folder:)
          @definition_folder = definition_folder
          @dist_folder = dist_folder
          define
        end

        def define
          desc 'Assemble files to be packaged'
          task :build, [:inspec_folder, :config_file] do |t, args|
            add_folder(args[:inspec_folder] || './inspec')
            add_file(args[:config_file] || './spin-default.yaml')
            add_file("./stack-instance-default.yaml")
            add_file("./stack-instance-defaults.yaml")
            add_file("./spin-local.yaml")
            add_file("./stack-instance-local.yaml")
            builder.build
          end

          desc 'Package the artefact'
          task :package do |t, args|
            builder.package
          end
        end

        def add_folder(folder)
          builder.add_folder_to_package(folder) if Dir.exists?(folder)
        end

        def add_file(filename)
          builder.add_file_to_package(filename) if File.exists?(filename)
        end

        def builder
          @builder ||= Cloudspin::Stack::Artefact::Builder.new(
            stack_definition: stack_definition,
            dist_folder: @dist_folder
          )
        end

        def stack_definition
          @definition ||= Cloudspin::Stack::Definition.from_file(@definition_folder + '/stack.yaml')
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudspin-stack-artefact-0.1.5 lib/cloudspin/stack/rake/artefact_task.rb
cloudspin-stack-artefact-0.1.4 lib/cloudspin/stack/rake/artefact_task.rb