engineyard-recipes 0.1.3 → 0.2.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/Rakefile +6 -1
- data/bin/ey-recipes +1 -5
- data/features/clone-recipe.feature +7 -0
- data/features/init-new-cookbook.feature +0 -2
- data/features/init-sm-framework.feature +36 -0
- data/features/step_definitions/common_steps.rb +5 -1
- data/features/step_definitions/fixture_project_steps.rb +16 -2
- data/features/step_definitions/mock_git_steps.rb +22 -0
- data/features/support/env.rb +2 -2
- data/features/wrap-sm-extension.feature +57 -0
- data/fixtures/sm_exts/local_sm_repo/local_sm_repo_readme.md +0 -0
- data/lib/engineyard-recipes/cli.rb +25 -0
- data/lib/engineyard-recipes/fetch_uri.rb +18 -1
- data/lib/engineyard-recipes/generators/init_generator.rb +0 -13
- data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/attributes/recipe.rb +0 -0
- data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/default.rb +1 -0
- data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/install.rb +21 -0
- data/lib/engineyard-recipes/generators/init_sm_generator.rb +37 -0
- data/lib/engineyard-recipes/generators/sm_generator/templates/command_recipe.rb.tt +9 -0
- data/lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/attributes/recipe.rb.tt +6 -0
- data/lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/recipes/default.rb.tt +4 -0
- data/lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/recipes/install_sm_ext.rb.tt +8 -0
- data/lib/engineyard-recipes/generators/sm_generator.rb +49 -0
- data/lib/engineyard-recipes/git_cmd.rb +20 -0
- data/lib/engineyard-recipes/version.rb +1 -1
- data/spec/fetch_uri_spec.rb +50 -0
- data/spec/spec_helper.rb +9 -0
- metadata +41 -22
data/.rspec
ADDED
data/Rakefile
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc "Run all examples"
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
3
8
|
namespace :cucumber do
|
4
9
|
require 'cucumber/rake/task'
|
5
10
|
Cucumber::Rake::Task.new(:wip, 'Run features that are being worked on') do |t|
|
@@ -19,4 +24,4 @@ end
|
|
19
24
|
desc 'Alias for cucumber:ok'
|
20
25
|
task :cucumber => 'cucumber:ok'
|
21
26
|
|
22
|
-
task :default => ["cucumber"]
|
27
|
+
task :default => ["spec", "cucumber"]
|
data/bin/ey-recipes
CHANGED
@@ -6,12 +6,8 @@ require 'engineyard-recipes/cli'
|
|
6
6
|
|
7
7
|
begin
|
8
8
|
Engineyard::Recipes::CLI.start
|
9
|
-
rescue EY::Error => e
|
10
|
-
EY.ui.print_exception(e)
|
11
|
-
exit(1)
|
12
9
|
rescue Interrupt => e
|
13
10
|
puts
|
14
|
-
|
15
|
-
EY.ui.say("Quitting...")
|
11
|
+
puts "Quitting..."
|
16
12
|
exit(1)
|
17
13
|
end
|
@@ -46,6 +46,13 @@ Feature: Clone recipe from git repositories
|
|
46
46
|
create cookbooks/library/libraries/mylib.rb
|
47
47
|
"""
|
48
48
|
|
49
|
+
Scenario: Clone URI is an unknown local path
|
50
|
+
When I run local executable "ey-recipes" with arguments "clone /tmp/ey-recipes/UNKNOWN"
|
51
|
+
And I should see exactly
|
52
|
+
"""
|
53
|
+
ERROR: No recipe found at /tmp/ey-recipes/UNKNOWN
|
54
|
+
"""
|
55
|
+
|
49
56
|
@wip
|
50
57
|
Scenario: Clone a recipe from engineyard/ey-cloud-recipes repository
|
51
58
|
Given I am have a local recipe "blank" at "/tmp/ey-recipes/blank"
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Setup your EY Cloud cookbook to use SM framework extensions
|
2
|
+
I want to write my customizations in SM framework
|
3
|
+
And have them work on EY Cloud
|
4
|
+
|
5
|
+
Scenario: Setup existing EY Cloud custom cookbooks for SM extensions
|
6
|
+
Given I am in the "rails" project folder
|
7
|
+
When I run local executable "ey-recipes" with arguments "init"
|
8
|
+
When I run local executable "ey-recipes" with arguments "init-sm"
|
9
|
+
Then file "cookbooks/sm/recipes/default.rb" contains "require_recipe 'sm::install'"
|
10
|
+
Then file "cookbooks/sm/recipes/install.rb" contains "curl -L -s https://github.com/sm/sm/tarball/master -o sm-master.tar.gz"
|
11
|
+
And I should see exactly
|
12
|
+
"""
|
13
|
+
exist cookbooks
|
14
|
+
create cookbooks/sm/attributes/recipe.rb
|
15
|
+
create cookbooks/sm/recipes/default.rb
|
16
|
+
create cookbooks/sm/recipes/install.rb
|
17
|
+
append cookbooks/main/recipes/default.rb
|
18
|
+
"""
|
19
|
+
|
20
|
+
Scenario: Create new EY CLoud custom cookbooks with SM extensions
|
21
|
+
Given I am in the "rails" project folder
|
22
|
+
When I run local executable "ey-recipes" with arguments "init --sm"
|
23
|
+
And I should see exactly
|
24
|
+
"""
|
25
|
+
create cookbooks
|
26
|
+
create cookbooks/main/attributes/recipe.rb
|
27
|
+
create cookbooks/main/definitions/ey_cloud_report.rb
|
28
|
+
create cookbooks/main/libraries/ruby_block.rb
|
29
|
+
create cookbooks/main/libraries/run_for_app.rb
|
30
|
+
create cookbooks/main/recipes/default.rb
|
31
|
+
exist cookbooks
|
32
|
+
create cookbooks/sm/attributes/recipe.rb
|
33
|
+
create cookbooks/sm/recipes/default.rb
|
34
|
+
create cookbooks/sm/recipes/install.rb
|
35
|
+
append cookbooks/main/recipes/default.rb
|
36
|
+
"""
|
@@ -49,7 +49,11 @@ When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, argu
|
|
49
49
|
require 'engineyard-recipes/cli'
|
50
50
|
in_project_folder do
|
51
51
|
stdout, stderr = capture_stdios do
|
52
|
-
|
52
|
+
begin
|
53
|
+
Engineyard::Recipes::CLI.start(arguments.split(/ /))
|
54
|
+
rescue SystemExit => e
|
55
|
+
@system_exit = true
|
56
|
+
end
|
53
57
|
end
|
54
58
|
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
55
59
|
File.open(@stdout, "w") {|f| f << stdout; f << stderr}
|
@@ -9,7 +9,21 @@ end
|
|
9
9
|
Given /^I am have a local recipe "([^\"]*)" at "\/tmp\/ey-recipes\/([^"]*)"$/ do |name, repeat_name|
|
10
10
|
name.should == repeat_name
|
11
11
|
fixture_recipe = File.join(@fixtures_path, "recipes", name)
|
12
|
-
FileUtils.rm_rf(
|
13
|
-
FileUtils.mkdir_p(
|
12
|
+
FileUtils.rm_rf(@tmp_recipes_path)
|
13
|
+
FileUtils.mkdir_p(@tmp_recipes_path)
|
14
14
|
FileUtils.cp_r(fixture_recipe, @tmp_recipes_path)
|
15
15
|
end
|
16
|
+
|
17
|
+
Given /^I am have a local sm extension "([^"]*)" at "\/tmp\/ey-recipes\/([^"]*)"$/ do |name, repeat_name|
|
18
|
+
name.should == repeat_name
|
19
|
+
fixture_recipe = File.join(@fixtures_path, "sm_exts", name)
|
20
|
+
FileUtils.rm_rf(@tmp_recipes_path)
|
21
|
+
FileUtils.mkdir_p(@tmp_recipes_path)
|
22
|
+
FileUtils.cp_r(fixture_recipe, @tmp_recipes_path)
|
23
|
+
FileUtils.chdir(File.join(@tmp_recipes_path, name)) do
|
24
|
+
`git init`
|
25
|
+
`git add .`
|
26
|
+
`git commit -m 'Ready for testing'`
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Given /^I mock out git commands$/ do
|
2
|
+
Engineyard::Recipes::GitCmd.test_mode = true
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^git command "([^"]*)" is run$/ do |command|
|
6
|
+
command.gsub!(/^git\s+/, '') # don't test for git command portion
|
7
|
+
in_tmp_folder do
|
8
|
+
File.should be_exists('git.log')
|
9
|
+
File.read('git.log').should =~ /^#{command}$/
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Then /^git command "([^"]*)" is not run$/ do |command|
|
15
|
+
command.gsub!(/^git\s+/, '') # don't test for git command portion
|
16
|
+
in_tmp_folder do
|
17
|
+
if File.exists? 'git.log'
|
18
|
+
File.read('git.log').should_not =~ /^#{command}$/
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/features/support/env.rb
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../../lib'))
|
|
2
2
|
require 'bundler/setup'
|
3
3
|
require 'engineyard-recipes'
|
4
4
|
|
5
|
-
|
5
|
+
original_path = ENV['PATH']
|
6
6
|
|
7
7
|
Before do
|
8
8
|
@tmp_root = File.dirname(__FILE__) + "/../../tmp"
|
@@ -17,5 +17,5 @@ Before do
|
|
17
17
|
FileUtils.mkdir_p @tmp_recipes_path
|
18
18
|
ENV['HOME'] = @home_path
|
19
19
|
fixture_bin_path = File.expand_path('../../../fixtures/bin', __FILE__)
|
20
|
-
ENV['PATH'] = fixture_bin_path + ":" +
|
20
|
+
ENV['PATH'] = fixture_bin_path + ":" + original_path
|
21
21
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Feature: Wrap SM framework extension
|
2
|
+
I want to write my customizations in SM framework extensions
|
3
|
+
And have them work on EY Cloud
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given I am in the "rails" project folder
|
7
|
+
When I run local executable "ey-recipes" with arguments "init"
|
8
|
+
When I run local executable "ey-recipes" with arguments "init-sm"
|
9
|
+
|
10
|
+
Scenario: Wrap an SM extension only
|
11
|
+
When I run local executable "ey-recipes" with arguments "sm https://github.com/eystacks/sm_jenkins.git --name jenkins"
|
12
|
+
Then file "cookbooks/jenkins/recipes/default.rb" contains "require_recipe 'jenkins::install_sm_ext'"
|
13
|
+
Then file "cookbooks/jenkins/attributes/recipe.rb" contains "sm_jenkins_uri('https://github.com/eystacks/sm_jenkins.git')"
|
14
|
+
Then file "cookbooks/jenkins/recipes/install_sm_ext.rb" contains "command 'sm ext install jenkins #{node[:sm_jenkins_uri]}'"
|
15
|
+
Then file ".gitmodules" is not created
|
16
|
+
And I should see exactly
|
17
|
+
"""
|
18
|
+
exist cookbooks
|
19
|
+
create cookbooks/jenkins/attributes/recipe.rb
|
20
|
+
create cookbooks/jenkins/recipes/default.rb
|
21
|
+
create cookbooks/jenkins/recipes/install_sm_ext.rb
|
22
|
+
append cookbooks/main/recipes/default.rb
|
23
|
+
"""
|
24
|
+
|
25
|
+
Scenario: Wrap an SM extension only and trigger its commands
|
26
|
+
When I run local executable "ey-recipes" with arguments "sm https://github.com/eystacks/sm_jenkins.git install configure start --name jenkins"
|
27
|
+
Then file "cookbooks/jenkins/recipes/default.rb" contains "require_recipe 'jenkins::install_sm_ext'"
|
28
|
+
Then file "cookbooks/jenkins/recipes/default.rb" contains "require_recipe 'jenkins::install'"
|
29
|
+
Then file "cookbooks/jenkins/recipes/default.rb" contains "require_recipe 'jenkins::configure'"
|
30
|
+
Then file "cookbooks/jenkins/recipes/default.rb" contains "require_recipe 'jenkins::start'"
|
31
|
+
Then file "cookbooks/jenkins/recipes/install.rb" contains "command 'sm jenkins install'"
|
32
|
+
Then file "cookbooks/jenkins/recipes/configure.rb" contains "command 'sm jenkins configure'"
|
33
|
+
Then file "cookbooks/jenkins/recipes/start.rb" contains "command 'sm jenkins start'"
|
34
|
+
And I should see exactly
|
35
|
+
"""
|
36
|
+
exist cookbooks
|
37
|
+
create cookbooks/jenkins/attributes/recipe.rb
|
38
|
+
create cookbooks/jenkins/recipes/default.rb
|
39
|
+
create cookbooks/jenkins/recipes/install_sm_ext.rb
|
40
|
+
create cookbooks/jenkins/recipes/install.rb
|
41
|
+
create cookbooks/jenkins/recipes/configure.rb
|
42
|
+
create cookbooks/jenkins/recipes/start.rb
|
43
|
+
append cookbooks/main/recipes/default.rb
|
44
|
+
"""
|
45
|
+
|
46
|
+
Scenario: Wrap a local SM extension and vendor it
|
47
|
+
Given I am have a local sm extension "local_sm_repo" at "/tmp/ey-recipes/local_sm_repo"
|
48
|
+
When I run local executable "ey-recipes" with arguments "sm /tmp/ey-recipes/local_sm_repo --name jenkins --submodule repo"
|
49
|
+
Then file "cookbooks/jenkins/attributes/recipe.rb" contains "sm_jenkins_uri(File.expand_path('../../../../cookbooks/jenkins/repo', __FILE__))"
|
50
|
+
And git command "git submodule add https://github.com/eystacks/sm_jenkins.git cookbooks/jenkins/repo" is not run
|
51
|
+
And file "cookbooks/jenkins/repo/local_sm_repo_readme.md" is created
|
52
|
+
|
53
|
+
Scenario: Wrap a git SM extension and vendor it via submodules
|
54
|
+
Given I mock out git commands
|
55
|
+
When I run local executable "ey-recipes" with arguments "sm https://github.com/eystacks/sm_jenkins.git --name jenkins --submodule repo"
|
56
|
+
Then file "cookbooks/jenkins/attributes/recipe.rb" contains "sm_jenkins_uri(File.expand_path('../../../../cookbooks/jenkins/repo', __FILE__))"
|
57
|
+
And git command "git submodule add https://github.com/eystacks/sm_jenkins.git cookbooks/jenkins/repo" is run
|
File without changes
|
@@ -7,9 +7,17 @@ module Engineyard
|
|
7
7
|
class CLI < Thor
|
8
8
|
|
9
9
|
desc "init", "Creates cookbooks scaffolding for your recipes"
|
10
|
+
method_option :sm, :type => :boolean
|
10
11
|
def init
|
11
12
|
require 'engineyard-recipes/generators/init_generator'
|
12
13
|
Engineyard::Recipes::Generators::InitGenerator.start
|
14
|
+
init_sm if options[:sm]
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "init-sm", "Setup your EY Cloud cookbook to use SM framework extensions"
|
18
|
+
def init_sm
|
19
|
+
require 'engineyard-recipes/generators/init_sm_generator'
|
20
|
+
Engineyard::Recipes::Generators::InitSmGenerator.start
|
13
21
|
end
|
14
22
|
|
15
23
|
desc "recipe RECIPE", "Generate recipe for a package"
|
@@ -38,6 +46,23 @@ module Engineyard
|
|
38
46
|
generator = Engineyard::Recipes::Generators::LocalRecipeCloneGenerator
|
39
47
|
local_cookbook_path, recipe_name = FetchUri.fetch_recipe(folder_path, generator.source_root, options["name"])
|
40
48
|
generator.start([recipe_name])
|
49
|
+
rescue Engineyard::Recipes::FetchUri::UnknownPath => e
|
50
|
+
error "No recipe found at #{e.message}"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "sm URI [COMMANDS]", "Wrap an SM extension as an eychef recipe"
|
54
|
+
method_option :name, :aliases => ['-n'], :desc => "Specify name of recipe. Defaults to base name.", :required => true
|
55
|
+
method_option :submodule, :desc => "Submodule the URI into recipe folder name"
|
56
|
+
def sm(uri, *commands)
|
57
|
+
require 'engineyard-recipes/generators/sm_generator'
|
58
|
+
recipe_name = options["name"]
|
59
|
+
if options["submodule"]
|
60
|
+
sm_vendor_path = File.join("cookbooks", recipe_name, options["submodule"])
|
61
|
+
end
|
62
|
+
Engineyard::Recipes::Generators::SmGenerator.start([recipe_name, uri, commands, sm_vendor_path])
|
63
|
+
if sm_vendor_path
|
64
|
+
FetchUri.vendor_recipe_into_recipe(uri, sm_vendor_path)
|
65
|
+
end
|
41
66
|
end
|
42
67
|
|
43
68
|
desc "version", "show version information"
|
@@ -1,6 +1,11 @@
|
|
1
|
+
require "engineyard-recipes/git_cmd"
|
2
|
+
|
1
3
|
module Engineyard::Recipes
|
2
4
|
module FetchUri
|
3
5
|
extend self
|
6
|
+
extend Engineyard::Recipes::GitCmd
|
7
|
+
|
8
|
+
class UnknownPath < StandardError; end
|
4
9
|
|
5
10
|
# Fetch the target at URI (git url or local folder path)
|
6
11
|
#
|
@@ -10,6 +15,19 @@ module Engineyard::Recipes
|
|
10
15
|
def fetch_recipe(uri, source_root, recipe_name = nil)
|
11
16
|
if File.exists?(uri)
|
12
17
|
normalize_fetched_project(uri, source_root, recipe_name)
|
18
|
+
else
|
19
|
+
raise UnknownPath, uri
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Vendor/submodule the +uri+ into current git repo at +sm_vendor_path+
|
24
|
+
# If +uri+ is a local folder, then copy folder to +sm_vendor_path+
|
25
|
+
# If +uri+ is a remote git repo, then submodule to +sm_vendor_path+
|
26
|
+
def vendor_recipe_into_recipe(uri, sm_vendor_path)
|
27
|
+
if File.exists?(uri)
|
28
|
+
FileUtils.cp_r(uri, sm_vendor_path)
|
29
|
+
else
|
30
|
+
git "submodule add #{uri} #{sm_vendor_path}"
|
13
31
|
end
|
14
32
|
end
|
15
33
|
|
@@ -46,7 +64,6 @@ module Engineyard::Recipes
|
|
46
64
|
initial_storage = Dir.mktmpdir
|
47
65
|
initial_storage_cookbooks = File.join(initial_storage, "cookbooks")
|
48
66
|
if File.directory?(File.join(path, "cookbooks"))
|
49
|
-
# FIXME untested
|
50
67
|
FileUtils.cp_r("#{path}/", initial_storage)
|
51
68
|
else
|
52
69
|
FileUtils.mkdir_p(initial_storage_cookbooks)
|
@@ -16,19 +16,6 @@ module Engineyard::Recipes
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
# def attributes
|
20
|
-
# template "attributes.rb.tt", "cookbooks/recipes_slave/attributes/default.rb"
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# def recipe
|
24
|
-
# copy_file "recipes.rb", "cookbooks/recipes_slave/recipes/default.rb"
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
def readme
|
28
|
-
say ""
|
29
|
-
say "Lovely.", :green
|
30
|
-
end
|
31
|
-
|
32
19
|
private
|
33
20
|
def say(msg, color = nil)
|
34
21
|
color ? shell.say(msg, color) : shell.say(msg)
|
data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/attributes/recipe.rb
ADDED
File without changes
|
data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/default.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_recipe 'sm::install'
|
data/lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/install.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
ey_cloud_report "Installing SM framework"
|
2
|
+
|
3
|
+
execute "install-sm" do
|
4
|
+
command <<-SHELL
|
5
|
+
for entry in /tmp/sm-* ; do rm -rf ${entry} ; done
|
6
|
+
|
7
|
+
curl -L -s https://github.com/sm/sm/tarball/master -o sm-master.tar.gz &&
|
8
|
+
tar zxf sm-master.tar.gz && # unpack
|
9
|
+
mv sm-sm-* sm-master && # rename github-named folder to something known
|
10
|
+
cd sm-master &&
|
11
|
+
./install # >/dev/null
|
12
|
+
|
13
|
+
|
14
|
+
# prefix_path=/eystack ./install >/dev/null
|
15
|
+
SHELL
|
16
|
+
action :run
|
17
|
+
end
|
18
|
+
|
19
|
+
link "/bin/sm" do
|
20
|
+
to "/opt/sm/bin/sm"
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module Engineyard::Recipes
|
4
|
+
module Generators
|
5
|
+
class InitSmGenerator < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
File.join(File.dirname(__FILE__), "init_sm_generator", "templates")
|
10
|
+
end
|
11
|
+
|
12
|
+
def install_cookbooks
|
13
|
+
directory "cookbooks"
|
14
|
+
end
|
15
|
+
|
16
|
+
def auto_require_package
|
17
|
+
file = "cookbooks/main/recipes/default.rb"
|
18
|
+
file_path = File.join(destination_root, "cookbooks/main/recipes/default.rb")
|
19
|
+
unless File.exists?(file_path)
|
20
|
+
puts "Skipping auto-require of package recipe: #{file} is missing"
|
21
|
+
else
|
22
|
+
require_recipe = "\nrequire_recipe '#{recipe_name}'\n"
|
23
|
+
append_to_file file, require_recipe
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def say(msg, color = nil)
|
29
|
+
color ? shell.say(msg, color) : shell.say(msg)
|
30
|
+
end
|
31
|
+
|
32
|
+
def recipe_name
|
33
|
+
'sm'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
<% if sm_vendor_path -%>
|
2
|
+
<% # assumes render file is at 'cookbooks/recipe-name/attributes/recipe.rb' -%>
|
3
|
+
sm_<%= recipe_name %>_uri(File.expand_path('../../../../<%= sm_vendor_path %>', __FILE__))
|
4
|
+
<% else -%>
|
5
|
+
sm_<%= recipe_name %>_uri('<%= sm_ext_uri %>')
|
6
|
+
<% end %>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module Engineyard::Recipes
|
4
|
+
module Generators
|
5
|
+
class SmGenerator < Thor::Group
|
6
|
+
include Thor::Actions
|
7
|
+
attr_accessor :command
|
8
|
+
|
9
|
+
argument :recipe_name
|
10
|
+
argument :sm_ext_uri
|
11
|
+
argument :sm_ext_commands, :type => :array
|
12
|
+
argument :sm_vendor_path, :required => false
|
13
|
+
|
14
|
+
def self.source_root
|
15
|
+
File.join(File.dirname(__FILE__), "sm_generator", "templates")
|
16
|
+
end
|
17
|
+
|
18
|
+
def install_cookbooks
|
19
|
+
directory "cookbooks"
|
20
|
+
end
|
21
|
+
|
22
|
+
def wrap_commands
|
23
|
+
template_file = 'command_recipe.rb.tt'
|
24
|
+
sm_ext_commands.each do |command|
|
25
|
+
self.command = command # for the template
|
26
|
+
recipe = "cookbooks/#{recipe_name}/recipes/#{command}.rb"
|
27
|
+
template(template_file, recipe)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def auto_require_package
|
32
|
+
file = "cookbooks/main/recipes/default.rb"
|
33
|
+
file_path = File.join(destination_root, "cookbooks/main/recipes/default.rb")
|
34
|
+
unless File.exists?(file_path)
|
35
|
+
puts "Skipping auto-require of package recipe: #{file} is missing"
|
36
|
+
else
|
37
|
+
require_recipe = "\nrequire_recipe '#{recipe_name}'\n"
|
38
|
+
append_to_file file, require_recipe
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
def say(msg, color = nil)
|
44
|
+
color ? shell.say(msg, color) : shell.say(msg)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Engineyard::Recipes
|
2
|
+
module GitCmd
|
3
|
+
class << self
|
4
|
+
attr_accessor :test_mode
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.git(command)
|
8
|
+
if test_mode
|
9
|
+
git_mock_log = File.expand_path("../../../tmp/git.log", __FILE__)
|
10
|
+
File.open(git_mock_log, "a") { |file| file << command; file << "\n" }
|
11
|
+
else
|
12
|
+
`git #{command}`
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def git(command)
|
17
|
+
Engineyard::Recipes::GitCmd.git(command)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$:.unshift(File.expand_path("..", __FILE__))
|
2
|
+
require "spec_helper"
|
3
|
+
require "engineyard-recipes/fetch_uri"
|
4
|
+
|
5
|
+
describe Engineyard::Recipes::FetchUri do
|
6
|
+
# Fetch the target at URI (git url or local folder path)
|
7
|
+
#
|
8
|
+
# Returns a tuple:
|
9
|
+
# * path to a local folder structure that contains "cookbooks/<recipe name>"
|
10
|
+
# * recipe_name
|
11
|
+
describe "#fetch_recipe" do
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# Vendor/submodule the +uri+ into current git repo at +sm_vendor_path+
|
16
|
+
# If +uri+ is a local folder, then copy folder to +sm_vendor_path+
|
17
|
+
# If +uri+ is a remote git repo, then submodule to +sm_vendor_path+
|
18
|
+
describe "#vendor_recipe_into_recipe" do
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
# Takes a folder that is either a cookbooks/<recipes> structure, or
|
23
|
+
# assumed to be a singular <recipe>/
|
24
|
+
# Copies it into +store_path+ and resulting folder
|
25
|
+
# guaranteed to be in cookbooks/<recipes> structure
|
26
|
+
#
|
27
|
+
# For example, if the +path+ is:
|
28
|
+
# path/
|
29
|
+
# ey-dnapi/
|
30
|
+
# libraries/
|
31
|
+
# engineyard.rb
|
32
|
+
#
|
33
|
+
# Then the resulting +store_path+ will be:
|
34
|
+
# tmpdir/
|
35
|
+
# cookbooks/
|
36
|
+
# ey-dnapi/
|
37
|
+
# libraries/
|
38
|
+
# engineyard.rb
|
39
|
+
#
|
40
|
+
# If +path+/cookbooks exists, then +store_path+
|
41
|
+
# will be a duplicate of +path+
|
42
|
+
#
|
43
|
+
# Can override the +<recipe>+ name with +recipe_name+
|
44
|
+
#
|
45
|
+
# Returns a tuple:
|
46
|
+
# * path to a local folder structure that contains "cookbooks/<recipe name>"
|
47
|
+
# * recipe_name
|
48
|
+
describe "#normalize_fetched_project" do
|
49
|
+
end
|
50
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0.pre1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dr Nic Williams
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-11-
|
12
|
+
date: 2011-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
16
|
-
requirement: &
|
16
|
+
requirement: &70211728365380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.14.6
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70211728365380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: engineyard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70211728363740 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.4.6
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70211728363740
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70211728363200 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.9.2
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70211728363200
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: cucumber
|
49
|
-
requirement: &
|
49
|
+
requirement: &70211728362300 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.1.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70211728362300
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70211728360180 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 2.7.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70211728360180
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: launchy
|
71
|
-
requirement: &
|
71
|
+
requirement: &70211728357420 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70211728357420
|
80
80
|
description: Tools to generate, upload, test and apply chef recipes for Engine Yard
|
81
81
|
Cloud.
|
82
82
|
email:
|
@@ -87,6 +87,7 @@ extensions: []
|
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
89
|
- .gitignore
|
90
|
+
- .rspec
|
90
91
|
- .travis.yml
|
91
92
|
- ChangeLog.md
|
92
93
|
- Gemfile
|
@@ -98,16 +99,20 @@ files:
|
|
98
99
|
- features/generate-helper-definitions.feature
|
99
100
|
- features/generate-recipe.feature
|
100
101
|
- features/init-new-cookbook.feature
|
102
|
+
- features/init-sm-framework.feature
|
101
103
|
- features/step_definitions/api_steps.rb
|
102
104
|
- features/step_definitions/common_steps.rb
|
103
105
|
- features/step_definitions/fixture_project_steps.rb
|
106
|
+
- features/step_definitions/mock_git_steps.rb
|
104
107
|
- features/support/common.rb
|
105
108
|
- features/support/env.rb
|
106
109
|
- features/support/matchers.rb
|
110
|
+
- features/wrap-sm-extension.feature
|
107
111
|
- fixtures/projects/rails/Gemfile
|
108
112
|
- fixtures/projects/rails/Rakefile
|
109
113
|
- fixtures/recipes/blank/README.rdoc
|
110
114
|
- fixtures/recipes/blank/recipes/default.rb
|
115
|
+
- fixtures/sm_exts/local_sm_repo/local_sm_repo_readme.md
|
111
116
|
- lib/engineyard-recipes.rb
|
112
117
|
- lib/engineyard-recipes/cli.rb
|
113
118
|
- lib/engineyard-recipes/fetch_uri.rb
|
@@ -119,14 +124,26 @@ files:
|
|
119
124
|
- lib/engineyard-recipes/generators/init_generator/templates/cookbooks/main/libraries/ruby_block.rb
|
120
125
|
- lib/engineyard-recipes/generators/init_generator/templates/cookbooks/main/libraries/run_for_app.rb
|
121
126
|
- lib/engineyard-recipes/generators/init_generator/templates/cookbooks/main/recipes/default.rb
|
127
|
+
- lib/engineyard-recipes/generators/init_sm_generator.rb
|
128
|
+
- lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/attributes/recipe.rb
|
129
|
+
- lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/default.rb
|
130
|
+
- lib/engineyard-recipes/generators/init_sm_generator/templates/cookbooks/sm/recipes/install.rb
|
122
131
|
- lib/engineyard-recipes/generators/local_recipe_clone_generator.rb
|
123
132
|
- lib/engineyard-recipes/generators/local_recipe_clone_generator/templates/cookbooks/%recipe_name%/definitions/%definition_name%.rb.tt
|
124
133
|
- lib/engineyard-recipes/generators/recipe_generator.rb
|
125
134
|
- lib/engineyard-recipes/generators/recipe_generator/templates/cookbooks/%recipe_name%/attributes/recipe.rb.tt
|
126
135
|
- lib/engineyard-recipes/generators/recipe_generator/templates/cookbooks/%recipe_name%/recipes/default.rb.tt
|
127
136
|
- lib/engineyard-recipes/generators/recipe_generator/templates/cookbooks/%recipe_name%/recipes/install.rb.tt
|
137
|
+
- lib/engineyard-recipes/generators/sm_generator.rb
|
138
|
+
- lib/engineyard-recipes/generators/sm_generator/templates/command_recipe.rb.tt
|
139
|
+
- lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/attributes/recipe.rb.tt
|
140
|
+
- lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/recipes/default.rb.tt
|
141
|
+
- lib/engineyard-recipes/generators/sm_generator/templates/cookbooks/%recipe_name%/recipes/install_sm_ext.rb.tt
|
142
|
+
- lib/engineyard-recipes/git_cmd.rb
|
128
143
|
- lib/engineyard-recipes/thor-ext/actions/directory.rb
|
129
144
|
- lib/engineyard-recipes/version.rb
|
145
|
+
- spec/fetch_uri_spec.rb
|
146
|
+
- spec/spec_helper.rb
|
130
147
|
homepage: ''
|
131
148
|
licenses: []
|
132
149
|
post_install_message:
|
@@ -141,19 +158,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
158
|
version: '0'
|
142
159
|
segments:
|
143
160
|
- 0
|
144
|
-
hash: -
|
161
|
+
hash: -734340891019188320
|
145
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
163
|
none: false
|
147
164
|
requirements:
|
148
|
-
- - ! '
|
165
|
+
- - ! '>'
|
149
166
|
- !ruby/object:Gem::Version
|
150
|
-
version:
|
151
|
-
segments:
|
152
|
-
- 0
|
153
|
-
hash: -808852144891410131
|
167
|
+
version: 1.3.1
|
154
168
|
requirements: []
|
155
169
|
rubyforge_project: engineyard-recipes
|
156
|
-
rubygems_version: 1.8.
|
170
|
+
rubygems_version: 1.8.10
|
157
171
|
signing_key:
|
158
172
|
specification_version: 3
|
159
173
|
summary: Tools to generate, upload, test and apply chef recipes for Engine Yard Cloud.
|
@@ -162,9 +176,14 @@ test_files:
|
|
162
176
|
- features/generate-helper-definitions.feature
|
163
177
|
- features/generate-recipe.feature
|
164
178
|
- features/init-new-cookbook.feature
|
179
|
+
- features/init-sm-framework.feature
|
165
180
|
- features/step_definitions/api_steps.rb
|
166
181
|
- features/step_definitions/common_steps.rb
|
167
182
|
- features/step_definitions/fixture_project_steps.rb
|
183
|
+
- features/step_definitions/mock_git_steps.rb
|
168
184
|
- features/support/common.rb
|
169
185
|
- features/support/env.rb
|
170
186
|
- features/support/matchers.rb
|
187
|
+
- features/wrap-sm-extension.feature
|
188
|
+
- spec/fetch_uri_spec.rb
|
189
|
+
- spec/spec_helper.rb
|