cpl 1.1.2 → 1.3.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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/check_cpln_links.yml +19 -0
  3. data/.github/workflows/rspec.yml +1 -1
  4. data/.overcommit.yml +3 -0
  5. data/CHANGELOG.md +47 -2
  6. data/CONTRIBUTING.md +2 -6
  7. data/Gemfile.lock +8 -8
  8. data/README.md +57 -15
  9. data/docs/commands.md +29 -23
  10. data/docs/dns.md +9 -0
  11. data/docs/migrating.md +3 -3
  12. data/examples/controlplane.yml +67 -4
  13. data/lib/command/apply_template.rb +2 -1
  14. data/lib/command/base.rb +62 -0
  15. data/lib/command/build_image.rb +5 -1
  16. data/lib/command/config.rb +0 -5
  17. data/lib/command/copy_image_from_upstream.rb +5 -4
  18. data/lib/command/delete.rb +40 -11
  19. data/lib/command/env.rb +1 -0
  20. data/lib/command/generate.rb +45 -0
  21. data/lib/command/info.rb +15 -33
  22. data/lib/command/latest_image.rb +1 -0
  23. data/lib/command/maintenance.rb +9 -4
  24. data/lib/command/maintenance_off.rb +8 -4
  25. data/lib/command/maintenance_on.rb +8 -4
  26. data/lib/command/no_command.rb +1 -0
  27. data/lib/command/ps.rb +5 -1
  28. data/lib/command/run.rb +20 -23
  29. data/lib/command/run_detached.rb +38 -30
  30. data/lib/command/setup_app.rb +3 -3
  31. data/lib/command/version.rb +1 -0
  32. data/lib/core/config.rb +194 -66
  33. data/lib/core/controlplane.rb +28 -7
  34. data/lib/core/controlplane_api.rb +13 -1
  35. data/lib/core/controlplane_api_direct.rb +18 -2
  36. data/lib/core/helpers.rb +16 -0
  37. data/lib/core/shell.rb +25 -3
  38. data/lib/cpl/version.rb +1 -1
  39. data/lib/cpl.rb +32 -3
  40. data/lib/generator_templates/Dockerfile +27 -0
  41. data/lib/generator_templates/controlplane.yml +57 -0
  42. data/lib/generator_templates/entrypoint.sh +8 -0
  43. data/lib/generator_templates/templates/gvc.yml +21 -0
  44. data/lib/generator_templates/templates/postgres.yml +176 -0
  45. data/lib/generator_templates/templates/rails.yml +36 -0
  46. data/script/check_cpln_links +45 -0
  47. metadata +14 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89a038d31fb497bfc6c0d34451ace68fe554d700f4686413a1919cf6d9bceb09
4
- data.tar.gz: 3c733b43e703ad7b7798cf599b71f59ea1758ce2c71babd4486670c5ed5f12a3
3
+ metadata.gz: d76f46cb9427fc137ece07123d0ddd0d1add98e1ffa046a95e1394916784676e
4
+ data.tar.gz: 266681f356c78d8a4636ae27cb90485a49eda80c27a6199bd3505ddd72cd3451
5
5
  SHA512:
6
- metadata.gz: 325eecc73176b362c4b898632e45040544ecfdda14ecfbbd655caf92d0912aa3e431fbd8ac90c2681d4a2bcff68db0a71f80813601c1cf3b3ca32d44c9ef033f
7
- data.tar.gz: 0c0c04c6f1d4d57114d50d603fabfbd3470da4f373f48b091991e228306080f47bd3643e5c5c706fe9e3992e661b656b4634c881ee0861b79fbfa1f63a60d8e5
6
+ metadata.gz: 33f9ec2f7af612611d3a55114097f21a2a2cc9605b3bd2813345b9a06f8308a28d204bd71f49f96e2d1a77798e920621651e457801d795b40f3bf51abe91e985
7
+ data.tar.gz: d2c82fb6b24cf54e306e83f21b0c8a1b519147e1f8ec66b81442b2ae05f2c752eb18c60cb94c66c2cd11ea921db228116b2bc3ead49c77f1317ce0aa4e290ff1
@@ -0,0 +1,19 @@
1
+ name: Check Links
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ check_cpln_links:
11
+ runs-on: ubuntu-latest
12
+ name: Check Links
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v3
16
+ - name: Validate outgoing links to Control Plane
17
+ run: |
18
+ TERM=xterm-color ./script/check_cpln_links
19
+ shell: bash
@@ -36,5 +36,5 @@ jobs:
36
36
  uses: actions/upload-artifact@master
37
37
  if: always()
38
38
  with:
39
- name: coverage-report
39
+ name: coverage-report-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.ruby }}
40
40
  path: coverage
data/.overcommit.yml CHANGED
@@ -1,4 +1,7 @@
1
1
  PreCommit:
2
+ ValidateLinks:
3
+ enabled: true
4
+ command: ["bash", "./script/check_cpln_links"]
2
5
  CommandDocs:
3
6
  enabled: true
4
7
  command: ["bundle", "exec", "rake", "check_command_docs"]
data/CHANGELOG.md CHANGED
@@ -14,6 +14,50 @@ Changes since the last non-beta release.
14
14
 
15
15
  _Please add entries here for your pull requests that are not yet released._
16
16
 
17
+ ### Fixed
18
+
19
+ - Fixed issue where cpln profile was not switched back to `default` if an error happened while running `copy-image-from-upstream` command. [PR 135](https://github.com/shakacode/heroku-to-control-plane/pull/135) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
20
+ - Fixed issue that didn't allow using upstream with `match_if_app_name_starts_with` set to `true` in `copy-image-from-upstream` command. [PR 136](https://github.com/shakacode/heroku-to-control-plane/pull/136) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
21
+
22
+ ### Added
23
+
24
+ - Added `--no-clean-on-failure` option to `run:detached` command to skip deletion of failed workload run. [PR 133](https://github.com/shakacode/heroku-to-control-plane/pull/133) by [Justin Gordon](https://github.com/justin808) and [Rafael Gomes](https://github.com/rafaelgomesxyz).
25
+ - Added `--domain` option to `maintenance`, `maintenance:on` and `maintenance:off` commands. [PR 131](https://github.com/shakacode/heroku-to-control-plane/pull/131) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
26
+ - Added `default_domain` config to specify domain for `maintenance`, `maintenance:on` and `maintenance:off` commands. [PR 131](https://github.com/shakacode/heroku-to-control-plane/pull/131) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
27
+ - Added option to specify upstream for `copy-image-from-upstream` command through `CPLN_UPSTREAM` env var. [PR 138](https://github.com/shakacode/heroku-to-control-plane/pull/138) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
28
+
29
+ ### Changed
30
+
31
+ - `build-image` command now accepts extra options and passes them to `docker build`. [PR 126](https://github.com/shakacode/heroku-to-control-plane/pull/126) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
32
+ - `CPLN_ORG_UPSTREAM` env var now takes precedence over config from `controlplane.yml` in `copy-image-from-upstream` command. [PR 137](https://github.com/shakacode/heroku-to-control-plane/pull/137) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
33
+ - `info` command now works properly for apps with `match_if_app_name_starts_with` set to `true`.[PR 139](https://github.com/shakacode/heroku-to-control-plane/pull/139) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
34
+ - `info` command now lists workloads in the same order as `controlplane.yml`. [PR 139](https://github.com/shakacode/heroku-to-control-plane/pull/139) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
35
+ - Improved domain workload matching for `maintenance`, `maintenance:on` and `maintenance:off` commands (instead of matching only by workload, it now matches by org + app + workload, which is more accurate). [PR 140](https://github.com/shakacode/heroku-to-control-plane/pull/140) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
36
+
37
+ ## [1.2.0] - 2024-01-03
38
+
39
+ ### Fixed
40
+
41
+ - Fixed issue where `info` command does not respect `CPLN_ORG` env var. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
42
+ - Fixed issues with running `cpl --version` and `cpl --help` where no configuration file exists. [PR 100](https://github.com/shakacode/heroku-to-control-plane/pull/100) by [Mostafa Ahangarha](https://github.com/ahangarha).
43
+ - Fixed issue where `delete` command fails to delete apps with volumesets. [PR 123](https://github.com/shakacode/heroku-to-control-plane/pull/123) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
44
+
45
+ ### Added
46
+
47
+ - Added `--org` option to all commands. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
48
+ - Added option to set the app with a `CPLN_APP` env var. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
49
+ - Show `org` and `app` on every command excluding `info`, `version`, `maintenance`, `env`, `ps`, and `latest_image`. [PR 94](https://github.com/shakacode/heroku-to-control-plane/pull/94) by [Mostafa Ahangarha](https://github.com/ahangarha).
50
+ - Added option to only use `CPLN_ORG` and `CPLN_APP` env vars if `allow_org_override_by_env` and `allow_app_override_by_env` configs are set to `true` in `controlplane.yml`. [PR 109](https://github.com/shakacode/heroku-to-control-plane/pull/109) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
51
+ - Added `CPLN_LOCATION` env variable and `--location` option for `apply-template`, `ps`, `run`, `run:detached`. [PR 105](https://github.com/shakacode/heroku-to-control-plane/pull/105) by [Mostafa Ahangarha](https://github.com/ahangarha).
52
+ - Added `generate` command for creating basic Control Plane configuration directory. [PR 116](https://github.com/shakacode/heroku-to-control-plane/pull/116) by [Mostafa Ahangarhga](https://github.com/ahangarha).
53
+ - Added `--trace` option to all commands for more detailed logs. [PR 124](https://github.com/shakacode/heroku-to-control-plane/pull/124) by [justin808](https://github.com/justin808)
54
+ - Added better error message to check the org name in case of a 403 error. [PR 124](https://github.com/justin808) by [justin808](https://github.com/justin808)
55
+
56
+ ### Changed
57
+
58
+ - `--org` option now takes precedence over `CPLN_ORG` env var, which takes precedence over `cpln_org` from `controlplane.yml`. [PR 88](https://github.com/shakacode/heroku-to-control-plane/pull/88) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
59
+ - Renamed `setup` config into `setup_app_templates`. [PR 112](https://github.com/shakacode/heroku-to-control-plane/pull/112) by [Mostafa Ahangarha](https://github.com/ahangarha).
60
+
17
61
  ## [1.1.2] - 2023-10-17
18
62
 
19
63
  ### Fixed
@@ -23,7 +67,7 @@ _Please add entries here for your pull requests that are not yet released._
23
67
  ### Added
24
68
 
25
69
  - Added `open-console` command to open the app console on Control Plane. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
26
- - Added option to set the org with a `CPLN_ORG` env var. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
70
+ - Added option to set the org with a `CPLN_ORG`/`CPLN_ORG_UPSTREAM` env var. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
27
71
  - Added `--verbose` option to all commands for more detailed logs. [PR 83](https://github.com/shakacode/heroku-to-control-plane/pull/83) by [Rafael Gomes](https://github.com/rafaelgomesxyz).
28
72
 
29
73
  ### Changed
@@ -95,7 +139,8 @@ _Please add entries here for your pull requests that are not yet released._
95
139
 
96
140
  - Initial release
97
141
 
98
- [Unreleased]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.2...HEAD
142
+ [Unreleased]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.2.0...HEAD
143
+ [1.2.0]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.2...v1.2.0
99
144
  [1.1.2]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.1...v1.1.2
100
145
  [1.1.1]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.1.0...v1.1.1
101
146
  [1.1.0]: https://github.com/shakacode/heroku-to-control-plane/compare/v1.0.4...v1.1.0
data/CONTRIBUTING.md CHANGED
@@ -12,12 +12,6 @@ git clone https://github.com/shakacode/heroku-to-control-plane
12
12
  alias cpl="~/projects/heroku-to-control-plane/bin/cpl"
13
13
  ```
14
14
 
15
- Or set the path of the Ruby gem in your Gemfile.
16
-
17
- ```ruby
18
- gem 'cpl', path: '~/projects/heroku-to-control-plane'
19
- ```
20
-
21
15
  ## Linting/Testing
22
16
 
23
17
  Before committing or pushing code, be sure to:
@@ -36,6 +30,8 @@ overcommit --install
36
30
 
37
31
  ## Debugging
38
32
 
33
+ 1. Use the `--verbose` option to see more detailed logs.
34
+ 2. Use the `--trace` option to see full logging of HTTP requests. Warning, this will display keys to your logs or console.
39
35
  1. Add a breakpoint (`debugger`) to any line of code you want to debug.
40
36
  2. Modify the `lib/command/test.rb` file to trigger the code you want to test. To simulate a command, you can use
41
37
  `Cpl::Cli.start` (e.g., `Cpl::Cli.start(["deploy-image", "-a", "my-app-name"])` would be the same as running
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cpl (1.1.2)
4
+ cpl (1.3.0)
5
5
  debug (~> 1.7.1)
6
6
  dotenv (~> 2.8.1)
7
7
  psych (~> 5.1.0)
@@ -24,10 +24,10 @@ GEM
24
24
  dotenv (2.8.1)
25
25
  hashdiff (1.0.1)
26
26
  iniparse (1.5.0)
27
- io-console (0.6.0)
28
- irb (1.8.3)
27
+ io-console (0.7.2)
28
+ irb (1.12.0)
29
29
  rdoc
30
- reline (>= 0.3.8)
30
+ reline (>= 0.4.2)
31
31
  json (2.6.3)
32
32
  overcommit (0.60.0)
33
33
  childprocess (>= 0.6.3, < 5)
@@ -36,15 +36,15 @@ GEM
36
36
  parallel (1.22.1)
37
37
  parser (3.2.0.0)
38
38
  ast (~> 2.4.1)
39
- psych (5.1.1.1)
39
+ psych (5.1.2)
40
40
  stringio
41
41
  public_suffix (5.0.1)
42
42
  rainbow (3.1.1)
43
43
  rake (13.0.6)
44
- rdoc (6.5.0)
44
+ rdoc (6.6.2)
45
45
  psych (>= 4.0.0)
46
46
  regexp_parser (2.6.2)
47
- reline (0.3.9)
47
+ reline (0.4.3)
48
48
  io-console (~> 0.5)
49
49
  rexml (3.2.5)
50
50
  rspec (3.12.0)
@@ -86,7 +86,7 @@ GEM
86
86
  simplecov_json_formatter (~> 0.1)
87
87
  simplecov-html (0.12.3)
88
88
  simplecov_json_formatter (0.1.4)
89
- stringio (3.0.8)
89
+ stringio (3.1.0)
90
90
  thor (1.2.2)
91
91
  timecop (0.9.6)
92
92
  unicode-display_width (2.4.2)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Heroku to Control Plane `cpl` CLI
1
+ # The power of Kubernetes with the ease of Heroku!
2
2
 
3
3
  <meta name="author" content="Justin Gordon and Sergey Tarasov">
4
4
  <meta name="description" content="Instructions on how to migrate from Heroku to Control Plane and a CLI called cpl to make it easier.">
@@ -6,13 +6,27 @@
6
6
  <meta name="keywords" content="Control Plane, Heroku, Kubernetes, K8, Infrastructure">
7
7
  <meta name="google-site-verification" content="dIV4nMplcYl6YOKOaZMqgvdKXhLJ4cdYY6pS6e_YrPU" />
8
8
 
9
- _A gem that provides **Heroku Flow** functionality on Control Plane, including docs for migrating from [Heroku](https://heroku.com) to [Control Plane](https://controlplane.com)_
10
-
11
9
  [![RSpec](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rspec.yml/badge.svg)](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rspec.yml)
12
10
  [![Rubocop](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rubocop.yml/badge.svg)](https://github.com/shakacode/heroku-to-control-plane/actions/workflows/rubocop.yml)
13
11
 
14
12
  [![Gem](https://badge.fury.io/rb/cpl.svg)](https://badge.fury.io/rb/cpl)
15
13
 
14
+
15
+ Here's a playbook for migrating from [Heroku Flow](https://www.heroku.com/flow) to [Control Plane](https://shakacode.controlplane.com) with our `cpl` gem source code.
16
+
17
+ ----
18
+
19
+ _If you need a free demo account for Control Plane (no CC required), you can contact [Justin Gordon, CEO of ShakaCode](mailto:justin@shakacode.com)._
20
+
21
+ ---
22
+
23
+ Be sure to see the [demo app](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/.controlplane)
24
+ If you would like to see the simple YAML configuration and setup,
25
+ Also, check [how the `cpl` gem (this project) is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
26
+ Here is a brief [video overview](https://www.youtube.com/watch?v=llaQoAV_6Iw).
27
+
28
+ ---
29
+
16
30
  This playbook shows how to move "Heroku apps" to "Control Plane workloads" via an open-source `cpl` CLI on top of
17
31
  Control Plane's `cpln` CLI.
18
32
 
@@ -90,7 +104,7 @@ For the typical Rails app, this means:
90
104
 
91
105
  ## Installation
92
106
 
93
- 1. Ensure your [Control Plane](https://controlplane.com) account is set up. Set up an `organization` <your-org> for testing in that account and modify the value for `aliases.common.cpln_org` in `.controlplane/controlplane.yml`, or you can also set it with the `CPLN_ORG` environment variable. If you need an organization, please [contact Shakacode](mailto:controlplane@shakacode.com).
107
+ 1. Ensure your [Control Plane](https://shakacode.controlplane.com/) account is set up. Set up an `organization` `<your-org>` for testing in that account and modify the value for `aliases.common.cpln_org` in `.controlplane/controlplane.yml`, or you can also set it with the `CPLN_ORG` environment variable. If you need an organization, please [contact Shakacode](mailto:controlplane@shakacode.com).
94
108
 
95
109
  2. Install [Node.js](https://nodejs.org/en) (required for Control Plane CLI).
96
110
 
@@ -111,8 +125,7 @@ npm update -g @controlplane/cli
111
125
 
112
126
  5. Run `cpln image docker-login --org <your-org>` to ensure that you have access to the Control Plane Docker registry.
113
127
 
114
- 6. Install Heroku to Control Plane `cpl` CLI, either as a [Ruby gem](https://rubygems.org/gems/cpl) or a local clone.
115
- For information on the latter, see [CONTRIBUTING.md](CONTRIBUTING.md). You may also install `cpl` in your project's Gemfile.
128
+ 6. Install Heroku to Control Plane `cpl` CLI as a [Ruby gem](https://rubygems.org/gems/cpl): `gem install cpl`. If you want to hack on the source code, see [CONTRIBUTING.md](CONTRIBUTING.md).
116
129
 
117
130
  7. You can use [this Dockerfile](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/Dockerfile) as an example for your project. Ensure that you have Docker running.
118
131
 
@@ -138,7 +151,7 @@ The `cpl` gem is based on several configuration files within a `/.controlplane`
138
151
  ├─ entrypoint.sh
139
152
  ```
140
153
 
141
- 1. `controlplane.yml` describes the overall application. Be sure to have <your-org> as the value for `aliases.common.cpln_org`, or set it with the `CPLN_ORG` environment variable.
154
+ 1. `controlplane.yml` describes the overall application. Be sure to have `<your-org>` as the value for `aliases.common.cpln_org`, or set it with the `CPLN_ORG` environment variable.
142
155
  2. `Dockerfile` builds the production application. `entrypoint.sh` is an _example_ entrypoint script for the production application, referenced in your Dockerfile.
143
156
  3. `templates` directory contains the templates for the various workloads, such as `rails.yml` and `postgres.yml`.
144
157
  4. `templates/gvc.yml` defines your project's GVC (like a Heroku app). More importantly, it contains ENV values for the app.
@@ -153,18 +166,31 @@ Here's a complete example of all supported config keys explained for the `contro
153
166
  ```yaml
154
167
  # Keys beginning with "cpln_" correspond to your settings in Control Plane.
155
168
 
169
+ # Global settings that apply to `cpl` usage.
170
+ # You can opt out of allowing the use of CPLN_ORG and CPLN_APP env vars
171
+ # to avoid any accidents with the wrong org / app.
172
+ allow_org_override_by_env: true
173
+ allow_app_override_by_env: true
174
+
156
175
  aliases:
157
176
  common: &common
158
- # Organization name for staging (customize to your needs).
159
- # Production apps will use a different organization, specified below, for security.
177
+ # Organization for staging and QA apps is typically set as an alias.
178
+ # Production apps will use a different organization, specified in `apps`, for security.
179
+ # Change this value to your organization name
180
+ # or set the CPLN_ORG env var and it will override this for all `cpl` commands
181
+ # (provided that `allow_org_override_by_env` is set to `true`).
160
182
  cpln_org: my-org-staging
161
183
 
162
- # Example apps use only one location. Control Plane offers the ability to use multiple locations.
184
+ # Control Plane offers the ability to use multiple locations.
185
+ # default_location is used for commands that require a location
186
+ # including `ps`, `run`, `run:detached`, `apply-template`.
187
+ # This can be overridden with option --location=<location> and
188
+ # CPLN_LOCATION environment variable.
163
189
  default_location: aws-us-east-2
164
190
 
165
191
  # Allows running the command `cpl setup-app`
166
192
  # instead of `cpl apply-template gvc redis postgres memcached rails sidekiq`.
167
- setup:
193
+ setup_app_templates:
168
194
  - gvc
169
195
  - redis
170
196
  - postgres
@@ -224,6 +250,11 @@ apps:
224
250
  my-app-production:
225
251
  <<: *common
226
252
 
253
+ # You can also opt out of allowing the use of CPLN_ORG and CPLN_APP env vars per app.
254
+ # It's recommended to leave this off for production, to avoid any accidents.
255
+ allow_org_override_by_env: false
256
+ allow_app_override_by_env: false
257
+
227
258
  # Use a different organization for production.
228
259
  cpln_org: my-org-production
229
260
 
@@ -235,6 +266,10 @@ apps:
235
266
  # This is relative to the `.controlplane/` directory.
236
267
  release_script: release_script
237
268
 
269
+ # default_domain is used for commands that require a domain
270
+ # including `maintenance`, `maintenance:on`, `maintenance:off`.
271
+ default_domain: domain.com
272
+
238
273
  my-app-other:
239
274
  <<: *common
240
275
 
@@ -255,7 +290,7 @@ Suppose your app is called `tutorial-app`. You can run the following commands.
255
290
  ```sh
256
291
  # Provision all infrastructure on Control Plane.
257
292
  # `tutorial-app` will be created per definition in .controlplane/controlplane.yml.
258
- cpl apply-template gvc postgres redis rails -a tutorial-app
293
+ cpl apply-template gvc postgres redis rails daily-task -a tutorial-app
259
294
 
260
295
  # Build and push the Docker image to the Control Plane repository.
261
296
  # Note, it may take many minutes. Be patient.
@@ -405,7 +440,7 @@ spec:
405
440
  type: cron
406
441
  job:
407
442
  # Run daily job at 2am.
408
- schedule: 0 2 * * *
443
+ schedule: "0 2 * * *"
409
444
  # "Never" or "OnFailure"
410
445
  restartPolicy: Never
411
446
  containers:
@@ -452,6 +487,13 @@ cpl --help
452
487
 
453
488
  ## Examples
454
489
 
455
- - See the `examples/` and `templates/` directories of this repository.
490
+ - See this repository's `examples/` and `templates/` directories.
456
491
  - See the `.controlplane/` directory of this live example:
457
- [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/.controlplane)
492
+ [react-webpack-rails-tutorial](https://github.com/shakacode/react-webpack-rails-tutorial/tree/master/.controlplane).
493
+ - See [how the `cpl` gem is used in the Github actions](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.github/actions/deploy-to-control-plane/action.yml).
494
+ - Here is a brief [video overview](https://www.youtube.com/watch?v=llaQoAV_6Iw).
495
+
496
+ ## Resources
497
+ * If you need a free demo account for Control Plane (no CC required), you can contact [Justin Gordon, CEO of ShakaCode](mailto:justin@shakacode.com).
498
+ * [Control Plane Site](https://shakacode.controlplane.com)
499
+ * [Join our Slack to Discuss Heroku to Control Plane](https://reactrails.slack.com/join/shared_invite/enQtNjY3NTczMjczNzYxLTlmYjdiZmY3MTVlMzU2YWE0OWM0MzNiZDI0MzdkZGFiZTFkYTFkOGVjODBmOWEyYWQ3MzA2NGE1YWJjNmVlMGE)
data/docs/commands.md CHANGED
@@ -41,6 +41,7 @@ cpl apply-template gvc postgres redis rails -a $APP_NAME
41
41
  - Automatically assigns image numbers, e.g., `app:1`, `app:2`, etc.
42
42
  - Uses `.controlplane/Dockerfile` or a different Dockerfile specified through `dockerfile` in the `.controlplane/controlplane.yml` file
43
43
  - If a commit is provided through `--commit` or `-c`, it will be set as the runtime env var `GIT_COMMIT`
44
+ - Accepts extra options that are passed to `docker build`
44
45
 
45
46
  ```sh
46
47
  cpl build-image -a $APP_NAME
@@ -86,7 +87,7 @@ cpl config -a $APP_NAME
86
87
  ### `copy-image-from-upstream`
87
88
 
88
89
  - Copies an image (by default the latest) from a source org to the current org
89
- - The source org must be specified through `upstream` in the `.controlplane/controlplane.yml` file
90
+ - The source app must be specified either through the `CPLN_UPSTREAM` env var or `upstream` in the `.controlplane/controlplane.yml` file
90
91
  - Additionally, the token for the source org must be provided through `--upstream-token` or `-t`
91
92
  - A `cpln` profile will be temporarily created to pull the image from the source org
92
93
 
@@ -100,7 +101,7 @@ cpl copy-image-from-upstream -a $APP_NAME --upstream-token $UPSTREAM_TOKEN --ima
100
101
 
101
102
  ### `delete`
102
103
 
103
- - Deletes the whole app (GVC with all workloads and all images)
104
+ - Deletes the whole app (GVC with all workloads, all volumesets and all images)
104
105
  - Will ask for explicit user confirmation
105
106
 
106
107
  ```sh
@@ -131,6 +132,15 @@ cpl env -a $APP_NAME
131
132
  if [ cpl exists -a $APP_NAME ]; ...
132
133
  ```
133
134
 
135
+ ### `generate`
136
+
137
+ Creates base Control Plane config and template files
138
+
139
+ ```sh
140
+ # Creates .controlplane directory with Control Plane config and other templates
141
+ cpl generate
142
+ ```
143
+
134
144
  ### `info`
135
145
 
136
146
  - Displays the diff between defined/available apps/workloads (apps equal GVCs)
@@ -140,7 +150,7 @@ if [ cpl exists -a $APP_NAME ]; ...
140
150
  - The diff is based on what's defined in the `.controlplane/controlplane.yml` file
141
151
 
142
152
  ```sh
143
- # Shows diff for all apps in all orgs.
153
+ # Shows diff for all apps in all orgs (based on `.controlplane/controlplane.yml`).
144
154
  cpl info
145
155
 
146
156
  # Shows diff for all apps in a specific org.
@@ -312,7 +322,6 @@ cpl ps:swait -a $APP_NAME -w $WORKLOAD_NAME
312
322
 
313
323
  - Runs one-off **_interactive_** replicas (analog of `heroku run`)
314
324
  - Uses `Standard` workload type and `cpln exec` as the execution method, with CLI streaming
315
- - May not work correctly with tasks that last over 5 minutes (there's a Control Plane scaling bug at the moment)
316
325
  - If `fix_terminal_size` is `true` in the `.controlplane/controlplane.yml` file, the remote terminal size will be fixed to match the local terminal size (may also be overriden through `--terminal-size`)
317
326
 
318
327
  > **IMPORTANT:** Useful for development where it's needed for interaction, and where network connection drops and
@@ -323,28 +332,25 @@ cpl ps:swait -a $APP_NAME -w $WORKLOAD_NAME
323
332
  cpl run -a $APP_NAME
324
333
 
325
334
  # Need to quote COMMAND if setting ENV value or passing args.
326
- cpl run 'LOG_LEVEL=warn rails db:migrate' -a $APP_NAME
327
-
328
- # COMMAND may also be passed at the end.
329
335
  cpl run -a $APP_NAME -- 'LOG_LEVEL=warn rails db:migrate'
330
336
 
331
337
  # Runs command, displays output, and exits shell.
332
- cpl run ls / -a $APP_NAME
333
- cpl run rails db:migrate:status -a $APP_NAME
338
+ cpl run -a $APP_NAME -- ls /
339
+ cpl run -a $APP_NAME -- rails db:migrate:status
334
340
 
335
341
  # Runs command and keeps shell open.
336
- cpl run rails c -a $APP_NAME
342
+ cpl run -a $APP_NAME -- rails c
337
343
 
338
344
  # Uses a different image (which may not be promoted yet).
339
- cpl run rails db:migrate -a $APP_NAME --image appimage:123 # Exact image name
340
- cpl run rails db:migrate -a $APP_NAME --image latest # Latest sequential image
345
+ cpl run -a $APP_NAME --image appimage:123 -- rails db:migrate # Exact image name
346
+ cpl run -a $APP_NAME --image latest -- rails db:migrate # Latest sequential image
341
347
 
342
348
  # Uses a different workload than `one_off_workload` from `.controlplane/controlplane.yml`.
343
- cpl run bash -a $APP_NAME -w other-workload
349
+ cpl run -a $APP_NAME -w other-workload -- bash
344
350
 
345
351
  # Overrides remote CPLN_TOKEN env variable with local token.
346
352
  # Useful when superuser rights are needed in remote container.
347
- cpl run bash -a $APP_NAME --use-local-token
353
+ cpl run -a $APP_NAME --use-local-token -- bash
348
354
  ```
349
355
 
350
356
  ### `run:cleanup`
@@ -366,33 +372,33 @@ cpl run:cleanup -a $APP_NAME
366
372
  - Implemented with only async execution methods, more suitable for production tasks
367
373
  - Has alternative log fetch implementation with only JSON-polling and no WebSockets
368
374
  - Less responsive but more stable, useful for CI tasks
375
+ - Deletes the workload whenever finished with success
376
+ - Deletes the workload whenever finished with failure by default
377
+ - Use `--no-clean-on-failure` to disable cleanup to help with debugging failed runs
369
378
 
370
379
  ```sh
371
380
  cpl run:detached rails db:prepare -a $APP_NAME
372
381
 
373
382
  # Need to quote COMMAND if setting ENV value or passing args.
374
- cpl run:detached 'LOG_LEVEL=warn rails db:migrate' -a $APP_NAME
375
-
376
- # COMMAND may also be passed at the end.
377
383
  cpl run:detached -a $APP_NAME -- 'LOG_LEVEL=warn rails db:migrate'
378
384
 
379
385
  # Uses a different image (which may not be promoted yet).
380
- cpl run:detached rails db:migrate -a $APP_NAME --image appimage:123 # Exact image name
381
- cpl run:detached rails db:migrate -a $APP_NAME --image latest # Latest sequential image
386
+ cpl run:detached -a $APP_NAME --image appimage:123 -- rails db:migrate # Exact image name
387
+ cpl run:detached -a $APP_NAME --image latest -- rails db:migrate # Latest sequential image
382
388
 
383
389
  # Uses a different workload than `one_off_workload` from `.controlplane/controlplane.yml`.
384
- cpl run:detached rails db:migrate:status -a $APP_NAME -w other-workload
390
+ cpl run:detached -a $APP_NAME -w other-workload -- rails db:migrate:status
385
391
 
386
392
  # Overrides remote CPLN_TOKEN env variable with local token.
387
393
  # Useful when superuser rights are needed in remote container.
388
- cpl run:detached rails db:migrate:status -a $APP_NAME --use-local-token
394
+ cpl run:detached -a $APP_NAME --use-local-token -- rails db:migrate:status
389
395
  ```
390
396
 
391
397
  ### `setup-app`
392
398
 
393
399
  - Creates an app and all its workloads
394
- - Specify the templates for the app and workloads through `setup` in the `.controlplane/controlplane.yml` file
395
- - This should should only be used for temporary apps like review apps, never for persistent apps like production (to update workloads for those, use 'cpl apply-template' instead)
400
+ - Specify the templates for the app and workloads through `setup_app_templates` in the `.controlplane/controlplane.yml` file
401
+ - This should only be used for temporary apps like review apps, never for persistent apps like production (to update workloads for those, use 'cpl apply-template' instead)
396
402
 
397
403
  ```sh
398
404
  cpl setup-app -a $APP_NAME
data/docs/dns.md ADDED
@@ -0,0 +1,9 @@
1
+ # DNS Setup Example
2
+
3
+ About reactrails.com DNS, steps:
4
+ 1. create CNAME or ALIAS record pointing to rails-xxxx.cpln.app
5
+ 1. go to CPLN Domains -> create
6
+ 1. add reactrails.com copy code from there
7
+ 1. add TXT record with code as _cpln.reactrails.com
8
+ 1. hit ok on CPLN, route to rails workload when asked
9
+ 1. wait domain check and certificates created
data/docs/migrating.md CHANGED
@@ -29,13 +29,13 @@ Edit the `.controlplane/controlplane.yml` file as needed. Note that the `my-app-
29
29
  is defined in this file. See
30
30
  [this example](https://github.com/shakacode/react-webpack-rails-tutorial/blob/master/.controlplane/controlplane.yml).
31
31
 
32
- Before the initial setup, add the templates for the app to the `.controlplane/controlplane.yml` file, using the `setup`
32
+ Before the initial setup, add the templates for the app to the `.controlplane/controlplane.yml` file, using the `setup_app_templates`
33
33
  key, e.g.:
34
34
 
35
35
  ```yaml
36
36
  my-app-staging:
37
37
  <<: *common
38
- setup:
38
+ setup_app_templates:
39
39
  - gvc
40
40
  - redis
41
41
  - memcached
@@ -191,7 +191,7 @@ configure an entry for, e.g., `my-app-review`, and then create review apps start
191
191
  my-app-review:
192
192
  <<: *common
193
193
  match_if_app_name_starts_with: true
194
- setup:
194
+ setup_app_templates:
195
195
  - gvc
196
196
  - redis
197
197
  - memcached
@@ -1,15 +1,38 @@
1
1
  # Keys beginning with "cpln_" correspond to your settings in Control Plane.
2
2
 
3
+ # Global settings that apply to `cpl` usage.
4
+ # You can opt out of allowing the use of CPLN_ORG and CPLN_APP env vars
5
+ # to avoid any accidents with the wrong org / app.
6
+ allow_org_override_by_env: true
7
+ allow_app_override_by_env: true
8
+
3
9
  aliases:
4
10
  common: &common
5
- # Organization name for staging (customize to your needs).
6
- # Production apps will use a different organization, specified below, for security.
11
+ # Organization for staging and QA apps is typically set as an alias.
12
+ # Production apps will use a different organization, specified in `apps`, for security.
13
+ # Change this value to your organization name
14
+ # or set the CPLN_ORG env var and it will override this for all `cpl` commands
15
+ # (provided that `allow_org_override_by_env` is set to `true`).
7
16
  cpln_org: my-org-staging
8
17
 
9
- # Example apps use only one location. Control Plane offers the ability to use multiple locations.
18
+ # Control Plane offers the ability to use multiple locations.
19
+ # default_location is used for commands that require a location
20
+ # including `ps`, `run`, `run:detached`, `apply-template`.
21
+ # This can be overridden with option --location=<location> and
22
+ # CPLN_LOCATION environment variable.
10
23
  # TODO: Allow specification of multiple locations.
11
24
  default_location: aws-us-east-2
12
25
 
26
+ # Allows running the command `cpl setup-app`
27
+ # instead of `cpl apply-template gvc redis postgres memcached rails sidekiq`.
28
+ setup:
29
+ - gvc
30
+ - redis
31
+ - postgres
32
+ - memcached
33
+ - rails
34
+ - sidekiq
35
+
13
36
  # Configure the workload name used as a template for one-off scripts, like a Heroku one-off dyno.
14
37
  one_off_workload: rails
15
38
 
@@ -24,26 +47,66 @@ aliases:
24
47
  - postgres
25
48
  - memcached
26
49
 
27
- # Configure the workload name used when maintenance mode is on (defaults to "maintenance")
50
+ # Configure the workload name used when maintenance mode is on (defaults to "maintenance").
28
51
  maintenance_workload: maintenance
29
52
 
53
+ # Fixes the remote terminal size to match the local terminal size
54
+ # when running the commands `cpl run` or `cpl run:detached`.
55
+ fix_terminal_size: true
56
+
57
+ # Apps with a deployed image created before this amount of days will be listed for deletion
58
+ # when running the command `cpl cleanup-stale-apps`.
59
+ stale_app_image_deployed_days: 5
60
+
61
+ # Images that exceed this quantity will be listed for deletion
62
+ # when running the command `cpl cleanup-images`.
63
+ image_retention_max_qty: 20
64
+
65
+ # Images created before this amount of days will be listed for deletion
66
+ # when running the command `cpl cleanup-images` (`image_retention_max_qty` takes precedence).
67
+ image_retention_days: 5
68
+
69
+ # Run workloads created before this amount of days will be listed for deletion
70
+ # when running the command `cpl run:cleanup`.
71
+ stale_run_workload_created_days: 2
72
+
30
73
  apps:
31
74
  my-app-staging:
32
75
  # Use the values from the common section above.
33
76
  <<: *common
77
+
34
78
  my-app-review:
35
79
  <<: *common
80
+
36
81
  # If `match_if_app_name_starts_with` is `true`, then use this config for app names starting with this name,
37
82
  # e.g., "my-app-review-pr123", "my-app-review-anything-goes", etc.
38
83
  match_if_app_name_starts_with: true
84
+
39
85
  my-app-production:
40
86
  <<: *common
87
+
88
+ # You can also opt out of allowing the use of CPLN_ORG and CPLN_APP env vars per app.
89
+ # It's recommended to leave this off for production, to avoid any accidents.
90
+ allow_org_override_by_env: false
91
+ allow_app_override_by_env: false
92
+
41
93
  # Use a different organization for production.
42
94
  cpln_org: my-org-production
95
+
43
96
  # Allows running the command `cpl promote-app-from-upstream -a my-app-production`
44
97
  # to promote the staging app to production.
45
98
  upstream: my-app-staging
99
+
100
+ # Used by the command `cpl promote-app-from-upstream` to run a release script before deploying.
101
+ # This is relative to the `.controlplane/` directory.
102
+ release_script: release_script
103
+
104
+ # default_domain is used for commands that require a domain
105
+ # including `maintenance`, `maintenance:on`, `maintenance:off`.
106
+ default_domain: domain.com
107
+
46
108
  my-app-other:
47
109
  <<: *common
110
+
48
111
  # You can specify a different `Dockerfile` relative to the `.controlplane/` directory (defaults to "Dockerfile").
49
112
  dockerfile: ../some_other/Dockerfile
@@ -7,6 +7,7 @@ module Command
7
7
  REQUIRES_ARGS = true
8
8
  OPTIONS = [
9
9
  app_option(required: true),
10
+ location_option,
10
11
  skip_confirm_option
11
12
  ].freeze
12
13
  DESCRIPTION = "Applies application-specific configs from templates"
@@ -126,7 +127,7 @@ module Command
126
127
  def apply_template(filename)
127
128
  data = File.read(filename)
128
129
  .gsub("APP_GVC", config.app)
129
- .gsub("APP_LOCATION", config[:default_location])
130
+ .gsub("APP_LOCATION", config.location)
130
131
  .gsub("APP_ORG", config.org)
131
132
  .gsub("APP_IMAGE", latest_image)
132
133