Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying upstream for copy-image-from-upstream command through CPLN_UPSTREAM env var #138

Merged
merged 11 commits into from
Jan 22, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ _Please add entries here for your pull requests that are not yet released._

- 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).
- 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).
- 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).

### Changed

Expand Down
2 changes: 1 addition & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cpl config -a $APP_NAME
### `copy-image-from-upstream`

- Copies an image (by default the latest) from a source org to the current org
- The source org must be specified through `upstream` in the `.controlplane/controlplane.yml` file
- The source app must be specified either through the `CPLN_UPSTREAM` env var or `upstream` in the `.controlplane/controlplane.yml` file
- Additionally, the token for the source org must be provided through `--upstream-token` or `-t`
- A `cpln` profile will be temporarily created to pull the image from the source org

Expand Down
4 changes: 2 additions & 2 deletions lib/command/copy_image_from_upstream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CopyImageFromUpstream < Base
DESCRIPTION = "Copies an image (by default the latest) from a source org to the current org"
LONG_DESCRIPTION = <<~DESC
- Copies an image (by default the latest) from a source org to the current org
- The source org must be specified through `upstream` in the `.controlplane/controlplane.yml` file
- The source app must be specified either through the `CPLN_UPSTREAM` env var or `upstream` in the `.controlplane/controlplane.yml` file
- Additionally, the token for the source org must be provided through `--upstream-token` or `-t`
- A `cpln` profile will be temporarily created to pull the image from the source org
DESC
Expand All @@ -28,7 +28,7 @@ class CopyImageFromUpstream < Base
def call # rubocop:disable Metrics/MethodLength
ensure_docker_running!

@upstream = config[:upstream]
@upstream = ENV.fetch("CPLN_UPSTREAM", nil) || config[:upstream]
@upstream_org = ENV.fetch("CPLN_ORG_UPSTREAM", nil) || config.find_app_config(@upstream)&.dig(:cpln_org)
ensure_upstream_org!

Expand Down
1 change: 1 addition & 0 deletions spec/command/copy_image_from_upstream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
allow(ENV).to receive(:fetch).with("CPLN_ORG", nil).and_return(nil)
allow(ENV).to receive(:fetch).with("CPLN_ORG_UPSTREAM", nil).and_return(nil)
allow(ENV).to receive(:fetch).with("CPLN_APP", nil).and_return(nil)
allow(ENV).to receive(:fetch).with("CPLN_UPSTREAM", nil).and_return(nil)
allow_any_instance_of(Config).to receive(:config_file_path).and_return("spec/fixtures/config.yml")
allow_any_instance_of(described_class).to receive(:ensure_docker_running!)
allow_any_instance_of(Controlplane).to receive(:profile_exists?).and_return(false)
Expand Down