Module: RakeFly

Includes:
RubyFly
Defined in:
lib/rake_fly.rb,
lib/rake_fly/version.rb,
lib/rake_fly/task_sets/pipeline.rb,
lib/rake_fly/tasks/pipeline/get.rb,
lib/rake_fly/tasks/pipeline/set.rb,
lib/rake_fly/tasks/pipeline/push.rb,
lib/rake_fly/tasks/pipeline/unpause.rb,
lib/rake_fly/task_sets/authentication.rb,
lib/rake_fly/tasks/authentication/login.rb,
lib/rake_fly/tasks/authentication/ensure.rb

Defined Under Namespace

Modules: TaskSets, Tasks

Constant Summary collapse

ARTIFACT_FORMAT_CHANGE_VERSION =
'5.0.0'
VERSION =
'2.3.0'

Class Method Summary collapse

Class Method Details

.define_authentication_tasks(opts = {}, &block) ⇒ Object



54
55
56
# File 'lib/rake_fly.rb', line 54

def self.define_authentication_tasks(opts = {}, &block)
  RakeFly::TaskSets::Authentication.define(opts, &block)
end

.define_installation_tasks(opts = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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) ⇒ Object



50
51
52
# File 'lib/rake_fly.rb', line 50

def self.define_pipeline_tasks(opts = {}, &block)
  RakeFly::TaskSets::Pipeline.define(opts, &block)
end

.file_name_template(version) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/rake_fly.rb', line 84

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) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
63
# File 'lib/rake_fly.rb', line 60

def self.new_format?(version)
  Semantic::Version.new(version) >=
      Semantic::Version.new(ARTIFACT_FORMAT_CHANGE_VERSION)
end

.type(version) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/rake_fly.rb', line 65

def self.type(version)
  if self.new_format?(version)
    :tgz
  else
    :uncompressed
  end
end

.uri_template(version) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/rake_fly.rb', line 73

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