rake_easy_rsa 0.12.0.pre.1 → 0.12.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43fc9d2c9c47bbd820b00f196e1385398a0bab066f77ff376bb4f7f289d229d1
4
- data.tar.gz: cf30ebcc14bde0fa3908802f85f2e064074d2159fe2f448d8ab76e8dd0bc6592
3
+ metadata.gz: 9763f394954b34abfd9ed44b6b776855071e36cd62961b293868644182c800b7
4
+ data.tar.gz: 1b5d7a84b02defd5aa6d7314823166687def68a68ffa7efd4c0e9ea8db81b8aa
5
5
  SHA512:
6
- metadata.gz: 5bb7e94d780a8ffc6f1af6c2556243f408ed38f75ce48369823c6c22997da7bd805f84aedf6fa3ec9b499184241ff553b529c0667c231e10966b01c06c18d306
7
- data.tar.gz: 9ba10d75414f33399b69bc982fcdf1dfbc5e172f446247a1aff9375eb56ac8b21614d0a7f5bab0abc9bfdaaf8cb852a048f6d77151dc9ae94b824122a87be3b7
6
+ metadata.gz: 49badc6d60381ff091da95f44d95cdbe2b01aa01f3242779e8e54d608fbd2f3743252f11469c48f3e96d963b6d7c374ac6aba23ca2d9e1ae2ff49bb5cdbb93d1
7
+ data.tar.gz: de2a4199d67c7c0dfc4b5dd3cd27d0e1920db22677de6742ac798d3c72b41f29680de535ac4e91b819eb21fcdd096a1fccf03fde24b70e38d3ca12698d22c91f
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 rake_fly.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_easy_rsa (0.12.0.pre.1)
4
+ rake_easy_rsa (0.12.0.pre.2)
5
5
  rake_dependencies (~> 3.1)
6
6
  rake_factory (~> 0.23)
7
7
  ruby_easy_rsa (~> 0.7)
@@ -17,11 +17,12 @@ GEM
17
17
  tzinfo (~> 2.0)
18
18
  addressable (2.8.0)
19
19
  public_suffix (>= 2.0.2, < 5.0)
20
+ ast (2.4.2)
20
21
  colored2 (3.1.2)
21
- concurrent-ruby (1.1.9)
22
+ concurrent-ruby (1.1.10)
22
23
  diff-lcs (1.5.0)
23
24
  docile (1.4.0)
24
- excon (0.92.0)
25
+ excon (0.92.2)
25
26
  fakefs (1.4.1)
26
27
  faraday (1.10.0)
27
28
  faraday-em_http (~> 1.0)
@@ -61,7 +62,11 @@ GEM
61
62
  faraday (>= 0.9)
62
63
  sawyer (~> 0.8.0, >= 0.5.3)
63
64
  open4 (1.3.4)
65
+ parallel (1.22.1)
66
+ parser (3.1.1.0)
67
+ ast (~> 2.4.1)
64
68
  public_suffix (4.0.6)
69
+ rainbow (3.1.1)
65
70
  rake (13.0.6)
66
71
  rake_circle_ci (0.9.0)
67
72
  colored2 (~> 3.1)
@@ -88,6 +93,8 @@ GEM
88
93
  colored2 (~> 3.1)
89
94
  rake_factory (~> 0.23)
90
95
  sshkey (~> 2.0)
96
+ regexp_parser (2.2.1)
97
+ rexml (3.2.5)
91
98
  rspec (3.11.0)
92
99
  rspec-core (~> 3.11.0)
93
100
  rspec-expectations (~> 3.11.0)
@@ -97,10 +104,26 @@ GEM
97
104
  rspec-expectations (3.11.0)
98
105
  diff-lcs (>= 1.2.0, < 2.0)
99
106
  rspec-support (~> 3.11.0)
100
- rspec-mocks (3.11.0)
107
+ rspec-mocks (3.11.1)
101
108
  diff-lcs (>= 1.2.0, < 2.0)
102
109
  rspec-support (~> 3.11.0)
103
110
  rspec-support (3.11.0)
111
+ rubocop (1.26.1)
112
+ parallel (~> 1.10)
113
+ parser (>= 3.1.0.0)
114
+ rainbow (>= 2.2.2, < 4.0)
115
+ regexp_parser (>= 1.8, < 3.0)
116
+ rexml
117
+ rubocop-ast (>= 1.16.0, < 2.0)
118
+ ruby-progressbar (~> 1.7)
119
+ unicode-display_width (>= 1.4.0, < 3.0)
120
+ rubocop-ast (1.16.0)
121
+ parser (>= 3.1.1.0)
122
+ rubocop-rake (0.6.0)
123
+ rubocop (~> 1.0)
124
+ rubocop-rspec (2.9.0)
125
+ rubocop (~> 1.19)
126
+ ruby-progressbar (1.11.0)
104
127
  ruby2_keywords (0.0.5)
105
128
  ruby_easy_rsa (0.9.0)
106
129
  lino (>= 1.5)
@@ -120,6 +143,7 @@ GEM
120
143
  sshkey (2.0.0)
121
144
  tzinfo (2.0.4)
122
145
  concurrent-ruby (~> 1.0)
146
+ unicode-display_width (2.1.0)
123
147
 
124
148
  PLATFORMS
125
149
  ruby
@@ -136,7 +160,10 @@ DEPENDENCIES
136
160
  rake_gpg
137
161
  rake_ssh
138
162
  rspec
163
+ rubocop
164
+ rubocop-rake
165
+ rubocop-rspec
139
166
  simplecov
140
167
 
141
168
  BUNDLED WITH
142
- 2.3.9
169
+ 2.3.10
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 :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
14
18
  namespace :passphrase do
19
+ desc 'Generate encryption passphrase for CI GPG key'
15
20
  task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
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
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
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
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'rake_easy_rsa CI Key')
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_easy_rsa 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
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/rake_easy_rsa'
62
+ namespace: :circle_ci,
63
+ project_slug: 'github/infrablocks/rake_easy_rsa'
43
64
  ) do |t|
44
65
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
66
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
67
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
68
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
69
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
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
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
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
- namespace: :github,
64
- repository: 'infrablocks/rake_easy_rsa',
84
+ namespace: :github,
85
+ repository: 'infrablocks/rake_easy_rsa'
65
86
  ) do |t, args|
66
87
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
88
+ YAML.load_file('config/secrets/github/config.yaml')
68
89
 
69
- t.access_token = github_config["github_personal_access_token"]
90
+ t.access_token = github_config['github_personal_access_token']
70
91
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
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
- 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'
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 "Bump version for specified type (pre, major, minor, patch)"
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 "Release gem"
119
+ desc 'Release gem'
98
120
  task :release do
99
- sh "gem release --tag --push"
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
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
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 "bundler/setup"
4
- require "rake_easyrsa"
4
+ require 'bundler/setup'
5
+ require 'rake_easyrsa'
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_easyrsa"
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
  module RakeEasyRSA
2
4
  module Mixins
3
5
  module AlgorithmParameters
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
 
3
5
  module RakeEasyRSA
@@ -7,11 +9,11 @@ module RakeEasyRSA
7
9
  super(base)
8
10
  base.class_eval do
9
11
  parameter :ensure_task_name, default: :'easy_rsa:ensure'
10
- default_prerequisites RakeFactory::DynamicValue.new { |t|
12
+ default_prerequisites(RakeFactory::DynamicValue.new do |t|
11
13
  [t.ensure_task_name]
12
- }
14
+ end)
13
15
  end
14
16
  end
15
17
  end
16
18
  end
17
- end
19
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeEasyRSA
2
4
  module Mixins
3
5
  module EncryptKeyParameters
@@ -9,4 +11,4 @@ module RakeEasyRSA
9
11
  end
10
12
  end
11
13
  end
12
- end
14
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeEasyRSA
2
4
  module Mixins
3
5
  module GitkeepParameters
@@ -9,4 +11,4 @@ module RakeEasyRSA
9
11
  end
10
12
  end
11
13
  end
12
- end
14
+ end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeEasyRSA
2
4
  module Mixins
3
5
  module GlobalParameters
6
+ # rubocop:disable Metrics/MethodLength
4
7
  def self.included(base)
5
8
  super(base)
6
9
  base.class_eval do
@@ -15,6 +18,7 @@ module RakeEasyRSA
15
18
  parameter :output_password
16
19
  end
17
20
  end
21
+ # rubocop:enable Metrics/MethodLength
18
22
  end
19
23
  end
20
- end
24
+ end
@@ -1,6 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeEasyRSA
2
4
  module Mixins
3
5
  module SSLParameters
6
+ # rubocop:disable Metrics/MethodLength
4
7
  def self.included(base)
5
8
  super(base)
6
9
  base.class_eval do
@@ -16,6 +19,7 @@ module RakeEasyRSA
16
19
  parameter :email
17
20
  end
18
21
  end
22
+ # rubocop:enable Metrics/MethodLength
19
23
  end
20
24
  end
21
25
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
 
3
5
  require_relative '../tasks'
@@ -8,6 +10,7 @@ require_relative '../mixins/encrypt_key_parameters'
8
10
 
9
11
  module RakeEasyRSA
10
12
  module TaskSets
13
+ # rubocop:disable Metrics/ClassLength
11
14
  class PKI < RakeFactory::TaskSet
12
15
  prepend RakeFactory::Namespaceable
13
16
 
@@ -41,88 +44,93 @@ module RakeEasyRSA
41
44
  parameter :certificate_renew_task_name, default: :renew
42
45
 
43
46
  task Tasks::Initialise,
44
- name: RakeFactory::DynamicValue.new { |ts|
45
- ts.initialise_task_name
46
- }
47
+ name: RakeFactory::DynamicValue.new { |ts|
48
+ ts.initialise_task_name
49
+ }
47
50
  task Tasks::Generate,
48
- name: RakeFactory::DynamicValue.new { |ts|
49
- ts.generate_task_name
50
- },
51
- initialise_task_name: RakeFactory::DynamicValue.new { |ts|
52
- ts.initialise_task_name
53
- },
54
- ca_create_task_name: RakeFactory::DynamicValue.new { |ts|
55
- "#{ts.ca_namespace}:#{ts.ca_create_task_name}".to_sym
56
- },
57
- crl_generate_task_name: RakeFactory::DynamicValue.new { |ts|
58
- "#{ts.crl_namespace}:#{ts.crl_generate_task_name}".to_sym
59
- },
60
- dh_generate_task_name: RakeFactory::DynamicValue.new { |ts|
61
- "#{ts.dh_namespace}:#{ts.dh_generate_task_name}".to_sym
62
- }
51
+ name: RakeFactory::DynamicValue.new { |ts|
52
+ ts.generate_task_name
53
+ },
54
+ initialise_task_name: RakeFactory::DynamicValue.new { |ts|
55
+ ts.initialise_task_name
56
+ },
57
+ ca_create_task_name: RakeFactory::DynamicValue.new { |ts|
58
+ "#{ts.ca_namespace}:#{ts.ca_create_task_name}".to_sym
59
+ },
60
+ crl_generate_task_name: RakeFactory::DynamicValue.new { |ts|
61
+ "#{ts.crl_namespace}:#{ts.crl_generate_task_name}".to_sym
62
+ },
63
+ dh_generate_task_name: RakeFactory::DynamicValue.new { |ts|
64
+ "#{ts.dh_namespace}:#{ts.dh_generate_task_name}".to_sym
65
+ }
63
66
  task Tasks::CA::Create,
64
- name: RakeFactory::DynamicValue.new { |ts|
65
- ts.ca_create_task_name
66
- }
67
+ name: RakeFactory::DynamicValue.new { |ts|
68
+ ts.ca_create_task_name
69
+ }
67
70
  task Tasks::CRL::Generate,
68
- name: RakeFactory::DynamicValue.new { |ts|
69
- ts.crl_generate_task_name
70
- }
71
+ name: RakeFactory::DynamicValue.new { |ts|
72
+ ts.crl_generate_task_name
73
+ }
71
74
  task Tasks::DH::Generate,
72
- name: RakeFactory::DynamicValue.new { |ts|
73
- ts.dh_generate_task_name
74
- }
75
+ name: RakeFactory::DynamicValue.new { |ts|
76
+ ts.dh_generate_task_name
77
+ }
75
78
  task Tasks::Client::Create,
76
- name: RakeFactory::DynamicValue.new { |ts|
77
- ts.client_create_task_name
78
- }
79
+ name: RakeFactory::DynamicValue.new { |ts|
80
+ ts.client_create_task_name
81
+ }
79
82
  task Tasks::Server::Create,
80
- name: RakeFactory::DynamicValue.new { |ts|
81
- ts.server_create_task_name
82
- }
83
+ name: RakeFactory::DynamicValue.new { |ts|
84
+ ts.server_create_task_name
85
+ }
83
86
  task Tasks::Certificate::Revoke,
84
- name: RakeFactory::DynamicValue.new { |ts|
85
- ts.certificate_revoke_task_name
86
- }
87
+ name: RakeFactory::DynamicValue.new { |ts|
88
+ ts.certificate_revoke_task_name
89
+ }
87
90
  task Tasks::Certificate::Renew,
88
- name: RakeFactory::DynamicValue.new { |ts|
89
- ts.certificate_renew_task_name
90
- }
91
+ name: RakeFactory::DynamicValue.new { |ts|
92
+ ts.certificate_renew_task_name
93
+ }
91
94
 
92
95
  def define_on(application)
93
96
  around_define(application) do
94
97
  self.class.tasks.each do |task_definition|
95
- ns = case task_definition.klass.to_s
96
- when /CA/
97
- ca_namespace
98
- when /CRL/
99
- crl_namespace
100
- when /DH/
101
- dh_namespace
102
- when /Client/
103
- client_namespace
104
- when /Server/
105
- server_namespace
106
- when /Certificate/
107
- certificate_namespace
108
- else
109
- nil
110
- end
98
+ namespace = resolve_namespace(task_definition)
111
99
 
112
- if ns
113
- application.in_namespace(ns) do
114
- task_definition
115
- .for_task_set(self)
116
- .define_on(application)
117
- end
100
+ if namespace
101
+ define_in_namespace(namespace, application, task_definition)
118
102
  else
119
- task_definition
120
- .for_task_set(self)
121
- .define_on(application)
103
+ define_at_current_level(application, task_definition)
122
104
  end
123
105
  end
124
106
  end
125
107
  end
108
+
109
+ private
110
+
111
+ def define_in_namespace(namespace, application, task_definition)
112
+ application.in_namespace(namespace) do
113
+ define_at_current_level(application, task_definition)
114
+ end
115
+ end
116
+
117
+ def resolve_namespace(task_definition)
118
+ case task_definition.klass.to_s
119
+ when /CA/ then ca_namespace
120
+ when /CRL/ then crl_namespace
121
+ when /DH/ then dh_namespace
122
+ when /Client/ then client_namespace
123
+ when /Server/ then server_namespace
124
+ when /Certificate/ then certificate_namespace
125
+ end
126
+ end
127
+
128
+ def define_at_current_level(application, task_definition)
129
+ task_definition
130
+ .for_task_set(self)
131
+ .define_on(application)
132
+ end
126
133
  end
134
+ # rubocop:enable Metrics/ClassLength
127
135
  end
128
136
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'task_sets/pki'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -20,28 +22,24 @@ module RakeEasyRSA
20
22
  include Mixins::EasyRSAEnsurePrerequisite
21
23
 
22
24
  default_name :create
23
- default_description "Create the CA certificate for the PKI"
25
+ default_description 'Create the CA certificate for the PKI'
24
26
 
25
27
  action do |t|
26
- puts "Creating CA certificate... "
28
+ puts 'Creating CA certificate... '
27
29
  RubyEasyRSA.build_ca(t.parameter_values)
28
30
  if t.include_gitkeep_files
29
- [
30
- 'certs_by_serial/.gitkeep',
31
- 'issued/.gitkeep',
32
- 'renewed/certs_by_serial/.gitkeep',
33
- 'renewed/private_by_serial/.gitkeep',
34
- 'renewed/reqs_by_serial/.gitkeep',
35
- 'revoked/certs_by_serial/.gitkeep',
36
- 'revoked/private_by_serial/.gitkeep',
37
- 'revoked/reqs_by_serial/.gitkeep'
38
- ].each do |gitkeep_file|
39
- File.open("#{t.pki_directory}/#{gitkeep_file}", 'w') do |f|
40
- f.write('')
41
- end
31
+ %w[certs_by_serial/.gitkeep
32
+ issued/.gitkeep
33
+ renewed/certs_by_serial/.gitkeep
34
+ renewed/private_by_serial/.gitkeep
35
+ renewed/reqs_by_serial/.gitkeep
36
+ revoked/certs_by_serial/.gitkeep
37
+ revoked/private_by_serial/.gitkeep
38
+ revoked/reqs_by_serial/.gitkeep].each do |gitkeep_file|
39
+ File.write("#{t.pki_directory}/#{gitkeep_file}", '')
42
40
  end
43
41
  end
44
- puts "Done."
42
+ puts 'Done.'
45
43
  end
46
44
  end
47
45
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'ca/create'
2
4
 
3
5
  module RakeEasyRSA
4
6
  module Tasks
5
7
  module CA
6
-
7
8
  end
8
9
  end
9
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -18,7 +20,7 @@ module RakeEasyRSA
18
20
  parameter :default_argument_names, default: [:filename_base]
19
21
 
20
22
  default_name :renew
21
- default_description "Renew a certificate of the PKI"
23
+ default_description 'Renew a certificate of the PKI'
22
24
 
23
25
  def argument_names
24
26
  @argument_names + default_argument_names
@@ -28,8 +30,10 @@ module RakeEasyRSA
28
30
  puts "Renewing certificate '#{args.filename_base}'... "
29
31
  RubyEasyRSA.renew(
30
32
  t.parameter_values.merge(
31
- filename_base: args.filename_base))
32
- puts "Done."
33
+ filename_base: args.filename_base
34
+ )
35
+ )
36
+ puts 'Done.'
33
37
  end
34
38
  end
35
39
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -14,7 +16,7 @@ module RakeEasyRSA
14
16
  include Mixins::EasyRSAEnsurePrerequisite
15
17
 
16
18
  parameter(:default_argument_names,
17
- default: [:filename_base, :reason])
19
+ default: %i[filename_base reason])
18
20
 
19
21
  default_name :revoke
20
22
  default_description 'Revoke a certificate of the PKI'
@@ -31,7 +33,9 @@ module RakeEasyRSA
31
33
  RubyEasyRSA.revoke(
32
34
  t.parameter_values.merge(
33
35
  reason: reason,
34
- filename_base: args.filename_base))
36
+ filename_base: args.filename_base
37
+ )
38
+ )
35
39
  puts 'Done.'
36
40
  end
37
41
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'certificate/revoke'
2
4
  require_relative 'certificate/renew'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -20,7 +22,7 @@ module RakeEasyRSA
20
22
  parameter :default_argument_names, default: [:filename_base]
21
23
 
22
24
  default_name :create
23
- default_description "Create a client certificate for the PKI"
25
+ default_description 'Create a client certificate for the PKI'
24
26
 
25
27
  def argument_names
26
28
  @argument_names + default_argument_names
@@ -30,8 +32,10 @@ module RakeEasyRSA
30
32
  puts "Creating client certificate '#{args.filename_base}'... "
31
33
  RubyEasyRSA.build_client_full(
32
34
  t.parameter_values.merge(
33
- filename_base: args.filename_base))
34
- puts "Done."
35
+ filename_base: args.filename_base
36
+ )
37
+ )
38
+ puts 'Done.'
35
39
  end
36
40
  end
37
41
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'client/create'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -15,12 +17,13 @@ module RakeEasyRSA
15
17
 
16
18
  default_name :generate
17
19
  default_description(
18
- "Generate the certificate revocation list for the PKI")
20
+ 'Generate the certificate revocation list for the PKI'
21
+ )
19
22
 
20
23
  action do |t|
21
- puts "Generating CRL... "
24
+ puts 'Generating CRL... '
22
25
  RubyEasyRSA.gen_crl(t.parameter_values)
23
- puts "Done."
26
+ puts 'Done.'
24
27
  end
25
28
  end
26
29
  end
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'crl/generate'
2
4
 
3
5
  module RakeEasyRSA
4
6
  module Tasks
5
7
  module CRL
6
-
7
8
  end
8
9
  end
9
10
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -15,12 +17,13 @@ module RakeEasyRSA
15
17
 
16
18
  default_name :generate
17
19
  default_description(
18
- "Generate Diffie-Hellman parameters for the PKI")
20
+ 'Generate Diffie-Hellman parameters for the PKI'
21
+ )
19
22
 
20
23
  action do |t|
21
- puts "Generating Diffie-Hellman parameters... "
24
+ puts 'Generating Diffie-Hellman parameters... '
22
25
  RubyEasyRSA.gen_dh(t.parameter_values)
23
- puts "Done."
26
+ puts 'Done.'
24
27
  end
25
28
  end
26
29
  end
@@ -1,2 +1,3 @@
1
- require_relative 'dh/generate'
1
+ # frozen_string_literal: true
2
2
 
3
+ require_relative 'dh/generate'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -5,7 +7,7 @@ module RakeEasyRSA
5
7
  module Tasks
6
8
  class Generate < RakeFactory::Task
7
9
  default_name :generate
8
- default_description "Generate all pre-requisites for managing the PKI"
10
+ default_description 'Generate all pre-requisites for managing the PKI'
9
11
 
10
12
  parameter :initialise_task_name, default: 'initialise'
11
13
  parameter :ca_create_task_name, default: 'ca:create'
@@ -13,12 +15,12 @@ module RakeEasyRSA
13
15
  parameter :dh_generate_task_name, default: 'dh:generate'
14
16
 
15
17
  action do |t, args|
16
- puts "Generating PKI pre-requisites... "
18
+ puts 'Generating PKI pre-requisites... '
17
19
  t.application[t.initialise_task_name, t.scope].invoke(*args)
18
20
  t.application[t.ca_create_task_name, t.scope].invoke(*args)
19
21
  t.application[t.crl_generate_task_name, t.scope].invoke(*args)
20
22
  t.application[t.dh_generate_task_name, t.scope].invoke(*args)
21
- puts "Done."
23
+ puts 'Done.'
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -15,20 +17,16 @@ module RakeEasyRSA
15
17
  include Mixins::EasyRSAEnsurePrerequisite
16
18
 
17
19
  default_name :initialise
18
- default_description "Initialise the PKI working directory"
20
+ default_description 'Initialise the PKI working directory'
19
21
 
20
22
  action do |t|
21
- puts "Initialising PKI working directory... "
23
+ puts 'Initialising PKI working directory... '
22
24
  RubyEasyRSA.init_pki(t.parameter_values)
23
25
  if t.include_gitkeep_files
24
- File.open("#{t.pki_directory}/private/.gitkeep", 'w') do |f|
25
- f.write('')
26
- end
27
- File.open("#{t.pki_directory}/reqs/.gitkeep", 'w') do |f|
28
- f.write('')
29
- end
26
+ File.write("#{t.pki_directory}/private/.gitkeep", '')
27
+ File.write("#{t.pki_directory}/reqs/.gitkeep", '')
30
28
  end
31
- puts "Done."
29
+ puts 'Done.'
32
30
  end
33
31
  end
34
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory'
2
4
  require 'ruby_easy_rsa'
3
5
 
@@ -18,9 +20,10 @@ module RakeEasyRSA
18
20
  include Mixins::EasyRSAEnsurePrerequisite
19
21
 
20
22
  parameter :default_argument_names, default: [:filename_base]
23
+ parameter :vegetable
21
24
 
22
25
  default_name :create
23
- default_description "Create a server certificate for the PKI"
26
+ default_description 'Create a server certificate for the PKI'
24
27
 
25
28
  def argument_names
26
29
  @argument_names + default_argument_names
@@ -29,9 +32,11 @@ module RakeEasyRSA
29
32
  action do |t, args|
30
33
  puts "Creating server certificate '#{args.filename_base}'... "
31
34
  RubyEasyRSA.build_server_full(
32
- t.parameter_values.merge(
33
- filename_base: args.filename_base))
34
- puts "Done."
35
+ t.parameter_values.merge(
36
+ filename_base: args.filename_base
37
+ )
38
+ )
39
+ puts 'Done.'
35
40
  end
36
41
  end
37
42
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'server/create'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'tasks/initialise'
2
4
  require_relative 'tasks/generate'
3
5
  require_relative 'tasks/ca'
@@ -9,6 +11,5 @@ require_relative 'tasks/certificate'
9
11
 
10
12
  module RakeEasyRSA
11
13
  module Tasks
12
-
13
14
  end
14
- end
15
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeEasyRSA
2
- VERSION = '0.12.0.pre.1'
4
+ VERSION = '0.12.0.pre.2'
3
5
  end
data/lib/rake_easy_rsa.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_dependencies'
2
4
  require 'ruby_easy_rsa'
3
5
  require 'rake_easy_rsa/version'
@@ -6,39 +8,77 @@ require 'rake_easy_rsa/task_sets'
6
8
 
7
9
  module RakeEasyRSA
8
10
  def self.define_installation_tasks(opts = {})
9
- namespace = opts[:namespace] || :easy_rsa
10
- version = opts[:version] || '3.0.7'
11
- path = opts[:path] || File.join('vendor', 'easy-rsa')
12
- type = :tgz
13
- binary_directory = ''
14
- uri_template = 'https://github.com/OpenVPN/easy-rsa/releases/' +
15
- 'download/v<%= @version %>/' +
16
- 'EasyRSA-<%= @version %>.tgz'
17
- file_name_template = 'EasyRSA-<%= @version %>.tgz'
18
- strip_path_template = 'EasyRSA-<%= @version %>'
19
-
20
- task_set_opts = {
21
- namespace: namespace,
22
- dependency: 'easy-rsa',
23
- version: version,
24
- path: path,
25
- type: type,
26
- binary_directory: binary_directory,
27
- uri_template: uri_template,
28
- file_name_template: file_name_template,
29
- strip_path_template: strip_path_template,
30
- needs_fetch: lambda { |t|
31
- !File.exist?(File.join(t.path, 'easyrsa'))
32
- }}
33
-
34
11
  RubyEasyRSA.configure do |c|
35
- c.binary = File.join(path, 'easyrsa')
12
+ c.binary = File.join(path(opts), 'easyrsa')
36
13
  end
37
14
 
38
- RakeDependencies::TaskSets::All.define(task_set_opts)
15
+ RakeDependencies::TaskSets::All.define(
16
+ installation_task_set_opts(opts)
17
+ )
39
18
  end
40
19
 
41
20
  def self.define_pki_tasks(opts = {}, &block)
42
21
  RakeEasyRSA::TaskSets::PKI.define(opts, &block)
43
22
  end
23
+
24
+ class << self
25
+ private
26
+
27
+ def installation_task_set_opts(opts)
28
+ { namespace: namespace(opts),
29
+ dependency: dependency(opts),
30
+ version: version(opts),
31
+ path: path(opts),
32
+ type: type(opts),
33
+ binary_directory: binary_directory(opts),
34
+ uri_template: uri_template(opts),
35
+ file_name_template: file_name_template(opts),
36
+ strip_path_template: strip_path_template(opts),
37
+ needs_fetch: needs_fetch_check_lambda(opts) }
38
+ end
39
+
40
+ def namespace(opts)
41
+ opts[:namespace] || :easy_rsa
42
+ end
43
+
44
+ def dependency(_)
45
+ 'easy-rsa'
46
+ end
47
+
48
+ def version(opts)
49
+ opts[:version] || '3.0.7'
50
+ end
51
+
52
+ def path(opts)
53
+ opts[:path] || File.join('vendor', 'easy-rsa')
54
+ end
55
+
56
+ def type(_)
57
+ :tgz
58
+ end
59
+
60
+ def uri_template(_)
61
+ 'https://github.com/OpenVPN/easy-rsa/releases/'\
62
+ 'download/v<%= @version %>/'\
63
+ 'EasyRSA-<%= @version %>.tgz'
64
+ end
65
+
66
+ def binary_directory(_)
67
+ ''
68
+ end
69
+
70
+ def file_name_template(_)
71
+ 'EasyRSA-<%= @version %>.tgz'
72
+ end
73
+
74
+ def strip_path_template(_)
75
+ 'EasyRSA-<%= @version %>'
76
+ end
77
+
78
+ def needs_fetch_check_lambda(_)
79
+ lambda { |t|
80
+ !File.exist?(File.join(t.path, 'easyrsa'))
81
+ }
82
+ end
83
+ end
44
84
  end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'rake_easy_rsa/version'
6
+
7
+ files = %w[
8
+ bin
9
+ lib
10
+ CODE_OF_CONDUCT.md
11
+ rake_easy_rsa.gemspec
12
+ Gemfile
13
+ LICENSE.txt
14
+ Rakefile
15
+ README.md
16
+ ]
17
+
18
+ Gem::Specification.new do |spec|
19
+ spec.name = 'rake_easy_rsa'
20
+ spec.version = RakeEasyRSA::VERSION
21
+ spec.authors = ['InfraBlocks Maintainers']
22
+ spec.email = ['maintainers@infrablocks.io']
23
+
24
+ spec.summary = 'Rake tasks for managing PKI using EasyRSA.'
25
+ spec.description = 'Rake tasks for common PKI management tasks using EasyRSA.'
26
+ spec.homepage = 'https://github.com/infrablocks/rake_easy_rsa'
27
+ spec.license = 'MIT'
28
+
29
+ spec.files = `git ls-files -z`.split("\x0").select do |f|
30
+ f.match(/^(#{files.map { |g| Regexp.escape(g) }.join('|')})/)
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+
36
+ spec.required_ruby_version = '>= 2.7'
37
+
38
+ spec.add_dependency 'rake_dependencies', '~> 3.1'
39
+ spec.add_dependency 'rake_factory', '~> 0.23'
40
+ spec.add_dependency 'ruby_easy_rsa', '~> 0.7'
41
+ spec.add_dependency 'semantic', '~> 1.6'
42
+
43
+ spec.add_development_dependency 'activesupport'
44
+ spec.add_development_dependency 'bundler'
45
+ spec.add_development_dependency 'fakefs'
46
+ spec.add_development_dependency 'gem-release'
47
+ spec.add_development_dependency 'rake'
48
+ spec.add_development_dependency 'rake_circle_ci'
49
+ spec.add_development_dependency 'rake_github'
50
+ spec.add_development_dependency 'rake_gpg'
51
+ spec.add_development_dependency 'rake_ssh'
52
+ spec.add_development_dependency 'rspec'
53
+ spec.add_development_dependency 'rubocop'
54
+ spec.add_development_dependency 'rubocop-rake'
55
+ spec.add_development_dependency 'rubocop-rspec'
56
+ spec.add_development_dependency 'simplecov'
57
+
58
+ spec.metadata['rubygems_mfa_required'] = 'false'
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_easy_rsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0.pre.1
4
+ version: 0.12.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake_dependencies
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,34 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fakefs
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: gem-release
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: rake
85
127
  requirement: !ruby/object:Gem::Requirement
@@ -123,7 +165,7 @@ dependencies:
123
165
  - !ruby/object:Gem::Version
124
166
  version: '0'
125
167
  - !ruby/object:Gem::Dependency
126
- name: rake_ssh
168
+ name: rake_gpg
127
169
  requirement: !ruby/object:Gem::Requirement
128
170
  requirements:
129
171
  - - ">="
@@ -137,7 +179,7 @@ dependencies:
137
179
  - !ruby/object:Gem::Version
138
180
  version: '0'
139
181
  - !ruby/object:Gem::Dependency
140
- name: rake_gpg
182
+ name: rake_ssh
141
183
  requirement: !ruby/object:Gem::Requirement
142
184
  requirements:
143
185
  - - ">="
@@ -165,7 +207,7 @@ dependencies:
165
207
  - !ruby/object:Gem::Version
166
208
  version: '0'
167
209
  - !ruby/object:Gem::Dependency
168
- name: gem-release
210
+ name: rubocop
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
213
  - - ">="
@@ -179,7 +221,7 @@ dependencies:
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
181
223
  - !ruby/object:Gem::Dependency
182
- name: activesupport
224
+ name: rubocop-rake
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - ">="
@@ -193,7 +235,7 @@ dependencies:
193
235
  - !ruby/object:Gem::Version
194
236
  version: '0'
195
237
  - !ruby/object:Gem::Dependency
196
- name: fakefs
238
+ name: rubocop-rspec
197
239
  requirement: !ruby/object:Gem::Requirement
198
240
  requirements:
199
241
  - - ">="
@@ -261,10 +303,12 @@ files:
261
303
  - lib/rake_easy_rsa/tasks/server.rb
262
304
  - lib/rake_easy_rsa/tasks/server/create.rb
263
305
  - lib/rake_easy_rsa/version.rb
306
+ - rake_easy_rsa.gemspec
264
307
  homepage: https://github.com/infrablocks/rake_easy_rsa
265
308
  licenses:
266
309
  - MIT
267
- metadata: {}
310
+ metadata:
311
+ rubygems_mfa_required: 'false'
268
312
  post_install_message:
269
313
  rdoc_options: []
270
314
  require_paths: