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

Raise error if image does not exist in deploy-image command #153

Merged
merged 4 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Changes since the last non-beta release.

_Please add entries here for your pull requests that are not yet released._

### Changed

- `deploy-image` command now raises an error if image does not exist. [PR 153](https://github.com/shakacode/heroku-to-control-plane/pull/153) by [Rafael Gomes](https://github.com/rafaelgomesxyz).

## [1.4.0] - 2024-03-20

### Added
Expand Down
5 changes: 5 additions & 0 deletions lib/command/deploy_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def call # rubocop:disable Metrics/MethodLength
deployed_endpoints = {}

image = latest_image
if cp.fetch_image_details(image).nil?
raise "Image '#{image}' does not exist in the Docker repository on Control Plane " \
"(see https://console.cpln.io/console/org/#{config.org}/repository/#{config.app}). " \
"Use `cpl build-image` first."
end

config[:app_workloads].each do |workload|
workload_data = cp.fetch_workload!(workload)
Expand Down
4 changes: 4 additions & 0 deletions lib/core/controlplane.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ def image_build(image, dockerfile:, docker_args: [], build_args: [], push: true)
image_push(image) if push
end

def fetch_image_details(image)
api.fetch_image_details(org: org, image: image)
end

def image_delete(image)
api.image_delete(org: org, image: image)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/core/controlplane_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def query_images(org:, gvc:, gvc_op_type:)
query("/org/#{org}/image", terms)
end

def fetch_image_details(org:, image:)
api_json("/org/#{org}/image/#{image}", method: :get)
end

def image_delete(org:, image:)
api_json("/org/#{org}/image/#{image}", method: :delete)
end
Expand Down
Loading