module RakeFly

Constants

ARTIFACT_FORMAT_CHANGE_VERSION
VERSION

Public Class Methods

define_authentication_tasks(opts = {}, &block) click to toggle source
# File lib/rake_fly.rb, line 50
def self.define_authentication_tasks(opts = {}, &block)
  RakeFly::TaskSets::Authentication.define(opts, &block)
end
define_installation_tasks(opts = {}) click to toggle source
# File lib/rake_fly.rb, line 13
def self.define_installation_tasks(opts = {})
  namespace = opts[:namespace] || :fly
  version = opts[:version] || '2.7.0'
  path = opts[:path] || File.join('vendor', 'fly')

  type = self.type(version)
  uri_template = self.uri_template(version)
  file_name_template = self.file_name_template(version)
  new_format = self.new_format?(version)

  task_set_opts = {
      namespace: namespace,
      dependency: 'fly',
      version: version,
      path: path,
      type: type,
      os_ids: {mac: 'darwin', linux: 'linux'},
      uri_template: uri_template,
      file_name_template: file_name_template,
      needs_fetch: lambda { |t|
        fly_binary = File.join(t.path, t.binary_directory, 'fly')

        !(File.exist?(fly_binary) && RubyFly.version == version)
      }}

  unless new_format
    task_set_opts[:source_binary_name_template] = "fly_<%= @os_id %>_amd64"
    task_set_opts[:target_binary_name_template] = "fly"
  end

  RubyFly.configure do |c|
    c.binary = File.join(path, 'bin', 'fly')
  end

  RakeDependencies::TaskSets::All.define(task_set_opts)
end
define_pipeline_tasks(opts = {}, &block) click to toggle source
# File lib/rake_fly.rb, line 54
def self.define_pipeline_tasks(opts = {}, &block)
  RakeFly::TaskSets::Pipeline.define(opts, &block)
end
define_project_tasks(opts = {}, &block) click to toggle source
# File lib/rake_fly.rb, line 58
def self.define_project_tasks(opts = {}, &block)
  RakeFly::TaskSets::Project.define(opts, &block)
end

Private Class Methods

file_name_template(version) click to toggle source
# File lib/rake_fly.rb, line 88
def self.file_name_template(version)
  if new_format?(version)
    "fly-<%= @version %>-<%= @os_id %>-amd64<%= @ext %>"
  else
    "fly_<%= @os_id %>_amd64"
  end
end
new_format?(version) click to toggle source
# File lib/rake_fly.rb, line 64
def self.new_format?(version)
  Semantic::Version.new(version) >=
      Semantic::Version.new(ARTIFACT_FORMAT_CHANGE_VERSION)
end
type(version) click to toggle source
# File lib/rake_fly.rb, line 69
def self.type(version)
  if self.new_format?(version)
    :tgz
  else
    :uncompressed
  end
end
uri_template(version) click to toggle source
# File lib/rake_fly.rb, line 77
def self.uri_template(version)
  if new_format?(version)
    "https://github.com/concourse/concourse/releases/download" +
        "/v<%= @version %>" +
        "/fly-<%= @version %>-<%= @os_id %>-amd64<%= @ext %>"
  else
    "https://github.com/concourse/concourse/releases/" +
        "download/v<%= @version %>/fly_<%= @os_id %>_amd64"
  end
end