Skip to content

Commit

Permalink
Move location assignment to config class
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangarha committed Nov 17, 2023
1 parent 257b551 commit 3895bf5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/command/apply_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def confirm_workload(template)
def apply_template(filename)
data = File.read(filename)
.gsub("APP_GVC", config.app)
.gsub("APP_LOCATION", config.options[:location] || config[:default_location])
.gsub("APP_LOCATION", config.location)
.gsub("APP_ORG", config.org)
.gsub("APP_IMAGE", latest_image)

Expand Down
2 changes: 1 addition & 1 deletion lib/command/ps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Ps < Base
def call
cp.fetch_gvc!

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

workloads = [config.options[:workload]] if config.options[:workload]
workloads ||= config[:app_workloads] + config[:additional_workloads]
Expand Down
2 changes: 1 addition & 1 deletion lib/command/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Run < Base
attr_reader :location, :workload, :one_off, :container

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

Expand Down
2 changes: 1 addition & 1 deletion lib/command/run_detached.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,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.options["location"] || config[:default_location]
@location = config.location
@workload = config.options["workload"] || config[:one_off_workload]
@one_off = "#{workload}-runner-#{rand(1000..9999)}"

Expand Down
4 changes: 3 additions & 1 deletion lib/core/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Config # rubocop:disable Metrics/ClassLength
attr_reader :config, :current,
:org, :org_comes_from_env, :app, :apps, :app_dir,
:org, :org_comes_from_env, :app, :apps, :app_dir, :location,
# command line options
:args, :options

Expand All @@ -18,6 +18,8 @@ def initialize(args, options)
load_app_config
load_apps

@location = options[:location] || config.dig(:apps, app.to_sym, :default_location)

Shell.verbose_mode(options[:verbose])
end

Expand Down

0 comments on commit 3895bf5

Please sign in to comment.