Skip to content

Commit

Permalink
Fixes #104: Determine project root from Moonfile.rb path. (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
askreet committed Oct 11, 2016
1 parent 317222a commit 1dcc75f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions lib/moonshot/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def self.run! # rubocop:disable AbcSize, CyclomaticComplexity, MethodLength, Per
Object.include(Moonshot::DeploymentMechanism)
load(File.join(moonfile_dir, 'Moonfile.rb'))

Moonshot.config.project_root = moonfile_dir

load_commands

# Determine what command is being run, which should be the first argument.
Expand Down
12 changes: 7 additions & 5 deletions lib/moonshot/controller_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ class ControllerConfig
attr_accessor :ssh_command
attr_accessor :ssh_auto_scaling_group_name
attr_accessor :ssh_instance
attr_accessor :project_root

def initialize
@interactive_logger = InteractiveLogger.new
@parent_stacks = []
@plugins = []
@interactive_logger = InteractiveLogger.new
@parameter_strategy = Moonshot::ParameterStrategy::DefaultStrategy.new
@parent_stacks = []
@plugins = []
@project_root = Dir.pwd
@show_all_stack_events = false
@parameter_strategy = Moonshot::ParameterStrategy::DefaultStrategy.new
@ssh_config = SSHConfig.new
@ssh_config = SSHConfig.new

user = ENV.fetch('USER', 'default-user').gsub(/\W/, '')
@environment_name = "dev-#{user}"
Expand Down
5 changes: 3 additions & 2 deletions lib/moonshot/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def template_file

# @return [String] the path to the parameters file.
def parameters_file
File.join(Dir.pwd, 'cloud_formation', 'parameters', "#{@name}.yml")
File.join(@config.project_root, 'cloud_formation', 'parameters', "#{@name}.yml")
end

def add_parameter_overrides(hash)
Expand Down Expand Up @@ -212,7 +212,8 @@ def yaml_template_path

# @return [String] the path to the template file without extension.
def raw_template_file_name
@raw_template_file_name ||= File.join(Dir.pwd, 'cloud_formation', @config.app_name)
@raw_template_file_name ||=
File.join(@config.project_root, 'cloud_formation', @config.app_name)
end

def load_template_file
Expand Down

0 comments on commit 1dcc75f

Please sign in to comment.