rake_fly 2.10.0.pre.2 → 2.10.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +29 -2
- data/Rakefile +67 -45
- data/bin/console +4 -3
- data/lib/rake_fly/kernel_extensions.rb +2 -0
- data/lib/rake_fly/task_sets/authentication.rb +11 -8
- data/lib/rake_fly/task_sets/pipeline.rb +18 -16
- data/lib/rake_fly/task_sets/project.rb +77 -69
- data/lib/rake_fly/task_sets.rb +2 -0
- data/lib/rake_fly/tasks/authentication/ensure.rb +18 -15
- data/lib/rake_fly/tasks/authentication/login.rb +35 -20
- data/lib/rake_fly/tasks/pipeline/destroy.rb +26 -21
- data/lib/rake_fly/tasks/pipeline/get.rb +24 -19
- data/lib/rake_fly/tasks/pipeline/push.rb +12 -10
- data/lib/rake_fly/tasks/pipeline/set.rb +26 -21
- data/lib/rake_fly/tasks/pipeline/unpause.rb +21 -16
- data/lib/rake_fly/tasks.rb +2 -0
- data/lib/rake_fly/version.rb +3 -1
- data/lib/rake_fly.rb +103 -57
- data/rake_fly.gemspec +65 -0
- metadata +70 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18edc1730fc579ae18a1676e8655366c803392ffa70e8b9b0b7df44825cd601c
|
4
|
+
data.tar.gz: 7f018eb6ff6c111238da6d7cf5faccd548aa5f57cbc5d543a15750bd63074681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f89cdc837c90c872038a2f76b8a53f111e706ed4bdede06f1b07568da8bad9678a220f04fb047204605742ac60b9b675b3e8888dc12ac02d75a78abc07bcf75
|
7
|
+
data.tar.gz: 4074759a07ac784256f14772ecf6263547c008b0103f03dab5bffc0b5376ef3f8afcecd148bdc823d1716da0386a880c3c7c1da13acea23f944a986f149ba5a7
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rake_fly (2.10.0.pre.
|
4
|
+
rake_fly (2.10.0.pre.3)
|
5
5
|
concourse.rb (>= 0.4)
|
6
6
|
rake_dependencies (~> 3.1)
|
7
7
|
rake_factory (~> 0.29)
|
@@ -18,6 +18,7 @@ GEM
|
|
18
18
|
tzinfo (~> 2.0)
|
19
19
|
addressable (2.8.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
|
+
ast (2.4.2)
|
21
22
|
colored2 (3.1.2)
|
22
23
|
concourse.rb (0.4.0)
|
23
24
|
dry-schema (~> 0.5)
|
@@ -98,7 +99,11 @@ GEM
|
|
98
99
|
sawyer (~> 0.8.0, >= 0.5.3)
|
99
100
|
open4 (1.3.4)
|
100
101
|
openssl (3.0.0)
|
102
|
+
parallel (1.22.1)
|
103
|
+
parser (3.1.1.0)
|
104
|
+
ast (~> 2.4.1)
|
101
105
|
public_suffix (4.0.6)
|
106
|
+
rainbow (3.1.1)
|
102
107
|
rake (13.0.6)
|
103
108
|
rake_circle_ci (0.9.0)
|
104
109
|
colored2 (~> 3.1)
|
@@ -125,6 +130,8 @@ GEM
|
|
125
130
|
colored2 (~> 3.1)
|
126
131
|
rake_factory (~> 0.23)
|
127
132
|
sshkey (~> 2.0)
|
133
|
+
regexp_parser (2.2.1)
|
134
|
+
rexml (3.2.5)
|
128
135
|
rspec (3.11.0)
|
129
136
|
rspec-core (~> 3.11.0)
|
130
137
|
rspec-expectations (~> 3.11.0)
|
@@ -138,6 +145,22 @@ GEM
|
|
138
145
|
diff-lcs (>= 1.2.0, < 2.0)
|
139
146
|
rspec-support (~> 3.11.0)
|
140
147
|
rspec-support (3.11.0)
|
148
|
+
rubocop (1.26.1)
|
149
|
+
parallel (~> 1.10)
|
150
|
+
parser (>= 3.1.0.0)
|
151
|
+
rainbow (>= 2.2.2, < 4.0)
|
152
|
+
regexp_parser (>= 1.8, < 3.0)
|
153
|
+
rexml
|
154
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
155
|
+
ruby-progressbar (~> 1.7)
|
156
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
157
|
+
rubocop-ast (1.16.0)
|
158
|
+
parser (>= 3.1.1.0)
|
159
|
+
rubocop-rake (0.6.0)
|
160
|
+
rubocop (~> 1.0)
|
161
|
+
rubocop-rspec (2.9.0)
|
162
|
+
rubocop (~> 1.19)
|
163
|
+
ruby-progressbar (1.11.0)
|
141
164
|
ruby2_keywords (0.0.5)
|
142
165
|
ruby_fly (0.37.0)
|
143
166
|
lino (~> 3.0)
|
@@ -157,6 +180,7 @@ GEM
|
|
157
180
|
sshkey (2.0.0)
|
158
181
|
tzinfo (2.0.4)
|
159
182
|
concurrent-ruby (~> 1.0)
|
183
|
+
unicode-display_width (2.1.0)
|
160
184
|
|
161
185
|
PLATFORMS
|
162
186
|
ruby
|
@@ -177,7 +201,10 @@ DEPENDENCIES
|
|
177
201
|
rake_gpg
|
178
202
|
rake_ssh
|
179
203
|
rspec
|
204
|
+
rubocop
|
205
|
+
rubocop-rake
|
206
|
+
rubocop-rspec
|
180
207
|
simplecov
|
181
208
|
|
182
209
|
BUNDLED WITH
|
183
|
-
2.3.
|
210
|
+
2.3.11
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'rake_circle_ci'
|
3
5
|
require 'rake_github'
|
@@ -5,17 +7,20 @@ require 'rake_ssh'
|
|
5
7
|
require 'rake_gpg'
|
6
8
|
require 'securerandom'
|
7
9
|
require 'rspec/core/rake_task'
|
10
|
+
require 'rubocop/rake_task'
|
8
11
|
|
9
|
-
task :
|
10
|
-
|
11
|
-
|
12
|
+
task default: %i[
|
13
|
+
library:fix
|
14
|
+
test:unit
|
15
|
+
]
|
12
16
|
|
13
17
|
namespace :encryption do
|
14
18
|
namespace :passphrase do
|
19
|
+
desc 'Generate encryption passphrase for CI GPG key'
|
15
20
|
task :generate do
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
FileUtils.mkdir_p('config/secrets/ci/')
|
22
|
+
File.write('config/secrets/ci/encryption.passphrase',
|
23
|
+
SecureRandom.base64(36))
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -23,85 +28,102 @@ end
|
|
23
28
|
namespace :keys do
|
24
29
|
namespace :deploy do
|
25
30
|
RakeSSH.define_key_tasks(
|
26
|
-
|
27
|
-
|
31
|
+
path: 'config/secrets/ci/',
|
32
|
+
comment: 'maintainers@infrablocks.io'
|
33
|
+
)
|
28
34
|
end
|
29
35
|
|
30
36
|
namespace :gpg do
|
31
37
|
RakeGPG.define_generate_key_task(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
output_directory: 'config/secrets/ci',
|
39
|
+
name_prefix: 'gpg',
|
40
|
+
owner_name: 'InfraBlocks Maintainers',
|
41
|
+
owner_email: 'maintainers@infrablocks.io',
|
42
|
+
owner_comment: 'rake_fly CI Key'
|
43
|
+
)
|
37
44
|
end
|
38
45
|
end
|
39
46
|
|
47
|
+
RuboCop::RakeTask.new
|
48
|
+
|
49
|
+
namespace :library do
|
50
|
+
desc 'Run all checks of the library'
|
51
|
+
task check: [:rubocop]
|
52
|
+
|
53
|
+
desc 'Attempt to automatically fix issues with the library'
|
54
|
+
task fix: [:'rubocop:auto_correct']
|
55
|
+
end
|
56
|
+
|
57
|
+
namespace :test do
|
58
|
+
RSpec::Core::RakeTask.new(:unit)
|
59
|
+
end
|
60
|
+
|
40
61
|
RakeCircleCI.define_project_tasks(
|
41
|
-
|
42
|
-
|
62
|
+
namespace: :circle_ci,
|
63
|
+
project_slug: 'github/infrablocks/rake_fly'
|
43
64
|
) do |t|
|
44
65
|
circle_ci_config =
|
45
|
-
|
66
|
+
YAML.load_file('config/secrets/circle_ci/config.yaml')
|
46
67
|
|
47
|
-
t.api_token = circle_ci_config[
|
68
|
+
t.api_token = circle_ci_config['circle_ci_api_token']
|
48
69
|
t.environment_variables = {
|
49
|
-
|
50
|
-
|
51
|
-
|
70
|
+
ENCRYPTION_PASSPHRASE:
|
71
|
+
File.read('config/secrets/ci/encryption.passphrase')
|
72
|
+
.chomp
|
52
73
|
}
|
53
74
|
t.checkout_keys = []
|
54
75
|
t.ssh_keys = [
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
76
|
+
{
|
77
|
+
hostname: 'github.com',
|
78
|
+
private_key: File.read('config/secrets/ci/ssh.private')
|
79
|
+
}
|
59
80
|
]
|
60
81
|
end
|
61
82
|
|
62
83
|
RakeGithub.define_repository_tasks(
|
63
|
-
|
64
|
-
|
84
|
+
namespace: :github,
|
85
|
+
repository: 'infrablocks/rake_fly'
|
65
86
|
) do |t, args|
|
66
87
|
github_config =
|
67
|
-
|
88
|
+
YAML.load_file('config/secrets/github/config.yaml')
|
68
89
|
|
69
|
-
t.access_token = github_config[
|
90
|
+
t.access_token = github_config['github_personal_access_token']
|
70
91
|
t.deploy_keys = [
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
92
|
+
{
|
93
|
+
title: 'CircleCI',
|
94
|
+
public_key: File.read('config/secrets/ci/ssh.public')
|
95
|
+
}
|
75
96
|
]
|
76
97
|
t.branch_name = args.branch_name
|
77
98
|
t.commit_message = args.commit_message
|
78
99
|
end
|
79
100
|
|
80
101
|
namespace :pipeline do
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
102
|
+
desc 'Prepare CircleCI Pipeline'
|
103
|
+
task prepare: %i[
|
104
|
+
circle_ci:project:follow
|
105
|
+
circle_ci:env_vars:ensure
|
106
|
+
circle_ci:checkout_keys:ensure
|
107
|
+
circle_ci:ssh_keys:ensure
|
108
|
+
github:deploy_keys:ensure
|
87
109
|
]
|
88
110
|
end
|
89
111
|
|
90
112
|
namespace :version do
|
91
|
-
desc
|
113
|
+
desc 'Bump version for specified type (pre, major, minor, patch)'
|
92
114
|
task :bump, [:type] do |_, args|
|
93
115
|
bump_version_for(args.type)
|
94
116
|
end
|
95
117
|
end
|
96
118
|
|
97
|
-
desc
|
119
|
+
desc 'Release gem'
|
98
120
|
task :release do
|
99
|
-
sh
|
121
|
+
sh 'gem release --tag --push'
|
100
122
|
end
|
101
123
|
|
102
124
|
def bump_version_for(version_type)
|
103
|
-
sh "gem bump --version #{version_type} "
|
104
|
-
|
105
|
-
|
106
|
-
|
125
|
+
sh "gem bump --version #{version_type} " \
|
126
|
+
'&& bundle install ' \
|
127
|
+
'&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
|
128
|
+
'&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
|
107
129
|
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake_fly'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "rake_fly"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
|
3
5
|
require_relative '../tasks/authentication/login'
|
@@ -14,12 +16,13 @@ module RakeFly
|
|
14
16
|
parameter :concourse_url, required: true
|
15
17
|
parameter :team, default: 'main'
|
16
18
|
|
17
|
-
parameter :backend,
|
19
|
+
parameter :backend,
|
20
|
+
default: RakeFly::Tasks::Authentication::Login::ApiBackend
|
18
21
|
parameter :username
|
19
22
|
parameter :password
|
20
23
|
|
21
24
|
parameter :home_directory,
|
22
|
-
|
25
|
+
default: RakeFactory::DynamicValue.new { |_| ENV['HOME'] }
|
23
26
|
|
24
27
|
parameter :login_task_name, default: :login
|
25
28
|
parameter :ensure_task_name, default: :ensure
|
@@ -27,13 +30,13 @@ module RakeFly
|
|
27
30
|
parameter :fly_ensure_task_name, default: :'fly:ensure'
|
28
31
|
|
29
32
|
task Tasks::Authentication::Login,
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
34
|
+
ts.login_task_name
|
35
|
+
}
|
33
36
|
task Tasks::Authentication::Ensure,
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
38
|
+
ts.ensure_task_name
|
39
|
+
}
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
|
3
5
|
require_relative '../tasks/pipeline/get'
|
@@ -22,7 +24,7 @@ module RakeFly
|
|
22
24
|
parameter :non_interactive
|
23
25
|
|
24
26
|
parameter :home_directory,
|
25
|
-
|
27
|
+
default: RakeFactory::DynamicValue.new { |_| ENV['HOME'] }
|
26
28
|
|
27
29
|
parameter :get_task_name, default: :get
|
28
30
|
parameter :set_task_name, default: :set
|
@@ -33,25 +35,25 @@ module RakeFly
|
|
33
35
|
parameter :fly_ensure_task_name, default: :'fly:ensure'
|
34
36
|
|
35
37
|
task Tasks::Pipeline::Get,
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
39
|
+
ts.get_task_name
|
40
|
+
}
|
39
41
|
task Tasks::Pipeline::Set,
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
43
|
+
ts.set_task_name
|
44
|
+
}
|
43
45
|
task Tasks::Pipeline::Unpause,
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
47
|
+
ts.unpause_task_name
|
48
|
+
}
|
47
49
|
task Tasks::Pipeline::Push,
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
51
|
+
ts.push_task_name
|
52
|
+
}
|
51
53
|
task Tasks::Pipeline::Destroy,
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
55
|
+
ts.destroy_task_name
|
56
|
+
}
|
55
57
|
end
|
56
58
|
end
|
57
59
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake_factory'
|
2
4
|
|
3
5
|
require_relative '../tasks/authentication/login'
|
@@ -9,6 +11,7 @@ require_relative '../tasks/pipeline/push'
|
|
9
11
|
|
10
12
|
module RakeFly
|
11
13
|
module TaskSets
|
14
|
+
# rubocop:disable Metrics/ClassLength
|
12
15
|
class Project < RakeFactory::TaskSet
|
13
16
|
prepend RakeFactory::Namespaceable
|
14
17
|
|
@@ -17,7 +20,8 @@ module RakeFly
|
|
17
20
|
parameter :concourse_url, required: true
|
18
21
|
parameter :team, default: 'main'
|
19
22
|
|
20
|
-
parameter :backend,
|
23
|
+
parameter :backend,
|
24
|
+
default: RakeFly::Tasks::Authentication::Login::ApiBackend
|
21
25
|
parameter :username
|
22
26
|
parameter :password
|
23
27
|
|
@@ -29,10 +33,10 @@ module RakeFly
|
|
29
33
|
parameter :non_interactive
|
30
34
|
|
31
35
|
parameter :target,
|
32
|
-
|
36
|
+
default: RakeFactory::DynamicValue.new { |t| t.team }
|
33
37
|
|
34
38
|
parameter :home_directory,
|
35
|
-
|
39
|
+
default: RakeFactory::DynamicValue.new { |_| ENV['HOME'] }
|
36
40
|
|
37
41
|
parameter :authentication_namespace, default: :authentication
|
38
42
|
parameter :authentication_login_task_name, default: :login
|
@@ -48,89 +52,93 @@ module RakeFly
|
|
48
52
|
parameter :fly_ensure_task_name, default: :'fly:ensure'
|
49
53
|
|
50
54
|
task Tasks::Authentication::Login,
|
51
|
-
|
52
|
-
|
53
|
-
|
55
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
56
|
+
ts.authentication_login_task_name
|
57
|
+
}
|
54
58
|
task Tasks::Authentication::Ensure,
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
60
|
+
ts.authentication_ensure_task_name
|
61
|
+
},
|
62
|
+
login_task_name: RakeFactory::DynamicValue.new { |ts|
|
63
|
+
ts.authentication_login_task_name
|
64
|
+
}
|
61
65
|
|
62
66
|
task Tasks::Pipeline::Get,
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
68
|
+
ts.pipeline_get_task_name
|
69
|
+
},
|
70
|
+
authentication_ensure_task_name: RakeFactory::DynamicValue.new { |ts|
|
71
|
+
"#{ts.authentication_namespace}:"\
|
72
|
+
"#{ts.authentication_ensure_task_name}"
|
73
|
+
.to_sym
|
74
|
+
}
|
71
75
|
task Tasks::Pipeline::Set,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
76
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
77
|
+
ts.pipeline_set_task_name
|
78
|
+
},
|
79
|
+
authentication_ensure_task_name: RakeFactory::DynamicValue.new { |ts|
|
80
|
+
"#{ts.authentication_namespace}:"\
|
81
|
+
"#{ts.authentication_ensure_task_name}"
|
82
|
+
.to_sym
|
83
|
+
}
|
80
84
|
task Tasks::Pipeline::Unpause,
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
85
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
86
|
+
ts.pipeline_unpause_task_name
|
87
|
+
},
|
88
|
+
authentication_ensure_task_name: RakeFactory::DynamicValue.new { |ts|
|
89
|
+
"#{ts.authentication_namespace}:"\
|
90
|
+
"#{ts.authentication_ensure_task_name}"
|
91
|
+
.to_sym
|
92
|
+
}
|
89
93
|
task Tasks::Pipeline::Push,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
94
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
95
|
+
ts.pipeline_push_task_name
|
96
|
+
},
|
97
|
+
get_task_name: RakeFactory::DynamicValue.new { |ts|
|
98
|
+
ts.pipeline_get_task_name
|
99
|
+
},
|
100
|
+
set_task_name: RakeFactory::DynamicValue.new { |ts|
|
101
|
+
ts.pipeline_set_task_name
|
102
|
+
},
|
103
|
+
unpause_task_name: RakeFactory::DynamicValue.new { |ts|
|
104
|
+
ts.pipeline_unpause_task_name
|
105
|
+
}
|
102
106
|
task Tasks::Pipeline::Destroy,
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
name: RakeFactory::DynamicValue.new { |ts|
|
108
|
+
ts.pipeline_destroy_task_name
|
109
|
+
},
|
110
|
+
authentication_ensure_task_name: RakeFactory::DynamicValue.new { |ts|
|
111
|
+
"#{ts.authentication_namespace}:"\
|
112
|
+
"#{ts.authentication_ensure_task_name}"
|
113
|
+
.to_sym
|
114
|
+
}
|
111
115
|
|
112
116
|
def define_on(application)
|
113
117
|
around_define(application) do
|
114
118
|
self.class.tasks.each do |task_definition|
|
115
|
-
|
116
|
-
ns = case task_class
|
117
|
-
when /Pipeline/
|
118
|
-
pipeline_namespace
|
119
|
-
when /Authentication/
|
120
|
-
authentication_namespace
|
121
|
-
else
|
122
|
-
raise StandardError.new(
|
123
|
-
"Unexpected task definition: #{task_class}.")
|
124
|
-
end
|
119
|
+
namespace = resolve_namespace(task_definition)
|
125
120
|
|
126
|
-
application.in_namespace(
|
121
|
+
application.in_namespace(namespace) do
|
127
122
|
task_definition
|
128
|
-
|
129
|
-
|
123
|
+
.for_task_set(self)
|
124
|
+
.define_on(application)
|
130
125
|
end
|
131
126
|
end
|
132
127
|
end
|
133
128
|
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def resolve_namespace(task_definition)
|
133
|
+
case task_definition.klass.to_s
|
134
|
+
when /Pipeline/ then pipeline_namespace
|
135
|
+
when /Authentication/ then authentication_namespace
|
136
|
+
else
|
137
|
+
raise StandardError,
|
138
|
+
"Unexpected task definition: #{task_definition.klass}."
|
139
|
+
end
|
140
|
+
end
|
134
141
|
end
|
142
|
+
# rubocop:enable Metrics/ClassLength
|
135
143
|
end
|
136
144
|
end
|
data/lib/rake_fly/task_sets.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'ruby_fly'
|
2
4
|
require 'rake_factory'
|
3
5
|
require 'concourse'
|
@@ -7,39 +9,40 @@ module RakeFly
|
|
7
9
|
module Authentication
|
8
10
|
class Ensure < RakeFactory::Task
|
9
11
|
default_name :ensure
|
10
|
-
default_prerequisites
|
12
|
+
default_prerequisites(RakeFactory::DynamicValue.new do |t|
|
11
13
|
[t.fly_ensure_task_name]
|
12
|
-
|
13
|
-
default_description
|
14
|
+
end)
|
15
|
+
default_description(RakeFactory::DynamicValue.new do |t|
|
14
16
|
target = t.target || '<derived>'
|
15
17
|
|
16
18
|
"Ensure logged in for target #{target}"
|
17
|
-
|
19
|
+
end)
|
18
20
|
|
19
21
|
parameter :target, required: true
|
20
22
|
|
21
23
|
parameter :home_directory,
|
22
|
-
|
24
|
+
default: RakeFactory::DynamicValue.new { |_| ENV['HOME'] }
|
23
25
|
|
24
|
-
parameter :login_task_name, :
|
26
|
+
parameter :login_task_name, default: :login
|
25
27
|
|
26
|
-
parameter :fly_ensure_task_name, :
|
28
|
+
parameter :fly_ensure_task_name, default: :'fly:ensure'
|
27
29
|
|
28
30
|
action do |t, args|
|
29
|
-
puts
|
31
|
+
$stdout.puts("Ensuring target #{t.target} is logged in...")
|
30
32
|
status = RubyFly.status(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
target: t.target,
|
34
|
+
environment: {
|
35
|
+
'HOME' => t.home_directory
|
36
|
+
}
|
37
|
+
)
|
35
38
|
if status == :logged_in
|
36
|
-
puts
|
39
|
+
$stdout.puts('Already logged in. Continuing...')
|
37
40
|
else
|
38
|
-
puts
|
41
|
+
$stdout.puts('Not logged in. Logging in...')
|
39
42
|
t.application[t.login_task_name, t.scope].invoke(*args)
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
end
|
44
47
|
end
|
45
|
-
end
|
48
|
+
end
|