ruby_fly 0.38.0.pre.2 → 0.38.0.pre.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 595a106b324d1d102c4d8d0e4267ba1fdefdd014fc8c1e49c6d5b7df32976d18
4
- data.tar.gz: f086df5ec4b0355482eb95d30773b217e0288ddaae92a7f564212b174525d541
3
+ metadata.gz: 8a923ce7e879b4342da242cfa3dc805bd8aa14fced11105bdb78d749a59e9b37
4
+ data.tar.gz: cb492bc1bd6aabd920dbfa84cc4eeb3dbee36ff1fc14b254fbcb0e7a879bdcec
5
5
  SHA512:
6
- metadata.gz: 120b68ce0f25b47b4cbcab6a53db14f3c7d2d06e0dcc43f1654803e14f2188a3808a14e98e476698c120fa045df9e57ebcd1830ecfa05d69817b82e8c54008ce
7
- data.tar.gz: d43795d459fb4cc9ef23de3cff44604529983f0c56f16819780997494a4be6d93158f8c6d933bdd19525c53c86d81d430a9ccb5963bafcc71b08a788f412df35
6
+ metadata.gz: 8298eeee2b9bae869f09da25cb3332f000a82ee736871e667e9fc47653197d1636f60075ada52fd4840fc2b2af607c87c30c89f90d5673d3a429d64cc66b9d51
7
+ data.tar.gz: ec8a3662cdb182d9364356b25da3e2c0cc65db3719f71e9b8b373633969d9c1fed52c766c2b2f8ed590c5a5d8db587d2fc00a3f4cf353c072603f0ad46c38eff
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in ruby_fly.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_fly (0.38.0.pre.2)
4
+ ruby_fly (0.38.0.pre.3)
5
5
  lino (~> 3.0)
6
6
 
7
7
  GEM
@@ -14,9 +14,11 @@ GEM
14
14
  tzinfo (~> 2.0)
15
15
  addressable (2.8.0)
16
16
  public_suffix (>= 2.0.2, < 5.0)
17
+ ast (2.4.2)
17
18
  colored2 (3.1.2)
18
19
  concurrent-ruby (1.1.9)
19
20
  diff-lcs (1.5.0)
21
+ docile (1.4.0)
20
22
  excon (0.92.0)
21
23
  fakefs (1.4.1)
22
24
  faker (2.20.0)
@@ -58,7 +60,11 @@ GEM
58
60
  faraday (>= 0.9)
59
61
  sawyer (~> 0.8.0, >= 0.5.3)
60
62
  open4 (1.3.4)
63
+ parallel (1.22.1)
64
+ parser (3.1.1.0)
65
+ ast (~> 2.4.1)
61
66
  public_suffix (4.0.6)
67
+ rainbow (3.1.1)
62
68
  rake (13.0.6)
63
69
  rake_circle_ci (0.9.0)
64
70
  colored2 (~> 3.1)
@@ -80,6 +86,8 @@ GEM
80
86
  colored2 (~> 3.1)
81
87
  rake_factory (~> 0.23)
82
88
  sshkey (~> 2.0)
89
+ regexp_parser (2.2.1)
90
+ rexml (3.2.5)
83
91
  rspec (3.11.0)
84
92
  rspec-core (~> 3.11.0)
85
93
  rspec-expectations (~> 3.11.0)
@@ -93,15 +101,38 @@ GEM
93
101
  diff-lcs (>= 1.2.0, < 2.0)
94
102
  rspec-support (~> 3.11.0)
95
103
  rspec-support (3.11.0)
104
+ rubocop (1.27.0)
105
+ parallel (~> 1.10)
106
+ parser (>= 3.1.0.0)
107
+ rainbow (>= 2.2.2, < 4.0)
108
+ regexp_parser (>= 1.8, < 3.0)
109
+ rexml
110
+ rubocop-ast (>= 1.16.0, < 2.0)
111
+ ruby-progressbar (~> 1.7)
112
+ unicode-display_width (>= 1.4.0, < 3.0)
113
+ rubocop-ast (1.16.0)
114
+ parser (>= 3.1.1.0)
115
+ rubocop-rake (0.6.0)
116
+ rubocop (~> 1.0)
117
+ rubocop-rspec (2.9.0)
118
+ rubocop (~> 1.19)
119
+ ruby-progressbar (1.11.0)
96
120
  ruby2_keywords (0.0.5)
97
121
  ruby_gpg2 (0.8.0)
98
122
  lino (>= 1.5)
99
123
  sawyer (0.8.2)
100
124
  addressable (>= 2.3.5)
101
125
  faraday (> 0.8, < 2.0)
126
+ simplecov (0.21.2)
127
+ docile (~> 1.1)
128
+ simplecov-html (~> 0.11)
129
+ simplecov_json_formatter (~> 0.1)
130
+ simplecov-html (0.12.3)
131
+ simplecov_json_formatter (0.1.4)
102
132
  sshkey (2.0.0)
103
133
  tzinfo (2.0.4)
104
134
  concurrent-ruby (~> 1.0)
135
+ unicode-display_width (2.1.0)
105
136
 
106
137
  PLATFORMS
107
138
  ruby
@@ -117,7 +148,11 @@ DEPENDENCIES
117
148
  rake_gpg
118
149
  rake_ssh
119
150
  rspec
151
+ rubocop
152
+ rubocop-rake
153
+ rubocop-rspec
120
154
  ruby_fly!
155
+ simplecov
121
156
 
122
157
  BUNDLED WITH
123
- 2.3.9
158
+ 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,26 @@ 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 :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
+ task default: %i[
13
+ library:fix
14
+ test:unit
15
+ ]
12
16
 
13
17
  namespace :encryption do
18
+ namespace :directory do
19
+ desc 'Ensure CI secrets directory exists.'
20
+ task :ensure do
21
+ FileUtils.mkdir_p('config/secrets/ci')
22
+ end
23
+ end
24
+
14
25
  namespace :passphrase do
15
- task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
26
+ desc 'Generate encryption passphrase used by CI.'
27
+ task generate: ['directory:ensure'] do
28
+ File.write('config/secrets/ci/encryption.passphrase',
29
+ SecureRandom.base64(36))
19
30
  end
20
31
  end
21
32
  end
@@ -23,85 +34,111 @@ end
23
34
  namespace :keys do
24
35
  namespace :deploy do
25
36
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
37
+ path: 'config/secrets/ci/',
38
+ comment: 'maintainers@infrablocks.io'
39
+ )
28
40
  end
29
41
 
30
42
  namespace :gpg do
31
43
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'ruby_fly CI Key')
44
+ output_directory: 'config/secrets/ci',
45
+ name_prefix: 'gpg',
46
+ owner_name: 'InfraBlocks Maintainers',
47
+ owner_email: 'maintainers@infrablocks.io',
48
+ owner_comment: 'ruby_fly CI Key'
49
+ )
37
50
  end
38
51
  end
39
52
 
53
+ namespace :secrets do
54
+ desc 'Regenerate all generatable secrets.'
55
+ task regenerate: %w[
56
+ encryption:passphrase:generate
57
+ keys:deploy:generate
58
+ keys:gpg:generate
59
+ ]
60
+ end
61
+
62
+ RuboCop::RakeTask.new
63
+
64
+ namespace :library do
65
+ desc 'Run all checks of the library'
66
+ task check: [:rubocop]
67
+
68
+ desc 'Attempt to automatically fix issues with the library'
69
+ task fix: [:'rubocop:auto_correct']
70
+ end
71
+
72
+ namespace :test do
73
+ RSpec::Core::RakeTask.new(:unit)
74
+ end
75
+
40
76
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/ruby_fly'
77
+ namespace: :circle_ci,
78
+ project_slug: 'github/infrablocks/ruby_fly'
43
79
  ) do |t|
44
80
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
81
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
82
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
83
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
84
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
85
+ ENCRYPTION_PASSPHRASE:
86
+ File.read('config/secrets/ci/encryption.passphrase')
87
+ .chomp
52
88
  }
53
89
  t.checkout_keys = []
54
90
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
91
+ {
92
+ hostname: 'github.com',
93
+ private_key: File.read('config/secrets/ci/ssh.private')
94
+ }
59
95
  ]
60
96
  end
61
97
 
62
98
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/ruby_fly',
99
+ namespace: :github,
100
+ repository: 'infrablocks/ruby_fly'
65
101
  ) do |t, args|
66
102
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
103
+ YAML.load_file('config/secrets/github/config.yaml')
68
104
 
69
- t.access_token = github_config["github_personal_access_token"]
105
+ t.access_token = github_config['github_personal_access_token']
70
106
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
107
+ {
108
+ title: 'CircleCI',
109
+ public_key: File.read('config/secrets/ci/ssh.public')
110
+ }
75
111
  ]
76
112
  t.branch_name = args.branch_name
77
113
  t.commit_message = args.commit_message
78
114
  end
79
115
 
80
116
  namespace :pipeline do
81
- task :prepare => [
82
- :'circle_ci:project:follow',
83
- :'circle_ci:env_vars:ensure',
84
- :'circle_ci:checkout_keys:ensure',
85
- :'circle_ci:ssh_keys:ensure',
86
- :'github:deploy_keys:ensure'
117
+ desc 'Prepare CircleCI Pipeline'
118
+ task prepare: %i[
119
+ circle_ci:project:follow
120
+ circle_ci:env_vars:ensure
121
+ circle_ci:checkout_keys:ensure
122
+ circle_ci:ssh_keys:ensure
123
+ github:deploy_keys:ensure
87
124
  ]
88
125
  end
89
126
 
90
127
  namespace :version do
91
- desc "Bump version for specified type (pre, major, minor, patch)"
128
+ desc 'Bump version for specified type (pre, major, minor, patch)'
92
129
  task :bump, [:type] do |_, args|
93
130
  bump_version_for(args.type)
94
131
  end
95
132
  end
96
133
 
97
- desc "Release gem"
134
+ desc 'Release gem'
98
135
  task :release do
99
- sh "gem release --tag --push"
136
+ sh 'gem release --tag --push'
100
137
  end
101
138
 
102
139
  def bump_version_for(version_type)
103
- sh "gem bump --version #{version_type} " +
104
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
140
+ sh "gem bump --version #{version_type} " \
141
+ '&& bundle install ' \
142
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
143
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
107
144
  end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "ruby_fly"
4
+ require 'bundler/setup'
5
+ require 'ruby_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 "ruby_fly"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
 
3
5
  module RubyFly
@@ -13,39 +15,32 @@ module RubyFly
13
15
  end
14
16
 
15
17
  def execute(opts = {})
16
- builder = instantiate_builder
17
-
18
18
  do_before(opts)
19
19
  do_around(opts) do |new_opts|
20
- configure_command(builder, new_opts)
21
- .build
22
- .execute(
23
- stdin: stdin,
24
- stdout: stdout,
25
- stderr: stderr)
20
+ configure_command(instantiate_builder, new_opts)
21
+ .build
22
+ .execute(stdin: stdin, stdout: stdout, stderr: stderr)
26
23
  end
27
24
  do_after(opts)
28
25
  end
29
26
 
30
27
  def instantiate_builder
31
28
  Lino::CommandLineBuilder
32
- .for_command(binary)
33
- .with_option_separator('=')
29
+ .for_command(binary)
30
+ .with_option_separator('=')
34
31
  end
35
32
 
36
- def do_before(opts)
37
- end
33
+ def do_before(opts); end
38
34
 
39
35
  def do_around(opts, &block)
40
36
  block.call(opts)
41
37
  end
42
38
 
43
- def configure_command(builder, opts)
39
+ def configure_command(builder, _opts)
44
40
  builder
45
41
  end
46
42
 
47
- def do_after(opts)
48
- end
43
+ def do_after(opts); end
49
44
  end
50
45
  end
51
- end
46
+ end
@@ -1,41 +1,53 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
  require_relative 'base'
3
5
  require_relative 'mixins/environment'
6
+ require_relative 'mixins/required_params'
4
7
 
5
8
  module RubyFly
6
9
  module Commands
7
10
  class DestroyPipeline < Base
8
11
  include Mixins::Environment
12
+ include Mixins::RequiredParams
9
13
 
10
14
  def configure_command(builder, opts)
11
15
  builder = super(builder, opts)
16
+ builder
17
+ .with_subcommand('destroy-pipeline') do |sub|
18
+ sub = with_target(sub, opts[:target])
19
+ sub = with_pipeline(sub, opts[:pipeline])
20
+ sub = with_team(sub, opts[:team])
21
+ sub = with_non_interactive(sub, opts[:non_interactive])
22
+ sub
23
+ end
24
+ end
12
25
 
13
- missing_params = [
14
- :target,
15
- :pipeline
16
- ].select { |param| opts[param].nil? }
26
+ private
17
27
 
18
- unless missing_params.empty?
19
- description = missing_params.map { |p| "'#{p}'" }.join(', ')
20
- raise(
21
- ArgumentError,
22
- "Error: #{description} required but not provided.")
23
- end
28
+ def required_params
29
+ %i[target pipeline]
30
+ end
31
+
32
+ def with_target(sub, target)
33
+ sub.with_option('-t', target)
34
+ end
35
+
36
+ def with_pipeline(sub, pipeline)
37
+ sub.with_option('-p', pipeline)
38
+ end
24
39
 
25
- target = opts[:target]
26
- pipeline = opts[:pipeline]
27
- non_interactive = opts[:non_interactive]
28
- team = opts[:team]
40
+ def with_team(sub, team)
41
+ return sub unless team
29
42
 
30
- builder
31
- .with_subcommand('destroy-pipeline') do |sub|
32
- sub = sub.with_option('-t', target)
33
- sub = sub.with_option('-p', pipeline)
34
- sub = sub.with_option('--team', team) if team
35
- sub = sub.with_flag('-n') if non_interactive
36
- sub
37
- end
43
+ sub.with_option('--team', team)
44
+ end
45
+
46
+ def with_non_interactive(sub, non_interactive)
47
+ return sub unless non_interactive
48
+
49
+ sub.with_flag('-n')
38
50
  end
39
51
  end
40
52
  end
41
- end
53
+ end
@@ -1,37 +1,39 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
  require_relative 'base'
3
5
  require_relative 'mixins/environment'
6
+ require_relative 'mixins/required_params'
4
7
 
5
8
  module RubyFly
6
9
  module Commands
7
10
  class GetPipeline < Base
8
11
  include Mixins::Environment
12
+ include Mixins::RequiredParams
9
13
 
10
14
  def configure_command(builder, opts)
11
15
  builder = super(builder, opts)
16
+ builder
17
+ .with_subcommand('get-pipeline') do |sub|
18
+ sub = with_target(sub, opts[:target])
19
+ sub = with_pipeline(sub, opts[:pipeline])
20
+ sub
21
+ end
22
+ end
12
23
 
13
- missing_params = [
14
- :target,
15
- :pipeline
16
- ].select { |param| opts[param].nil? }
24
+ private
17
25
 
18
- unless missing_params.empty?
19
- description = missing_params.map { |p| "'#{p}'" }.join(', ')
20
- raise(
21
- ArgumentError,
22
- "Error: #{description} required but not provided.")
23
- end
26
+ def required_params
27
+ %i[target pipeline]
28
+ end
24
29
 
25
- target = opts[:target]
26
- pipeline = opts[:pipeline]
30
+ def with_target(sub, target)
31
+ sub.with_option('-t', target)
32
+ end
27
33
 
28
- builder
29
- .with_subcommand('get-pipeline') do |sub|
30
- sub = sub.with_option('-t', target)
31
- sub = sub.with_option('-p', pipeline)
32
- sub
33
- end
34
+ def with_pipeline(sub, pipeline)
35
+ sub.with_option('-p', pipeline)
34
36
  end
35
37
  end
36
38
  end
37
- end
39
+ end
@@ -1,42 +1,62 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'lino'
2
4
  require_relative 'base'
3
5
  require_relative 'mixins/environment'
6
+ require_relative 'mixins/required_params'
4
7
 
5
8
  module RubyFly
6
9
  module Commands
7
10
  class Login < Base
8
11
  include Mixins::Environment
12
+ include Mixins::RequiredParams
9
13
 
10
14
  def configure_command(builder, opts)
11
15
  builder = super(builder, opts)
12
-
13
- missing_params = [
14
- :target
15
- ].select { |param| opts[param].nil? }
16
-
17
- unless missing_params.empty?
18
- description = missing_params.map { |p| "'#{p}'" }.join(', ')
19
- raise(
20
- ArgumentError,
21
- "Error: #{description} required but not provided.")
22
- end
23
-
24
- target = opts[:target]
25
- concourse_url = opts[:concourse_url]
26
- username = opts[:username]
27
- password = opts[:password]
28
- team = opts[:team]
29
-
30
16
  builder
31
17
  .with_subcommand('login') do |sub|
32
- sub = sub.with_option('-t', target)
33
- sub = sub.with_option('-c', concourse_url) if concourse_url
34
- sub = sub.with_option('-u', username) if username
35
- sub = sub.with_option('-p', password) if password
36
- sub = sub.with_option('-n', team) if team
18
+ sub = with_target(sub, opts[:target])
19
+ sub = with_concourse_url(sub, opts[:concourse_url])
20
+ sub = with_username(sub, opts[:username])
21
+ sub = with_password(sub, opts[:password])
22
+ sub = with_team(sub, opts[:team])
37
23
  sub
38
24
  end
39
25
  end
26
+
27
+ private
28
+
29
+ def required_params
30
+ %i[target]
31
+ end
32
+
33
+ def with_target(builder, target)
34
+ builder.with_option('-t', target)
35
+ end
36
+
37
+ def with_concourse_url(builder, concourse_url)
38
+ return builder unless concourse_url
39
+
40
+ builder.with_option('-c', concourse_url)
41
+ end
42
+
43
+ def with_username(builder, username)
44
+ return builder unless username
45
+
46
+ builder.with_option('-u', username)
47
+ end
48
+
49
+ def with_password(builder, password)
50
+ return builder unless password
51
+
52
+ builder.with_option('-p', password)
53
+ end
54
+
55
+ def with_team(builder, team)
56
+ return builder unless team
57
+
58
+ builder.with_option('-n', team)
59
+ end
40
60
  end
41
61
  end
42
- end
62
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RubyFly
2
4
  module Commands
3
5
  module Mixins
@@ -16,14 +18,14 @@ module RubyFly
16
18
  builder = super(builder, opts)
17
19
  environment = opts[:environment] || @environment
18
20
  if environment
19
- builder = environment.to_a
20
- .inject(builder) do |b, environment_variable|
21
- b.with_environment_variable(*environment_variable)
22
- end
21
+ builder =
22
+ environment.to_a.inject(builder) do |b, environment_variable|
23
+ b.with_environment_variable(*environment_variable)
24
+ end
23
25
  end
24
26
  builder
25
27
  end
26
28
  end
27
29
  end
28
30
  end
29
- end
31
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyFly
4
+ module Commands
5
+ module Mixins
6
+ module RequiredParams
7
+ def configure_command(builder, opts)
8
+ assert_required_params(opts)
9
+ super(builder, opts)
10
+ end
11
+
12
+ def required_params
13
+ %i[]
14
+ end
15
+
16
+ private
17
+
18
+ def missing_params(opts)
19
+ required_params.select { |param| opts[param].nil? }
20
+ end
21
+
22
+ def assert_required_params(opts)
23
+ missing_params = missing_params(opts)
24
+ return if missing_params.empty?
25
+
26
+ description = missing_params.map { |p| "'#{p}'" }.join(', ')
27
+ raise(
28
+ ArgumentError,
29
+ "Error: #{description} required but not provided."
30
+ )
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end