Skip to content

Commit

Permalink
Implements #132: Prefix development builds with dev/, by default. (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
askreet committed Oct 19, 2016
1 parent fb506ac commit 1e0fce3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/moonshot/commands/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def execute
controller.create

if @deploy && @version.nil?
controller.deploy_code
controller.push
elsif @deploy
controller.deploy_version(@version)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/moonshot/commands/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Push < Moonshot::Command
self.description = 'Build and deploy a development artifact from the working directory'

def execute
controller.deploy_code
controller.push
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions lib/moonshot/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ def status
run_plugins(:post_status)
end

def deploy_code
version = [@config.app_name, @config.environment_name, Time.now.to_i]
.join('-')
def push
version = @config.dev_build_name_proc.call(@config)
build_version(version)
deploy_version(version)
end
Expand Down
17 changes: 11 additions & 6 deletions lib/moonshot/controller_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@ module Moonshot
# Holds configuration for Moonshot::Controller
class ControllerConfig
attr_accessor :additional_tag
attr_accessor :answer_file
attr_accessor :app_name
attr_accessor :artifact_repository
attr_accessor :answer_file
attr_accessor :build_mechanism
attr_accessor :deployment_mechanism
attr_accessor :dev_build_name_proc
attr_accessor :environment_name
attr_accessor :interactive
attr_accessor :interactive_logger
attr_accessor :parameter_overrides
attr_accessor :parameters
attr_accessor :parent_stacks
attr_accessor :plugins
attr_accessor :project_root
attr_accessor :show_all_stack_events
attr_accessor :ssh_config
attr_accessor :ssh_command
attr_accessor :ssh_auto_scaling_group_name
attr_accessor :ssh_command
attr_accessor :ssh_config
attr_accessor :ssh_instance
attr_accessor :project_root
attr_accessor :parameters
attr_accessor :parameter_overrides

def initialize
@interactive = true
Expand All @@ -36,6 +37,10 @@ def initialize
@show_all_stack_events = false
@ssh_config = SSHConfig.new

@dev_build_name_proc = lambda do |c|
['dev', c.app_name, c.environment_name, Time.now.to_i].join('/')
end

user = ENV.fetch('USER', 'default-user').gsub(/\W/, '')
@environment_name = "dev-#{user}"
end
Expand Down

0 comments on commit 1e0fce3

Please sign in to comment.