producer-core 0.5.8 → 0.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/lib/producer/core/version.rb +1 -1
  3. metadata +21 -202
  4. data/.gitignore +0 -3
  5. data/.travis.yml +0 -14
  6. data/Gemfile +0 -5
  7. data/Guardfile +0 -14
  8. data/LICENSE +0 -30
  9. data/Rakefile +0 -19
  10. data/config/cucumber.yaml +0 -2
  11. data/features/actions/echo.feature +0 -11
  12. data/features/actions/file_append.feature +0 -15
  13. data/features/actions/file_replace_content.feature +0 -24
  14. data/features/actions/file_write.feature +0 -21
  15. data/features/actions/mkdir.feature +0 -31
  16. data/features/actions/sh.feature +0 -43
  17. data/features/actions/yaml_write.feature +0 -14
  18. data/features/cli/debug.feature +0 -19
  19. data/features/cli/dry_run.feature +0 -22
  20. data/features/cli/error_reporting.feature +0 -32
  21. data/features/cli/target.feature +0 -15
  22. data/features/cli/usage.feature +0 -13
  23. data/features/cli/verbose.feature +0 -48
  24. data/features/condition/negated_test.feature +0 -47
  25. data/features/condition/target.feature +0 -15
  26. data/features/recipe/compose_macro.feature +0 -29
  27. data/features/recipe/errors.feature +0 -9
  28. data/features/recipe/macro.feature +0 -50
  29. data/features/recipe/registry.feature +0 -82
  30. data/features/recipe/source.feature +0 -17
  31. data/features/recipe/target.feature +0 -23
  32. data/features/recipe/test_macro.feature +0 -50
  33. data/features/ssh/config.feature +0 -25
  34. data/features/steps/environment_steps.rb +0 -3
  35. data/features/support/env.rb +0 -1
  36. data/features/task/ask.feature +0 -23
  37. data/features/task/condition.feature +0 -13
  38. data/features/task/nested_tasks.feature +0 -20
  39. data/features/task/recipe_argv.feature +0 -13
  40. data/features/task/target.feature +0 -11
  41. data/features/task/template.feature +0 -49
  42. data/features/tests/dir.feature +0 -21
  43. data/features/tests/env.feature +0 -47
  44. data/features/tests/executable.feature +0 -26
  45. data/features/tests/file.feature +0 -21
  46. data/features/tests/file_contains.feature +0 -26
  47. data/features/tests/file_eq.feature +0 -26
  48. data/features/tests/file_match.feature +0 -26
  49. data/features/tests/shell_command_status.feature +0 -46
  50. data/features/tests/yaml_eq.feature +0 -26
  51. data/producer-core.gemspec +0 -28
  52. data/spec/fixtures/recipes/empty.rb +0 -1
  53. data/spec/fixtures/recipes/raise.rb +0 -1
  54. data/spec/fixtures/recipes/some_recipe.rb +0 -5
  55. data/spec/fixtures/recipes/throw.rb +0 -1
  56. data/spec/fixtures/templates/basic.erb +0 -1
  57. data/spec/fixtures/templates/basic_yaml.yaml +0 -1
  58. data/spec/fixtures/templates/variables.erb +0 -1
  59. data/spec/producer/core/action_spec.rb +0 -46
  60. data/spec/producer/core/actions/echo_spec.rb +0 -20
  61. data/spec/producer/core/actions/file_append_spec.rb +0 -49
  62. data/spec/producer/core/actions/file_replace_content_spec.rb +0 -42
  63. data/spec/producer/core/actions/file_writer_spec.rb +0 -52
  64. data/spec/producer/core/actions/mkdir_spec.rb +0 -71
  65. data/spec/producer/core/actions/shell_command_spec.rb +0 -45
  66. data/spec/producer/core/actions/yaml_writer_spec.rb +0 -25
  67. data/spec/producer/core/cli_spec.rb +0 -211
  68. data/spec/producer/core/condition_spec.rb +0 -198
  69. data/spec/producer/core/env_spec.rb +0 -196
  70. data/spec/producer/core/error_formatter_spec.rb +0 -86
  71. data/spec/producer/core/logger_formatter_spec.rb +0 -26
  72. data/spec/producer/core/prompter_spec.rb +0 -40
  73. data/spec/producer/core/recipe/file_evaluator_spec.rb +0 -22
  74. data/spec/producer/core/recipe_spec.rb +0 -126
  75. data/spec/producer/core/remote/environment_spec.rb +0 -19
  76. data/spec/producer/core/remote/fs_spec.rb +0 -144
  77. data/spec/producer/core/remote_spec.rb +0 -168
  78. data/spec/producer/core/task_spec.rb +0 -198
  79. data/spec/producer/core/template_spec.rb +0 -41
  80. data/spec/producer/core/test_spec.rb +0 -7
  81. data/spec/producer/core/testing/mock_remote_spec.rb +0 -66
  82. data/spec/producer/core/tests/condition_test_spec.rb +0 -55
  83. data/spec/producer/core/tests/file_contains_spec.rb +0 -46
  84. data/spec/producer/core/tests/file_eq_spec.rb +0 -45
  85. data/spec/producer/core/tests/file_match_spec.rb +0 -46
  86. data/spec/producer/core/tests/has_dir_spec.rb +0 -25
  87. data/spec/producer/core/tests/has_env_spec.rb +0 -75
  88. data/spec/producer/core/tests/has_executable_spec.rb +0 -29
  89. data/spec/producer/core/tests/has_file_spec.rb +0 -25
  90. data/spec/producer/core/tests/shell_command_status_spec.rb +0 -34
  91. data/spec/producer/core/tests/yaml_eq_spec.rb +0 -47
  92. data/spec/producer/core/worker_spec.rb +0 -88
  93. data/spec/spec_helper.rb +0 -13
  94. data/spec/support/exit_helpers.rb +0 -6
  95. data/spec/support/fixtures_helpers.rb +0 -7
  96. data/spec/support/net_ssh_story_helpers.rb +0 -36
  97. data/spec/support/shared_action.rb +0 -44
  98. data/spec/support/shared_test.rb +0 -82
  99. data/spec/support/test_env_helpers.rb +0 -44
@@ -1,21 +0,0 @@
1
- @sshd
2
- Feature: `file?' condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :file_test do
8
- condition { file? 'some_file' }
9
-
10
- echo 'evaluated'
11
- end
12
- """
13
-
14
- Scenario: succeeds when file exists
15
- Given a remote file named "some_file"
16
- When I successfully execute the recipe on remote target
17
- Then the output must contain "evaluated"
18
-
19
- Scenario: fails when file does not exist
20
- When I successfully execute the recipe on remote target
21
- Then the output must not contain "evaluated"
@@ -1,26 +0,0 @@
1
- @sshd
2
- Feature: `file_contains' condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :file_contains_test do
8
- condition { file_contains 'some_file', 'some_content' }
9
-
10
- echo 'evaluated'
11
- end
12
- """
13
-
14
- Scenario: succeeds when file contains expected content
15
- Given a remote file named "some_file" with "some_content"
16
- When I successfully execute the recipe on remote target
17
- Then the output must contain "evaluated"
18
-
19
- Scenario: fails when file does not contain expected content
20
- Given a remote file named "some_file" with "some_other_content"
21
- When I successfully execute the recipe on remote target
22
- Then the output must not contain "evaluated"
23
-
24
- Scenario: fails when file does not exist
25
- When I successfully execute the recipe on remote target
26
- Then the output must not contain "evaluated"
@@ -1,26 +0,0 @@
1
- @sshd
2
- Feature: `file_eq' condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :file_eq_test do
8
- condition { file_eq 'some_file', 'some content' }
9
-
10
- echo 'evaluated'
11
- end
12
- """
13
-
14
- Scenario: succeeds when file content is expected content
15
- Given a remote file named "some_file" with "some content"
16
- When I successfully execute the recipe on remote target
17
- Then the output must contain "evaluated"
18
-
19
- Scenario: fails when file content is not expected content
20
- Given a remote file named "some_file" with "some content padded"
21
- When I successfully execute the recipe on remote target
22
- Then the output must not contain "evaluated"
23
-
24
- Scenario: fails when file does not exist
25
- When I successfully execute the recipe on remote target
26
- Then the output must not contain "evaluated"
@@ -1,26 +0,0 @@
1
- @sshd
2
- Feature: `file_match' condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :file_match_test do
8
- condition { file_match 'some_file', /\Asome_content\z/ }
9
-
10
- echo 'evaluated'
11
- end
12
- """
13
-
14
- Scenario: succeeds when file match pattern
15
- Given a remote file named "some_file" with "some_content"
16
- When I successfully execute the recipe on remote target
17
- Then the output must contain "evaluated"
18
-
19
- Scenario: fails when file does not match pattern
20
- Given a remote file named "some_file" with "some_other_content"
21
- When I successfully execute the recipe on remote target
22
- Then the output must not contain "evaluated"
23
-
24
- Scenario: fails when file does not exist
25
- When I successfully execute the recipe on remote target
26
- Then the output must not contain "evaluated"
@@ -1,46 +0,0 @@
1
- @sshd
2
- Feature: `sh' and `` condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :sh_test_ok do
8
- condition { sh 'true' }
9
-
10
- echo 'test_ok'
11
- end
12
-
13
- task :sh_test_ko do
14
- condition { sh 'false' }
15
-
16
- echo 'test_ko'
17
- end
18
-
19
- task :sh_test_backtick_ok do
20
- condition { `true` }
21
-
22
- echo 'test_backtick_ok'
23
- end
24
-
25
- task :sh_test_backtick_ko do
26
- condition { `false` }
27
-
28
- echo 'test_backtick_ko'
29
- end
30
- """
31
-
32
- Scenario: succeeds when remote command execution is a success
33
- When I successfully execute the recipe on remote target
34
- Then the output must contain "test_ok"
35
-
36
- Scenario: fails when remote executable is not available
37
- When I successfully execute the recipe on remote target
38
- Then the output must not contain "test_ko"
39
-
40
- Scenario: `` alias, succeeds when remote executable is available
41
- When I successfully execute the recipe on remote target
42
- Then the output must contain "test_backtick_ok"
43
-
44
- Scenario: `` alias, fails when remote executable is not available
45
- When I successfully execute the recipe on remote target
46
- Then the output must not contain "test_backtick_ko"
@@ -1,26 +0,0 @@
1
- @sshd
2
- Feature: `yaml_eq' condition keyword
3
-
4
- Background:
5
- Given a recipe with:
6
- """
7
- task :yaml_eq_test do
8
- condition { yaml_eq 'some_file', { foo: 'bar' } }
9
-
10
- echo 'evaluated'
11
- end
12
- """
13
-
14
- Scenario: succeeds when YAML data is equivalent
15
- Given a remote file named "some_file" with ":foo: bar"
16
- When I successfully execute the recipe on remote target
17
- Then the output must contain "evaluated"
18
-
19
- Scenario: fails when YAML data differs
20
- Given a remote file named "some_file" with ":foo: baz"
21
- When I successfully execute the recipe on remote target
22
- Then the output must not contain "evaluated"
23
-
24
- Scenario: fails when YAML file does not exist
25
- When I successfully execute the recipe on remote target
26
- Then the output must not contain "evaluated"
@@ -1,28 +0,0 @@
1
- require File.expand_path('../lib/producer/core/version', __FILE__)
2
-
3
- Gem::Specification.new do |s|
4
- s.name = 'producer-core'
5
- s.version = Producer::Core::VERSION.dup
6
- s.summary = 'Provisioning tool'
7
- s.description = <<-eoh.gsub(/^ +/, '')
8
- Software provisioning tool, including a DSL to write "recipes".
9
- eoh
10
- s.homepage = 'https://rubygems.org/gems/producer-core'
11
-
12
- s.authors = 'Thibault Jouan'
13
- s.email = 'tj@a13.fr'
14
-
15
- s.files = `git ls-files`.split $/
16
- s.test_files = s.files.grep /\A(spec|features)\//
17
- s.executables = s.files.grep(/\Abin\//) { |f| File.basename(f) }
18
-
19
-
20
- s.add_dependency 'net-ssh', '~> 2.7'
21
- s.add_dependency 'net-sftp', '~> 2.1'
22
-
23
- s.add_development_dependency 'rspec', '~> 3.1'
24
- s.add_development_dependency 'cucumber', '~> 2.0'
25
- s.add_development_dependency 'aruba', '~> 0.8'
26
- s.add_development_dependency 'cucumber-sshd', '~> 1.1.1'
27
- s.add_development_dependency 'rake', '~> 10.1'
28
- end
@@ -1 +0,0 @@
1
- # can contain tasks written in ruby language.
@@ -1 +0,0 @@
1
- fail Producer::Core::RemoteCommandExecutionError, 'false'
@@ -1,5 +0,0 @@
1
- task :some_task do
2
- end
3
-
4
- task :another_task do
5
- end
@@ -1 +0,0 @@
1
- throw :recipe_code
@@ -1 +0,0 @@
1
- basic template
@@ -1 +0,0 @@
1
- foo: bar
@@ -1 +0,0 @@
1
- <%= @foo %>
@@ -1,46 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- describe Action do
5
- let(:env) { double 'env'}
6
- let(:arguments) { [:some, :arguments] }
7
- let(:options) { { foo: :bar } }
8
- subject(:action) { described_class.new(env, *arguments, options) }
9
-
10
- it_behaves_like 'action'
11
-
12
- describe '#initialize' do
13
- it 'calls #setup when defined' do
14
- action_class = Class.new(described_class)
15
- action_class.class_eval do
16
- define_method(:setup) { @arguments = :other_arguments }
17
- end
18
- expect(action_class.new(env).arguments).to eq :other_arguments
19
- end
20
- end
21
-
22
- describe '#name' do
23
- it 'infers action name from class name' do
24
- expect(action.name).to eq 'action'
25
- end
26
- end
27
-
28
- describe '#to_s' do
29
- it 'includes action name' do
30
- expect(action.to_s).to match /\A#{action.name}/
31
- end
32
-
33
- it 'includes arguments inspection' do
34
- expect(action.to_s).to match /#{Regexp.quote(arguments.inspect)}\z/
35
- end
36
-
37
- context 'when arguments inspection is very long' do
38
- let(:arguments) { [:some, :arguments] * 32 }
39
-
40
- it 'summarizes arguments inspection' do
41
- expect(action.to_s.length).to be < 70
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe Echo, :env do
6
- let(:text) { 'hello' }
7
- let(:arguments) { [text] }
8
- subject(:echo) { described_class.new(env, *arguments) }
9
-
10
- it_behaves_like 'action'
11
-
12
- describe '#apply' do
13
- it 'writes the given string to env output with a record separator' do
14
- echo.apply
15
- expect(output).to eq "hello\n"
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe FileAppend, :env do
6
- let(:path) { 'some_path' }
7
- let(:content) { 'some content' }
8
- let(:added_content) { ' added' }
9
- let(:arguments) { [path, added_content] }
10
- subject(:action) { described_class.new(env, *arguments) }
11
-
12
- it_behaves_like 'action'
13
-
14
- before { allow(remote_fs).to receive(:file_read).with(path) { content } }
15
-
16
- describe '#setup' do
17
- context 'when content is missing' do
18
- let(:added_content) { nil }
19
-
20
- it 'raises ArgumentError' do
21
- expect { action }.to raise_error ArgumentError
22
- end
23
- end
24
- end
25
-
26
- describe '#apply' do
27
- it 'appends given content to requested file on remote filesystem' do
28
- expect(remote_fs)
29
- .to receive(:file_write).with(path, action.combined_content)
30
- action.apply
31
- end
32
- end
33
-
34
- describe '#combined_content' do
35
- it 'returns original content and added content combined' do
36
- expect(action.combined_content).to eq 'some content added'
37
- end
38
-
39
- context 'when fs.file_read returns nil' do
40
- before { allow(remote_fs).to receive(:file_read).with(path) { nil } }
41
-
42
- it 'returns only the added content' do
43
- expect(action.combined_content).to eq ' added'
44
- end
45
- end
46
- end
47
- end
48
- end
49
- end
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe FileReplaceContent, :env do
6
- let(:path) { 'some_path' }
7
- let(:pattern) { 'content' }
8
- let(:replacement) { 'other content' }
9
- let(:content) { 'some content' }
10
- let(:arguments) { [path, pattern, replacement] }
11
- subject(:action) { described_class.new(env, *arguments) }
12
-
13
- it_behaves_like 'action'
14
-
15
- before { allow(remote_fs).to receive(:file_read).with(path) { content } }
16
-
17
- describe '#setup' do
18
- context 'when replacement is missing' do
19
- let(:replacement) { nil }
20
-
21
- it 'raises ArgumentError' do
22
- expect { action }.to raise_error ArgumentError
23
- end
24
- end
25
- end
26
-
27
- describe '#apply' do
28
- it 'writes replaced content to file on remote filesystem' do
29
- expect(remote_fs)
30
- .to receive(:file_write).with(path, action.replaced_content)
31
- action.apply
32
- end
33
- end
34
-
35
- describe '#replaced_content' do
36
- it 'returns content with pattern occurrences pattern replaced' do
37
- expect(action.replaced_content).to eq 'some other content'
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,52 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe FileWriter, :env do
6
- let(:path) { 'some_path' }
7
- let(:content) { 'some_content' }
8
- let(:arguments) { [path, content] }
9
- let(:options) { { } }
10
- subject(:writer) { described_class.new(env, *arguments, options) }
11
-
12
- it_behaves_like 'action'
13
-
14
- describe '#setup' do
15
- let(:options) { { mode: 0700, user: 'root' } }
16
-
17
- it 'translates mode option as permissions' do
18
- expect(writer.options[:permissions]).to eq 0700
19
- end
20
-
21
- it 'translates user option as owner' do
22
- expect(writer.options[:owner]).to eq 'root'
23
- end
24
-
25
- context 'when content is missing' do
26
- let(:content) { nil }
27
-
28
- it 'raises ArgumentError' do
29
- expect { writer }.to raise_error ArgumentError
30
- end
31
- end
32
- end
33
-
34
- describe '#apply' do
35
- it 'writes content to file on remote filesystem' do
36
- expect(remote_fs)
37
- .to receive(:file_write).with(path, content)
38
- writer.apply
39
- end
40
-
41
- context 'when status options are given' do
42
- let(:options) { { group: 'wheel' } }
43
-
44
- it 'changes the directory status with given options' do
45
- expect(remote_fs).to receive(:setstat).with(path, options)
46
- writer.apply
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe Mkdir, :env do
6
- let(:path) { 'some_path' }
7
- let(:options) { { } }
8
- let(:arguments) { [path] }
9
- subject(:mkdir) { described_class.new(env, *arguments, options) }
10
-
11
- it_behaves_like 'action'
12
-
13
- describe '#setup' do
14
- let(:options) { { mode: 0700, user: 'root' } }
15
-
16
- it 'translates mode option as permissions' do
17
- expect(mkdir.options[:permissions]).to eq 0700
18
- end
19
-
20
- it 'translates user option as owner' do
21
- expect(mkdir.options[:owner]).to eq 'root'
22
- end
23
-
24
- context 'when path is missing' do
25
- let(:path) { nil }
26
-
27
- it 'raises ArgumentError' do
28
- expect { mkdir }.to raise_error ArgumentError
29
- end
30
- end
31
- end
32
-
33
- describe '#apply' do
34
- before { allow(remote_fs).to receive(:dir?) { false } }
35
-
36
- it 'creates directory on remote filesystem' do
37
- expect(remote_fs).to receive(:mkdir).with(path)
38
- mkdir.apply
39
- end
40
-
41
- context 'when status options are given' do
42
- let(:options) { { group: 'wheel' } }
43
-
44
- it 'changes the directory status with given options' do
45
- expect(remote_fs).to receive(:setstat).with(path, options)
46
- mkdir.apply
47
- end
48
- end
49
-
50
- context 'when parent directories does not exist' do
51
- let(:path) { 'some/path' }
52
-
53
- it 'creates parent directories' do
54
- expect(remote_fs).to receive(:mkdir).with('some').ordered
55
- expect(remote_fs).to receive(:mkdir).with('some/path').ordered
56
- mkdir.apply
57
- end
58
- end
59
-
60
- context 'when directory already exists' do
61
- before { allow(remote_fs).to receive(:dir?) { true } }
62
-
63
- it 'does not create any directory' do
64
- expect(remote_fs).not_to receive(:mkdir)
65
- mkdir.apply
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,45 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe ShellCommand, :env do
6
- let(:command_args) { 'hello from remote host' }
7
- let(:command) { "echo #{command_args}" }
8
- let(:arguments) { [command] }
9
- subject(:sh) { described_class.new(env, *arguments) }
10
-
11
- it_behaves_like 'action'
12
-
13
- describe '#setup' do
14
- context 'when command is missing' do
15
- let(:command) { nil }
16
-
17
- it 'raises ArgumentError' do
18
- expect { sh }.to raise_error ArgumentError
19
- end
20
- end
21
- end
22
-
23
- describe '#apply' do
24
- it 'executes the remote command' do
25
- expect_execution(command)
26
- sh.apply
27
- end
28
-
29
- it 'writes the returned output' do
30
- sh.apply
31
- expect(output).to eq "#{command_args}\n"
32
- end
33
-
34
- context 'when content is written to standard error' do
35
- let(:command) { "echo #{command_args} >&2" }
36
-
37
- it 'writes errors to given error stream' do
38
- sh.apply
39
- expect(error_output).to eq "#{command_args}\n"
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,25 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Producer::Core
4
- module Actions
5
- describe YAMLWriter, :env do
6
- let(:path) { 'some_path' }
7
- let(:data) { { foo: 'bar' } }
8
- let(:arguments) { [path] }
9
- let(:options) { { data: data } }
10
- subject(:writer) { described_class.new(env, *arguments, options) }
11
-
12
- it_behaves_like 'action'
13
-
14
- it { is_expected.to be_a FileWriter}
15
-
16
- describe '#apply' do
17
- it 'writes data as YAML to file on remote filesystem' do
18
- expect(remote_fs)
19
- .to receive(:file_write).with(path, data.to_yaml)
20
- writer.apply
21
- end
22
- end
23
- end
24
- end
25
- end