Skip to content

Commit

Permalink
Add location option to apply-image, ps, run, and run:detached
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Nov 12, 2023
1 parent 9f8817b commit 2553b31
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/command/apply_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ApplyTemplate < Base # rubocop:disable Metrics/ClassLength
REQUIRES_ARGS = true
OPTIONS = [
app_option(required: true),
location_option,
skip_confirm_option
].freeze
DESCRIPTION = "Applies application-specific configs from templates"
Expand Down Expand Up @@ -126,7 +127,7 @@ def confirm_workload(template)
def apply_template(filename)
data = File.read(filename)
.gsub("APP_GVC", config.app)
.gsub("APP_LOCATION", config[:default_location])
.gsub("APP_LOCATION", config.options[:location] || config[:default_location])
.gsub("APP_ORG", config.org)
.gsub("APP_IMAGE", latest_image)

Expand Down
5 changes: 4 additions & 1 deletion lib/command/ps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Ps < Base
NAME = "ps"
OPTIONS = [
app_option(required: true),
location_option,
workload_option
].freeze
DESCRIPTION = "Shows running replicas in app"
Expand All @@ -24,12 +25,14 @@ class Ps < Base
def call
cp.fetch_gvc!

location = config.options["location"] || config[:default_location]

workloads = [config.options[:workload]] if config.options[:workload]
workloads ||= config[:app_workloads] + config[:additional_workloads]
workloads.each do |workload|
cp.fetch_workload!(workload)

result = cp.workload_get_replicas(workload, location: config[:default_location])
result = cp.workload_get_replicas(workload, location: location)
result["items"].each { |replica| puts replica }
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/command/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Run < Base
app_option(required: true),
image_option,
workload_option,
location_option,
use_local_token_option,
terminal_size_option
].freeze
Expand Down Expand Up @@ -56,7 +57,7 @@ class Run < Base
attr_reader :location, :workload, :one_off, :container

def call # rubocop:disable Metrics/MethodLength
@location = config[:default_location]
@location = config.options["location"] || config[:default_location]
@workload = config.options["workload"] || config[:one_off_workload]
@one_off = "#{workload}-run-#{rand(1000..9999)}"

Expand Down
3 changes: 2 additions & 1 deletion lib/command/run_detached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class RunDetached < Base # rubocop:disable Metrics/ClassLength
app_option(required: true),
image_option,
workload_option,
location_option,
use_local_token_option
].freeze
DESCRIPTION = "Runs one-off **_non-interactive_** replicas (close analog of `heroku run:detached`)"
Expand Down Expand Up @@ -47,7 +48,7 @@ class RunDetached < Base # rubocop:disable Metrics/ClassLength
attr_reader :location, :workload, :one_off, :container

def call # rubocop:disable Metrics/MethodLength
@location = config[:default_location]
@location = config.options["location"] || config[:default_location]
@workload = config.options["workload"] || config[:one_off_workload]
@one_off = "#{workload}-runner-#{rand(1000..9999)}"

Expand Down

0 comments on commit 2553b31

Please sign in to comment.