@govuk-pay/cli 0.0.22 → 0.0.24

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@govuk-pay/cli",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "GOV.UK Pay Command Line Interface",
5
5
  "bin": {
6
6
  "pay": "bin/cli.js",
package/readme.md CHANGED
@@ -40,6 +40,21 @@ use the command `legacy`, for example:
40
40
 
41
41
  Please add an issue any time you need to fall back on legacy behaviour so we can improve the typescript implementation.
42
42
 
43
+ ### Config files
44
+
45
+ Config files needed by the pay cli will go in `$HOME/.pay-cli"
46
+
47
+ #### Pay Local Config Files
48
+
49
+ You can override environment variables set in the the .env files in [the pay local services local config directory](https://github.com/alphagov/pay-cli/tree/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services` for
50
+ specific containers by placing files in `$HOME/.pay-cli/local/environment-overrides/<app_name>.env`.
51
+
52
+ For example to override an environment variable for connector which was set in [connector.env](https://github.com/alphagov/pay-cli/blob/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/connector.env)
53
+ you could create the file `$HOME/.pay-cli/local/environment-overrides/connector.env`
54
+
55
+ Note: This will only override variables set in the .env files, it will not override any variables which get declared in an `environment` configuration option in the generated docker-compose files. These are generated from the
56
+ [docker-compose.erb](https://github.com/alphagov/pay-cli/blob/main/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/docker-compose.erb#L5) template.
57
+
43
58
  ## Vulnerability Disclosure
44
59
 
45
60
  GOV.UK Pay aims to stay secure for everyone. If you are a security researcher and have discovered a security vulnerability in this code, we appreciate your help in disclosing it to us in a responsible manner. Please refer to our [vulnerability disclosure policy](https://www.gov.uk/help/report-vulnerability) and our [security.txt](https://vdp.cabinetoffice.gov.uk/.well-known/security.txt) file for details.
@@ -3,8 +3,8 @@ require 'yaml'
3
3
 
4
4
  class PayCLI::Commands::Doctor
5
5
  def start!
6
+ check_workspace!
6
7
  check_ruby_version!
7
- check_path!
8
8
  check_old_pay_config_dir!
9
9
  check_secrets_file!
10
10
  check_pay_low_pass!
@@ -93,18 +93,23 @@ class PayCLI::Commands::Doctor
93
93
  end
94
94
  end
95
95
 
96
- def check_path!
97
- if ENV['PATH'] =~ %r{pay-infra/cli}
98
- STDERR.puts "✅ PATH looks okay"
99
- else
100
- STDERR.puts "🔥 PATH does not contain pay-infra/cli"
96
+ def check_workspace!
97
+ # Normally in doctor we continue to more tests, but if WORKSPACE isn't set lots of the tests will result in a crash
98
+ if ! ENV.has_key?('WORKSPACE')
99
+ STDERR.puts "🔥 WORKSPACE env var not set, it needs to be set to the directory where you check out alphagov repos"
100
+ exit 1
101
+ end
102
+
103
+ if !File.directory?(ENV['WORKSPACE'])
104
+ STDERR.puts "🔥 WORKSPACE env var not set, it needs to be set to the directory where you check out alphagov repos"
105
+ exit 1
101
106
  end
107
+
108
+ STDERR.puts "✅ WORKSPACE looks okay"
102
109
  end
103
110
 
104
111
  def check_pay_low_pass!
105
- pay_low_pass_path = File.expand_path(File.join(
106
- PayCLI::Config::PROJECT_PATH, '..', 'pay-low-pass'
107
- ))
112
+ pay_low_pass_path = File.expand_path(ENV['WORKSPACE'], 'pay-low-pass')
108
113
  if File.exist? pay_low_pass_path
109
114
  STDERR.puts "✅ pay-low-pass is in the right place"
110
115
  else
@@ -32,6 +32,9 @@ services:
32
32
  env_file:
33
33
  - services/java_app.env
34
34
  - services/<%= app[:name] %>.env
35
+ <% if File.exist?(File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env")) %>
36
+ - <%= File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env") %>
37
+ <% end %>
35
38
  environment:
36
39
  - BIND_HOST=0.0.0.0
37
40
  - RUN_MIGRATION=true
@@ -116,6 +119,9 @@ services:
116
119
  env_file:
117
120
  - services/java_app.env
118
121
  - services/<%= app[:name] %>.env
122
+ <% if File.exist?(File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env")) %>
123
+ - <%= File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env") %>
124
+ <% end %>
119
125
  environment:
120
126
  - BIND_HOST=0.0.0.0
121
127
  - RUN_MIGRATION=true
@@ -199,7 +205,11 @@ services:
199
205
  <%= app[:name] %>_db:
200
206
  condition: service_healthy
201
207
  <% end %>
202
- env_file: services/<%= app[:name] %>.env
208
+ env_file:
209
+ - services/<%= app[:name] %>.env
210
+ <% if File.exist?(File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env")) %>
211
+ - <%= File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env") %>
212
+ <% end %>
203
213
  environment:
204
214
  - BIND_HOST=0.0.0.0
205
215
  - SECURE_COOKIE_OFF=true
@@ -254,7 +264,11 @@ services:
254
264
  <%= app[:name] %>_db:
255
265
  condition: service_healthy
256
266
  <% end %>
257
- env_file: services/<%= app[:name] %>.env
267
+ env_file:
268
+ - services/<%= app[:name] %>.env
269
+ <% if File.exist?(File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env")) %>
270
+ - <%= File.join(Dir.home, ".pay-cli", "local", "environment-overrides", "#{app[:name]}.env") %>
271
+ <% end %>
258
272
  <% if @mount_local_node_apps %>
259
273
  volumes:
260
274
  - "$WORKSPACE/pay-<%= app[:name] %>:/app"
@@ -47,7 +47,19 @@ module PayCLI::Commands::Tf
47
47
 
48
48
  def self.item!(command, environment, deployment_type, args)
49
49
  account = environment.split('-').first
50
- deployment_path = [PayCLI::Config::PROJECT_PATH, 'provisioning', 'terraform', 'deployments']
50
+ if ! ENV.has_key?('WORKSPACE')
51
+ STDERR.puts 'Error: You must set your WORKSPACE env var to the directory where you checkout alphagov github projects'
52
+ exit 1
53
+ end
54
+
55
+ pay_infra_path = File.join(ENV['WORKSPACE'], 'pay-infra')
56
+
57
+ if ! File.directory?(pay_infra_path)
58
+ STDERR.puts "Error: #{pay_infra_path} is not a directory. Do you need to check out pay-infra?"
59
+ exit 1
60
+ end
61
+
62
+ deployment_path = [pay_infra_path, 'provisioning', 'terraform', 'deployments']
51
63
  if account == environment
52
64
  deployment_path += [account, deployment_type]
53
65
  else
@@ -17,9 +17,7 @@ module PayCLI::Config
17
17
  performance
18
18
  ).freeze
19
19
 
20
- PROJECT_PATH = File.expand_path("../../..", __dir__)
21
-
22
- CLI_PATH = File.join PROJECT_PATH, 'cli'
20
+ CLI_PATH = File.expand_path(File.join(__dir__, '..', '..'))
23
21
  CONFIG_PATH = File.join CLI_PATH, 'config'
24
22
  LOCAL_SECRETS_PATH = File.expand_path(
25
23
  File.join('~', '.govuk-pay', 'secrets.yml')
@@ -129,11 +129,16 @@ module PayCLI::Secrets
129
129
  end
130
130
 
131
131
  def self.fetch_pay_pass!(env, service, key, provider, pass_path)
132
+ if ENV.has_key?('WORKSPACE')
133
+ STDERR.puts 'Error: You must set your WORKSPACE env var to the directory where you checkout alphagov github projects'
134
+ exit 1
135
+ end
136
+
132
137
  path = File.expand_path(File.join(
133
- PayCLI::Config::PROJECT_PATH, '..', provider
138
+ ENV['WORKSPACE'], provider
134
139
  ))
135
140
 
136
- abort "Path #{path} doesn't exist" unless File.exist? path
141
+ abort "Path #{path} doesn't exist or isn't a directory" unless File.directory? path
137
142
 
138
143
  STDERR.puts "Pulling secret #{key} from #{path} for #{service}"
139
144
  fetch_pass! path, pass_path