convox_installer 1.0.9 → 2.0.0

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: 8e3e80d423ba3cf14865e0b541207471286dcfa32956bfbc22c3fd4ff0818413
4
- data.tar.gz: 031f35af824c717ee140a281d22e4793c06b83a05182709a1803c60a23692ad6
3
+ metadata.gz: b9b7140386f111c59db16b8db7429b2fb3a5c1a48372a2559e2e2c5499d59dd2
4
+ data.tar.gz: 6e94e2c459c01426f8b6d2adc7d232f630e9711722947d2899b20ea509089c47
5
5
  SHA512:
6
- metadata.gz: a96d285b7778b693394fd5bb7c5f7157aa74513e6302337bbfab2b9714d4b1b425f1b2033cb0fdf488625cfb9c835c09ea7a05f7426a47ab2c681ded07c3cc55
7
- data.tar.gz: 368b58ededb07344ecd232838ba6229bbf93d4d3da345f5292eb4dfd213514b0b13138ea334857c54b53887eebf83b251938f5ff942bda410e7cb49ee0e46033
6
+ metadata.gz: 64741ea4bd8a4e03d30172d366976e7d18c99cd2dff1f27ceaf5106d86de56c46fc0302fed774669f5a513d3b5cd8212b3b94e54687a539b235e545b3a9c90cb
7
+ data.tar.gz: 67966065258259f0b64c7572895ee884f4e34c55e4f9c1ddbff90cf431e8da78984706955b406655d8f0128f4edd21842559129aa5b7dde73a745a121ad44ce1
data/.rubocop.yml CHANGED
@@ -1,5 +1,12 @@
1
1
  require: rubocop-rspec
2
- TargetRubyVersion: "2.3"
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ TargetRubyVersion: 2.5
6
+
7
+ Style/MixinUsage:
8
+ Exclude:
9
+ - examples/**/*
3
10
 
4
11
  Metrics/LineLength:
5
12
  Max: 100
@@ -39,3 +46,18 @@ Metrics/BlockLength:
39
46
 
40
47
  Metrics/BlockNesting:
41
48
  Max: 7
49
+
50
+ RSpec/MessageSpies:
51
+ Enabled: false
52
+
53
+ RSpec/StubbedMock:
54
+ Enabled: false
55
+
56
+ RSpec/MultipleExpectations:
57
+ Enabled: false
58
+
59
+ RSpec/ExampleLength:
60
+ Enabled: false
61
+
62
+ RSpec/AnyInstance:
63
+ Enabled: false
@@ -1,4 +1,4 @@
1
1
  {
2
- "editor.formatOnSave": true,
2
+ "editor.formatOnSave": false,
3
3
  "editor.formatOnSaveTimeout": 5000
4
- }
4
+ }
data/Gemfile CHANGED
@@ -5,8 +5,8 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :test do
8
- gem 'pry'
9
- gem 'pry-byebug'
8
+ gem 'pry', require: false
9
+ gem 'pry-byebug', require: false
10
10
  gem 'rspec'
11
11
  gem 'rubocop'
12
12
  gem 'rubocop-rspec'
data/README.md CHANGED
@@ -2,9 +2,12 @@
2
2
 
3
3
  A Ruby gem that makes it easier to build a Convox installation script. This is like Chef/Ansible/Terraform for your initial Convox setup.
4
4
 
5
- ## NOTE: This software is an alpha version
5
+ # Requirements: Convox v2
6
6
 
7
- Please note that the code quality is not very good, and the test coverage needs to be improved. However, I've successfully set up a number of test and production deployments using this gem, and everything seems to work very well. The library also facilitates idempotency and crash-resistance, so you can easily re-run your installation script if something goes wrong.
7
+ This version of `convox_installer` is only designed to work with Convox v2. Please install the v2 CLI by following the instructions at their old documentation site: https://docsv2.convox.com/introduction/installation
8
+ ## USE AT YOUR OWN RISK! THIS CODE IS PROVIDED WITHOUT ANY WARRANTIES OR GUARANTEES
9
+
10
+ We have successfully set up a number of test and production deployments using this gem. Everything seems to work very well. The library also facilitates idempotency and crash-resistance, so you can easily re-run your installation script if something goes wrong. However, if anything goes wrong, then you can end up with a large AWS bill if you're not careful. If anything crashes then make sure you double-check everything in your AWS account and shut down any leftover resources. **USE THIS SOFTWARE AT YOUR OWN RISK.**
8
11
 
9
12
  ## Features
10
13
 
@@ -149,7 +152,7 @@ If there are any existing files at `~/.convox/host` or `~/.convox/rack`, this me
149
152
 
150
153
  Runs `convox rack install ...`. Has some validations to ensure that all required settings are present.
151
154
 
152
- #### `validate_convox_auth_and_set_host!`
155
+ #### `validate_convox_auth_and_write_host!`
153
156
 
154
157
  After running `install_convox`, call this method to ensure that the the `~/.convox/auth` file has been updated with the correct details (checks the rack name and AWS region.) Then it sets the rack host in `~/.convox/host` (if not already set.)
155
158
 
@@ -1,28 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.push File.expand_path("lib", __dir__)
4
- require "convox_installer/version"
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+ require 'convox_installer/version'
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "convox_installer"
7
+ s.name = 'convox_installer'
8
8
  s.version = ConvoxInstaller::VERSION
9
9
  s.platform = Gem::Platform::RUBY
10
- s.authors = ["Form Applications Inc."]
11
- s.email = ["support@formapi.io"]
12
- s.homepage = "https://github.com/FormAPI/convox_installer"
13
- s.summary = "Build a Convox installation workflow"
14
- s.description = "Build a Convox installation workflow"
15
- s.license = "MIT"
16
- s.required_ruby_version = ">= 2.3"
10
+ s.authors = ['Form Applications Inc.']
11
+ s.email = ['support@formapi.io']
12
+ s.homepage = 'https://github.com/FormAPI/convox_installer'
13
+ s.summary = 'Build a Convox installation workflow'
14
+ s.description = 'Build a Convox installation workflow'
15
+ s.license = 'MIT'
16
+ s.required_ruby_version = '>= 2.5'
17
17
 
18
- s.add_runtime_dependency "highline", ">= 1.7.10"
19
- s.add_runtime_dependency "json", ">= 2.2.0"
20
- s.add_runtime_dependency "os", ">= 1.0.1"
21
- s.add_runtime_dependency "httparty", ">= 0.17.0"
22
- s.add_runtime_dependency "activesupport", ">= 5.2.3"
18
+ s.add_runtime_dependency 'activesupport', '>= 5.2.3'
19
+ s.add_runtime_dependency 'highline', '>= 1.7.10'
20
+ s.add_runtime_dependency 'httparty', '>= 0.17.0'
21
+ s.add_runtime_dependency 'json', '>= 2.2.0'
22
+ s.add_runtime_dependency 'os', '>= 1.0.1'
23
23
 
24
- s.files = `git ls-files`.split("\n").uniq.sort.reject(&:empty?) - ["Gemfile.lock"]
24
+ s.files = `git ls-files`.split("\n").uniq.sort.reject(&:empty?) - ['Gemfile.lock']
25
25
  s.test_files = `git ls-files spec test`.split("\n")
26
26
  s.executables = []
27
- s.require_paths = ["lib"]
27
+ s.require_paths = ['lib']
28
+ s.metadata['rubygems_mfa_required'] = 'true'
28
29
  end
@@ -9,82 +9,82 @@
9
9
  # gem "convox_installer"
10
10
  # end
11
11
 
12
- $LOAD_PATH << File.expand_path("../../lib", __FILE__)
13
- require "pry-byebug"
12
+ $LOAD_PATH << File.expand_path('../lib', __dir__)
13
+ require 'pry-byebug'
14
14
 
15
- require "convox_installer"
15
+ require 'convox_installer'
16
16
  include ConvoxInstaller
17
17
 
18
18
  @log_level = Logger::DEBUG
19
19
 
20
- MINIMAL_HEALTH_CHECK_PATH = "/health/site"
21
- COMPLETE_HEALTH_CHECK_PATH = "/health"
22
-
23
- S3_BUCKET_CORS_POLICY = <<-JSON
24
- {
25
- "CORSRules": [
26
- {
27
- "AllowedOrigins": ["*"],
28
- "AllowedHeaders": ["Authorization", "cache-control", "x-requested-with"],
29
- "AllowedMethods": ["PUT", "POST", "GET"],
30
- "MaxAgeSeconds": 3000
31
- }
32
- ]
33
- }
20
+ MINIMAL_HEALTH_CHECK_PATH = '/health/site'
21
+ COMPLETE_HEALTH_CHECK_PATH = '/health'
22
+
23
+ S3_BUCKET_CORS_POLICY = <<~JSON
24
+ {
25
+ "CORSRules": [
26
+ {
27
+ "AllowedOrigins": ["*"],
28
+ "AllowedHeaders": ["Authorization", "cache-control", "x-requested-with"],
29
+ "AllowedMethods": ["PUT", "POST", "GET"],
30
+ "MaxAgeSeconds": 3000
31
+ }
32
+ ]
33
+ }
34
34
  JSON
35
35
 
36
36
  @prompts = ConvoxInstaller::Config::DEFAULT_PROMPTS + [
37
37
  {
38
- section: "Docker Registry Authentication",
38
+ section: 'Docker Registry Authentication',
39
39
  info: "You should have received authentication details for the Docker Registry\n" \
40
- "via email. If not, please contact support@example.com",
40
+ 'via email. If not, please contact support@example.com'
41
41
  },
42
42
  {
43
43
  key: :docker_registry_url,
44
- title: "Docker Registry URL",
45
- value: "691950705664.dkr.ecr.us-east-1.amazonaws.com",
44
+ title: 'Docker Registry URL',
45
+ value: '691950705664.dkr.ecr.us-east-1.amazonaws.com'
46
46
  },
47
47
  {
48
48
  key: :docker_registry_username,
49
- title: "Docker Registry Username",
49
+ title: 'Docker Registry Username'
50
50
  },
51
51
  {
52
52
  key: :docker_registry_password,
53
- title: "Docker Registry Password",
53
+ title: 'Docker Registry Password'
54
54
  },
55
55
  {
56
56
  key: :convox_app_name,
57
- title: "Convox App Name",
58
- value: "convox-app",
57
+ title: 'Convox App Name',
58
+ value: 'convox-app'
59
59
  },
60
60
  {
61
61
  key: :default_service,
62
- title: "Default Convox Service (for domain)",
63
- value: "web",
64
- hidden: true,
62
+ title: 'Default Convox Service (for domain)',
63
+ value: 'web',
64
+ hidden: true
65
65
  },
66
66
  {
67
67
  key: :admin_email,
68
- title: "Admin User Email",
69
- prompt: "Please enter the email address you would like to use " \
70
- "for the default admin user",
71
- default: "admin@example.com",
68
+ title: 'Admin User Email',
69
+ prompt: 'Please enter the email address you would like to use ' \
70
+ 'for the default admin user',
71
+ default: 'admin@example.com'
72
72
  },
73
73
  {
74
74
  key: :admin_password,
75
- title: "Admin User Password",
76
- value: -> () { SecureRandom.hex(8) },
75
+ title: 'Admin User Password',
76
+ value: -> { SecureRandom.hex(8) }
77
77
  },
78
78
  {
79
79
  key: :s3_bucket_name,
80
- title: "S3 Bucket for Uploads",
81
- value: -> () { "app-uploads-#{SecureRandom.hex(4)}" },
80
+ title: 'S3 Bucket for Uploads',
81
+ value: -> { "app-uploads-#{SecureRandom.hex(4)}" }
82
82
  },
83
83
  {
84
84
  key: :s3_bucket_cors_policy,
85
85
  value: S3_BUCKET_CORS_POLICY,
86
- hidden: true,
87
- },
86
+ hidden: true
87
+ }
88
88
  ]
89
89
 
90
90
  ensure_requirements!
@@ -93,7 +93,7 @@ config = prompt_for_config
93
93
  backup_convox_host_and_rack
94
94
  install_convox
95
95
 
96
- validate_convox_auth_and_set_host!
96
+ validate_convox_auth_and_write_host!
97
97
  validate_convox_rack!
98
98
 
99
99
  create_convox_app!
@@ -101,70 +101,70 @@ set_default_app_for_directory!
101
101
  add_docker_registry!
102
102
  create_s3_bucket!
103
103
 
104
- puts "=> Generating secret keys for authentication sessions and encryption..."
104
+ puts '=> Generating secret keys for authentication sessions and encryption...'
105
105
  secret_key_base = SecureRandom.hex(64)
106
106
  data_encryption_key = SecureRandom.hex(32)
107
107
 
108
108
  puts "======> Default domain: #{default_service_domain_name}"
109
- puts " You can use this as a CNAME record after configuring a domain in convox.yml"
110
- puts " (Note: SSL will be configured automatically.)"
109
+ puts ' You can use this as a CNAME record after configuring a domain in convox.yml'
110
+ puts ' (Note: SSL will be configured automatically.)'
111
111
 
112
- puts "=> Setting environment variables to configure the application..."
112
+ puts '=> Setting environment variables to configure the application...'
113
113
 
114
114
  env = {
115
- "HEALTH_CHECK_PATH" => MINIMAL_HEALTH_CHECK_PATH,
116
- "DOMAIN_NAME" => default_service_domain_name,
117
- "AWS_ACCESS_KEY_ID" => s3_bucket_details.fetch(:access_key_id),
118
- "AWS_ACCESS_KEY_SECRET" => s3_bucket_details.fetch(:secret_access_key),
119
- "AWS_UPLOADS_S3_BUCKET" => s3_bucket_details.fetch(:name),
120
- "AWS_UPLOADS_S3_REGION" => config.fetch(:aws_region),
121
- "SECRET_KEY_BASE" => secret_key_base,
122
- "DATA_ENCRYPTION_KEY" => data_encryption_key,
123
- "ADMIN_NAME" => "Admin",
124
- "ADMIN_EMAIL" => config.fetch(:admin_email),
125
- "ADMIN_PASSWORD" => config.fetch(:admin_password),
115
+ 'HEALTH_CHECK_PATH' => MINIMAL_HEALTH_CHECK_PATH,
116
+ 'DOMAIN_NAME' => default_service_domain_name,
117
+ 'AWS_ACCESS_KEY_ID' => s3_bucket_details.fetch(:access_key_id),
118
+ 'AWS_ACCESS_KEY_SECRET' => s3_bucket_details.fetch(:secret_access_key),
119
+ 'AWS_UPLOADS_S3_BUCKET' => s3_bucket_details.fetch(:name),
120
+ 'AWS_UPLOADS_S3_REGION' => config.fetch(:aws_region),
121
+ 'SECRET_KEY_BASE' => secret_key_base,
122
+ 'DATA_ENCRYPTION_KEY' => data_encryption_key,
123
+ 'ADMIN_NAME' => 'Admin',
124
+ 'ADMIN_EMAIL' => config.fetch(:admin_email),
125
+ 'ADMIN_PASSWORD' => config.fetch(:admin_password)
126
126
  }
127
127
 
128
- env_command_params = env.map { |k, v| "#{k}=\"#{v}\"" }.join(" ")
128
+ env_command_params = env.map { |k, v| "#{k}=\"#{v}\"" }.join(' ')
129
129
  run_convox_command! "env set #{env_command_params}"
130
130
 
131
- puts "=> Initial deploy..."
132
- puts "-----> Documentation: https://docs.convox.com/deployment/builds"
133
- run_convox_command! "deploy --wait"
131
+ puts '=> Initial deploy...'
132
+ puts '-----> Documentation: https://docs.convox.com/deployment/builds'
133
+ run_convox_command! 'deploy --wait'
134
134
 
135
- puts "=> Setting up the database..."
136
- run_convox_command! "run web rake db:create db:migrate db:seed"
135
+ puts '=> Setting up the database...'
136
+ run_convox_command! 'run web rake db:create db:migrate db:seed'
137
137
 
138
- puts "=> Updating the health check path to include database tests..."
138
+ puts '=> Updating the health check path to include database tests...'
139
139
  run_convox_command! "env set --promote --wait HEALTH_CHECK_PATH=#{COMPLETE_HEALTH_CHECK_PATH}"
140
140
 
141
141
  puts
142
- puts "All done!"
142
+ puts 'All done!'
143
143
  puts
144
144
  puts "You can now visit #{default_service_domain_name} and sign in with:"
145
145
  puts
146
146
  puts " Email: #{config.fetch(:admin_email)}"
147
147
  puts " Password: #{config.fetch(:admin_password)}"
148
148
  puts
149
- puts "You can configure a custom domain name, auto-scaling, and other options in convox.yml."
150
- puts "To deploy your changes, run: convox deploy --wait"
149
+ puts 'You can configure a custom domain name, auto-scaling, and other options in convox.yml.'
150
+ puts 'To deploy your changes, run: convox deploy --wait'
151
151
  puts
152
152
  puts "IMPORTANT: You should be very careful with the 'resources' section in convox.yml."
153
- puts "If you remove, rename, or change these resources, then Convox will delete"
154
- puts "your database. This will result in downtime and a loss of data."
155
- puts "To prevent this from happening, you can sign into your AWS account,"
156
- puts "visit the RDS and ElastiCache services, and enable \"Termination Protection\""
157
- puts "for your database resources."
153
+ puts 'If you remove, rename, or change these resources, then Convox will delete'
154
+ puts 'your database. This will result in downtime and a loss of data.'
155
+ puts 'To prevent this from happening, you can sign into your AWS account,'
156
+ puts 'visit the RDS and ElastiCache services, and enable "Termination Protection"'
157
+ puts 'for your database resources.'
158
158
  puts
159
- puts "To learn more about the convox CLI, run: convox --help"
159
+ puts 'To learn more about the convox CLI, run: convox --help'
160
160
  puts
161
- puts " * View the Convox documentation: https://docs.convox.com/"
161
+ puts ' * View the Convox documentation: https://docs.convox.com/'
162
162
  puts
163
163
  puts
164
- puts "To completely uninstall Convox from your AWS account,"
165
- puts "run the following steps (in this order):"
164
+ puts 'To completely uninstall Convox from your AWS account,'
165
+ puts 'run the following steps (in this order):'
166
166
  puts
167
- puts " 1) Disable \"Termination Protection\" for any resource where it was enabled."
167
+ puts ' 1) Disable "Termination Protection" for any resource where it was enabled.'
168
168
  puts
169
169
  puts " 2) Delete all files from the #{config.fetch(:s3_bucket_name)} S3 bucket:"
170
170
  puts
@@ -176,7 +176,7 @@ puts " 3) Delete the #{config.fetch(:s3_bucket_name)} S3 bucket:"
176
176
  puts
177
177
  puts " convox rack resources delete #{config.fetch(:s3_bucket_name)} --wait"
178
178
  puts
179
- puts " 4) Uninstall Convox (deletes all CloudFormation stacks and AWS resources):"
179
+ puts ' 4) Uninstall Convox (deletes all CloudFormation stacks and AWS resources):'
180
180
  puts
181
181
  puts " convox rack uninstall aws #{config.fetch(:stack_name)}"
182
182
  puts