@govuk-pay/cli 0.0.3 → 0.0.4

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.
Files changed (89) hide show
  1. package/package.json +1 -1
  2. package/resources/legacy-ruby-cli/.rspec +1 -0
  3. package/resources/legacy-ruby-cli/.rubocop.yml +26 -0
  4. package/resources/legacy-ruby-cli/.ruby-version +1 -0
  5. package/resources/legacy-ruby-cli/Gemfile +24 -0
  6. package/resources/legacy-ruby-cli/Gemfile.lock +1431 -0
  7. package/resources/legacy-ruby-cli/README.md +142 -0
  8. package/resources/legacy-ruby-cli/bin/pay +31 -0
  9. package/resources/legacy-ruby-cli/config/generate-secrets.yml +9 -0
  10. package/resources/legacy-ruby-cli/config/secrets.yml +581 -0
  11. package/resources/legacy-ruby-cli/config/service_secrets.yml +174 -0
  12. package/resources/legacy-ruby-cli/lib/pay_cli/aws/document.rb +23 -0
  13. package/resources/legacy-ruby-cli/lib/pay_cli/aws/services.rb +47 -0
  14. package/resources/legacy-ruby-cli/lib/pay_cli/aws/tokens.rb +161 -0
  15. package/resources/legacy-ruby-cli/lib/pay_cli/commands/aws.rb +51 -0
  16. package/resources/legacy-ruby-cli/lib/pay_cli/commands/browse.rb +31 -0
  17. package/resources/legacy-ruby-cli/lib/pay_cli/commands/doctor.rb +154 -0
  18. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/app_client.rb +216 -0
  19. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.rb +138 -0
  20. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/config.yaml +192 -0
  21. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/docker.rb +36 -0
  22. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/docker-compose.erb +270 -0
  23. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/end-to-end.erb +30 -0
  24. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/localstack/init-aws.sh +70 -0
  25. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/naxsi/readme.md +1 -0
  26. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/postgres/docker-entrypoint-initdb.d/make_payments_databases.sql +26 -0
  27. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/adminusers.env +49 -0
  28. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/cardid.env +2 -0
  29. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/connector.env +70 -0
  30. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/demo-service.env +10 -0
  31. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/frontend.env +12 -0
  32. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/java_app.env +1 -0
  33. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ledger.env +7 -0
  34. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products-ui.env +14 -0
  35. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/products.env +25 -0
  36. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicapi.env +13 -0
  37. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/publicauth.env +13 -0
  38. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/selfservice.env +21 -0
  39. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/frontend-proxy.crt +18 -0
  40. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/products-ui-proxy.crt +20 -0
  41. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/selfservice-proxy.crt +20 -0
  42. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/certs/stubs-proxy.crt +18 -0
  43. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/frontend-proxy.key +28 -0
  44. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/products-ui-proxy.key +28 -0
  45. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/selfservice-proxy.key +28 -0
  46. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/keys/stubs-proxy.key +28 -0
  47. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/ssl/make-selfsigned.sh +2 -0
  48. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/stubs.env +12 -0
  49. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/toolbox.env +5 -0
  50. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/files/services/webhooks.env +9 -0
  51. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local/image_extractor.rb +20 -0
  52. package/resources/legacy-ruby-cli/lib/pay_cli/commands/local.rb +430 -0
  53. package/resources/legacy-ruby-cli/lib/pay_cli/commands/schema.rb +36 -0
  54. package/resources/legacy-ruby-cli/lib/pay_cli/commands/secrets.rb +114 -0
  55. package/resources/legacy-ruby-cli/lib/pay_cli/commands/ssm.rb +111 -0
  56. package/resources/legacy-ruby-cli/lib/pay_cli/commands/tf.rb +90 -0
  57. package/resources/legacy-ruby-cli/lib/pay_cli/commands/tunnel/services.yml +49 -0
  58. package/resources/legacy-ruby-cli/lib/pay_cli/config.rb +27 -0
  59. package/resources/legacy-ruby-cli/lib/pay_cli/ec2.rb +38 -0
  60. package/resources/legacy-ruby-cli/lib/pay_cli/entry_point.rb +52 -0
  61. package/resources/legacy-ruby-cli/lib/pay_cli/environment.rb +25 -0
  62. package/resources/legacy-ruby-cli/lib/pay_cli/logger.rb +3 -0
  63. package/resources/legacy-ruby-cli/lib/pay_cli/logs.rb +248 -0
  64. package/resources/legacy-ruby-cli/lib/pay_cli/naming.rb +44 -0
  65. package/resources/legacy-ruby-cli/lib/pay_cli/secrets.rb +276 -0
  66. package/resources/legacy-ruby-cli/lib/pay_cli/stop_yubico_authenticator.rb +10 -0
  67. package/resources/legacy-ruby-cli/lib/pay_cli/ykman_oath_credential_config.rb +70 -0
  68. package/resources/legacy-ruby-cli/lib/zeitwerk_setup.rb +5 -0
  69. package/resources/legacy-ruby-cli/package-lock.json +6 -0
  70. package/resources/legacy-ruby-cli/rds_access/connect.sh +149 -0
  71. package/resources/legacy-ruby-cli/spec/.rubocop.yml +2 -0
  72. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex +34 -0
  73. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.complex_differing_froms +33 -0
  74. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.no_from +3 -0
  75. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple +5 -0
  76. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.simple_no_tag +5 -0
  77. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha +5 -0
  78. package/resources/legacy-ruby-cli/spec/fixtures/dockerfile_examples/Dockerfile.with_sha_no_tag +5 -0
  79. package/resources/legacy-ruby-cli/spec/lib/pay_cli/commands/local/image_extractor_spec.rb +55 -0
  80. package/resources/legacy-ruby-cli/spec/naming_spec.rb +83 -0
  81. package/resources/legacy-ruby-cli/spec/spec_helper.rb +106 -0
  82. package/resources/legacy-ruby-cli/vulnerability_scan/.nvmrc +1 -0
  83. package/resources/legacy-ruby-cli/vulnerability_scan/generate_vulnerability_report.js +91 -0
  84. package/resources/legacy-ruby-cli/vulnerability_scan/reports/.gitkeep +0 -0
  85. package/resources/legacy-ruby-cli/vulnerability_scan/scan.sh +57 -0
  86. package/src/commands/browse.js +2 -2
  87. package/src/commands/legacy.js +3 -2
  88. package/src/core/constants.js +7 -10
  89. package/src/util/payCliExec.js +18 -1
@@ -0,0 +1,142 @@
1
+ # pay-cli
2
+
3
+ ## getting started
4
+
5
+ ### run
6
+
7
+ ```
8
+ cd $PRJ_ROOT/cli
9
+ rbenv install
10
+ rbenv exec gem install bundler
11
+ bundle install
12
+ ```
13
+
14
+ (if you receive an error relating to `nokogiri` try running:
15
+
16
+ ```
17
+ gem install nokogiri -v 1.8.4 -- --use-system-libraries=true --with-xml2-include="$(xcrun --show-sdk-path)"/usr/include/libxml2
18
+ ```
19
+
20
+ then re-running `bundle install`)
21
+
22
+ ### add the following to your `.bash_profile`, `.bashrc`, or `.zshrc`
23
+
24
+ In all of the following examples replace `~/Code/pay-infra` or `$HOME/Code/pay-infra` with the path where you have the
25
+ pay-infra repo checked out.
26
+
27
+ Either:
28
+ ```
29
+ export PATH="$PATH:~/Code/pay-infra/cli/bin"
30
+ ```
31
+
32
+ or if you want to avoid ruby version conflicts then you can instead use the following function
33
+
34
+ ```
35
+ function pay {
36
+ pushd "$HOME/Code/pay-infra/cli" >>/dev/null 2>&1 || return
37
+ rbenv exec bundle exec bin/pay "$@"
38
+ popd >>/dev/null 2>&1 || return
39
+ }
40
+ ```
41
+
42
+ ### add a basic secrets file
43
+
44
+ ```
45
+ mkdir $HOME/.govuk-pay
46
+ cat <<EOF > $HOME/.govuk-pay/secrets.yml
47
+ ---
48
+ dev-toby-3:
49
+ terraform:
50
+ ADMINUSERS_RDS_PASSWORD: dev-env-rds-password
51
+ CONNECTOR_RDS_PASSWORD: dev-env-rds-password
52
+ LEDGER_RDS_PASSWORD: dev-env-rds-password
53
+ PRODUCTS_RDS_PASSWORD: dev-env-rds-password
54
+ PUBLICAUTH_RDS_PASSWORD: dev-env-rds-password
55
+ ANALYTICS_TRACKING_ID: something
56
+
57
+ test-12: {}
58
+ EOF
59
+ ```
60
+
61
+ Add the secrets to cli/config/secrets.yml under the local provider
62
+ ```
63
+ local:
64
+ dev-toby-3:
65
+ terraform:
66
+ - ADMINUSERS_RDS_PASSWORD
67
+ - CONNECTOR_RDS_PASSWORD
68
+ - PRODUCTS_RDS_PASSWORD
69
+ - PUBLICAUTH_RDS_PASSWORD
70
+ ```
71
+
72
+ ## read the usage (list all commands)
73
+
74
+ ```
75
+ pay
76
+ ```
77
+
78
+ ## read the usage (individual command example)
79
+
80
+ ```
81
+ pay healthcheck
82
+ # run a healthcheck on a dev-env
83
+ pay healthcheck dev
84
+ # run a healthcheck on a dev-env for only ecs
85
+ pay healthcheck dev 'dd|ecs'
86
+ ```
87
+
88
+ ```
89
+ pay tf
90
+ # deploy a dev-env
91
+ pay tf apply environment dev-toby-3
92
+ # deploy a microservice
93
+ pay tf apply microservice dev-toby-3 cardid
94
+ ```
95
+
96
+ ## aims
97
+
98
+ Instead of saved command documents and pasting commands, we automate and
99
+ document command tasks.
100
+
101
+ The automation should do all the setting up of accounts for us, things like:
102
+ - AWS_ACCOUNT
103
+ - AWS_PROFILE
104
+ - DEPLOY_ENV
105
+ - AWS_RESOURCE
106
+
107
+ ## Developing
108
+
109
+ ### Linting
110
+
111
+ Linting is provided by rubocop which is included in the development dependencies in the Gemfile.
112
+
113
+ You should ensure your editor of choice is setup to use rubocop as a linter.
114
+
115
+ You can execute rubocop manually on a single file by running:
116
+
117
+ ```
118
+ bundle exec rubocop <file_path>
119
+ ```
120
+
121
+ ### Tests
122
+
123
+ Rspec is used as the test runner in pay cli. All files with tests in need to have a filename which ends in `_spec.rb`
124
+ and be placed in the `spec` directory. It's usual to include them in a directory hierarchy which matches the file
125
+ under test. E.g. for `lib/pay_cli/my_file.rb` would have it's unit tests in `spec/lib/pay_cli/my_file_spec.rb`.
126
+
127
+ To run all the tests, from the root of the project you can run:
128
+
129
+ ```
130
+ bundle exec rspec
131
+ ```
132
+
133
+ You can run the tests in a single file by adding the filepath:
134
+
135
+ ```
136
+ bundle exec rspec spec/lib/pay_cli/commands/local/image_extractor_spec.rb
137
+ ```
138
+
139
+ You can run a single spec by adding the line number:
140
+ ```
141
+ bundle exec rspec spec/lib/pay_cli/commands/local/image_extractor_spec.rb:11
142
+ ```
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if $stdout.isatty
4
+ banner = <<-BANNER
5
+
6
+ ____
7
+ / __ \____ ___ __
8
+ / /_/ / __ `/ / / /
9
+ / ____/ /_/ / /_/ /
10
+ /_/ \__,_/\__, /
11
+ /____/
12
+
13
+ BANNER
14
+ STDERR.puts banner
15
+ end
16
+
17
+ begin
18
+ require 'bundler/setup'
19
+ require File.expand_path(__dir__) + "/../lib/zeitwerk_setup"
20
+
21
+ PayCLI::EntryPoint.start
22
+ rescue LoadError => e
23
+ STDERR.puts %{
24
+ 💥 Oops! Looks like a ruby library is missing.
25
+
26
+ To install the required libraries run `bundle install` from within your pay-infra/cli folder:
27
+
28
+ $ cd #{File.expand_path("..", __dir__)}; bundle install
29
+ }
30
+ abort
31
+ end
@@ -0,0 +1,9 @@
1
+ products-ui:
2
+ SESSION_ENCRYPTION_KEY: random:20
3
+
4
+ selfservice:
5
+ SESSION_ENCRYPTION_KEY: random:20
6
+
7
+ frontend:
8
+ SESSION_ENCRYPTION_KEY: random:20
9
+ SESSION_ENCRYPTION_KEY_2: random:20