Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueHotDog committed May 19, 2015
1 parent 671cd39 commit 4399d7c
Showing 1 changed file with 21 additions and 37 deletions.
58 changes: 21 additions & 37 deletions opsworks_custom_cookbooks/recipes/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,41 @@
if node[:opsworks_custom_cookbooks][:scm][:type].to_s == 'archive'
repository = prepare_archive_checkouts(node[:opsworks_custom_cookbooks][:scm])
node.set[:opsworks_custom_cookbooks][:scm] = {
:type => 'git',
:repository => repository
:type => 'git',
:repository => repository
}
elsif node[:opsworks_custom_cookbooks][:scm][:type].to_s == 's3'
repository = prepare_s3_checkouts(node[:opsworks_custom_cookbooks][:scm])
node.set[:opsworks_custom_cookbooks][:scm] = {
:scm_type => 'git',
:repository => repository
:scm_type => 'git',
:repository => repository
}
end

case node[:opsworks_custom_cookbooks][:scm][:type]
when 'git'
git "Download Custom Cookbooks" do
enable_submodules node[:opsworks_custom_cookbooks][:enable_submodules]
depth nil
when 'git'
git "Download Custom Cookbooks" do
enable_submodules node[:opsworks_custom_cookbooks][:enable_submodules]
depth nil

user node[:opsworks_custom_cookbooks][:user]
group node[:opsworks_custom_cookbooks][:group]
action :checkout
destination node[:opsworks_custom_cookbooks][:destination]
repository node[:opsworks_custom_cookbooks][:scm][:repository]
revision node[:opsworks_custom_cookbooks][:scm][:revision]
retries 2
not_if do
node[:opsworks_custom_cookbooks][:scm][:repository].blank? || ::File.directory?(node[:opsworks_custom_cookbooks][:destination])
user node[:opsworks_custom_cookbooks][:user]
group node[:opsworks_custom_cookbooks][:group]
action :checkout
destination node[:opsworks_custom_cookbooks][:destination]
repository node[:opsworks_custom_cookbooks][:scm][:repository]
revision node[:opsworks_custom_cookbooks][:scm][:revision]
retries 2
not_if do
node[:opsworks_custom_cookbooks][:scm][:repository].blank? || ::File.directory?(node[:opsworks_custom_cookbooks][:destination])
end
end
end
when 'svn'
subversion "Download Custom Cookbooks" do
svn_username node[:opsworks_custom_cookbooks][:scm][:user]
svn_password node[:opsworks_custom_cookbooks][:scm][:password]

user node[:opsworks_custom_cookbooks][:user]
group node[:opsworks_custom_cookbooks][:group]
action :checkout
destination node[:opsworks_custom_cookbooks][:destination]
repository node[:opsworks_custom_cookbooks][:scm][:repository]
revision node[:opsworks_custom_cookbooks][:scm][:revision]
retries 2
not_if do
node[:opsworks_custom_cookbooks][:scm][:repository].blank? || ::File.directory?(node[:opsworks_custom_cookbooks][:destination])
end
end
else
raise "unsupported SCM type #{node[:opsworks_custom_cookbooks][:scm][:type].inspect}"
else
raise "unsupported SCM type #{node[:opsworks_custom_cookbooks][:scm][:type].inspect}"
end

ruby_block 'Move single cookbook contents into appropriate subdirectory' do
block do
cookbook_name = File.readlines(File.join(node[:opsworks_custom_cookbooks][:destination], 'metadata.rb')).detect{|line| line.match(/^\s*name\s+\S+$/)}[/name\s+['"]([^'"]+)['"]/, 1]
cookbook_name = File.readlines(File.join(node[:opsworks_custom_cookbooks][:destination], 'metadata.rb')).detect { |line| line.match(/^\s*name\s+\S+$/) }[/name\s+['"]([^'"]+)['"]/, 1]
cookbook_path = File.join(node[:opsworks_custom_cookbooks][:destination], cookbook_name)
Chef::Log.info "Single cookbook detected, moving into subdirectory '#{cookbook_path}'"
FileUtils.mkdir(cookbook_path)
Expand Down

0 comments on commit 4399d7c

Please sign in to comment.