katello-foreman-engine 0.0.7 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/katello-foreman-engine.gemspec +1 -1
- data/lib/katello_foreman_engine/actions/{environment_create.rb → content_view_create.rb} +6 -14
- data/lib/katello_foreman_engine/actions/content_view_publish.rb +4 -2
- data/lib/katello_foreman_engine/actions/environment_destroy.rb +2 -13
- data/test/lib/actions/content_view_publish_test.rb +9 -10
- data/test/lib/actions/env_destroy_test.rb +0 -22
- metadata +18 -18
- data/test/lib/actions/env_create_test.rb +0 -34
@@ -12,24 +12,16 @@
|
|
12
12
|
|
13
13
|
module KatelloForemanEngine
|
14
14
|
module Actions
|
15
|
-
class
|
15
|
+
class ContentViewCreate < Dynflow::Action
|
16
16
|
|
17
17
|
def self.subscribe
|
18
|
-
Katello::Actions::
|
18
|
+
Katello::Actions::ContentViewCreate
|
19
19
|
end
|
20
20
|
|
21
|
-
def plan(
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
input_format do
|
26
|
-
param :org_label, String
|
27
|
-
param :label, String
|
28
|
-
param :content_view_id, String
|
29
|
-
end
|
30
|
-
|
31
|
-
def run
|
32
|
-
Bindings.environment_create(input['content_view_id'], input['org_label'], input['label'])
|
21
|
+
def plan(content_view)
|
22
|
+
if content_view.default?
|
23
|
+
plan_action ContentViewPublish, content_view
|
24
|
+
end
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
@@ -20,8 +20,10 @@ module KatelloForemanEngine
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def plan(content_view)
|
23
|
-
unless Bindings.environment_find(
|
24
|
-
plan_self
|
23
|
+
unless Bindings.environment_find(content_view.organization.label, 'Library', content_view.label)
|
24
|
+
plan_self('id' => content_view.id,
|
25
|
+
'label' => content_view.label,
|
26
|
+
'organization_label' => content_view.organization.label)
|
25
27
|
end
|
26
28
|
content_view.repos(content_view.organization.library).each do |repo|
|
27
29
|
plan_action(RepositoryChange, repo)
|
@@ -14,26 +14,15 @@ module KatelloForemanEngine
|
|
14
14
|
module Actions
|
15
15
|
class EnvironmentDestroy < Dynflow::Action
|
16
16
|
|
17
|
-
input_format do
|
18
|
-
param :foreman_id, String
|
19
|
-
end
|
20
|
-
|
21
17
|
def self.subscribe
|
22
18
|
Katello::Actions::EnvironmentDestroy
|
23
19
|
end
|
24
20
|
|
25
21
|
def plan(env)
|
26
|
-
|
27
|
-
|
28
|
-
plan_action(ContentViewDemote, content_view, env)
|
29
|
-
end
|
30
|
-
plan_self 'foreman_id' => foreman_env['environment']['id']
|
22
|
+
env.content_views.each do |content_view|
|
23
|
+
plan_action(ContentViewDemote, content_view, env)
|
31
24
|
end
|
32
25
|
end
|
33
|
-
|
34
|
-
def run
|
35
|
-
Bindings.environment_destroy(input['foreman_id'])
|
36
|
-
end
|
37
26
|
end
|
38
27
|
end
|
39
28
|
end
|
@@ -5,24 +5,23 @@ module KatelloForemanEngine
|
|
5
5
|
class ContentViewPublishTest < ActiveSupport::TestCase
|
6
6
|
|
7
7
|
def setup
|
8
|
-
@org = Organization.new(:label => '
|
9
|
-
@content_view = ContentView.new
|
8
|
+
@org = Organization.new(:label => 'ACME')
|
9
|
+
@content_view = ContentView.new(:label => 'cv', :id => '123') do |cv|
|
10
|
+
cv.organization = @org
|
11
|
+
end
|
10
12
|
@content_view.stubs(:repos).returns([])
|
11
|
-
|
12
|
-
@input = { 'organization_label' => 'ACME',
|
13
|
-
'id' => '123',
|
14
|
-
'label' => 'cv' }
|
15
13
|
end
|
16
14
|
|
17
15
|
test "runs unless the environment in foreman is already created " do
|
18
16
|
Bindings.stubs(:environment_find).with('ACME', 'Library', 'cv').returns(nil)
|
19
17
|
|
20
|
-
step = run_steps(ContentViewPublish,
|
18
|
+
step = run_steps(ContentViewPublish, {}, @content_view).first
|
21
19
|
assert_equal ContentViewPublish, step.action_class
|
22
|
-
assert_equal step.input
|
20
|
+
assert_equal 'cv', step.input['label']
|
21
|
+
assert_equal 'ACME', step.input['organization_label']
|
23
22
|
|
24
23
|
Bindings.stubs(:environment_find).with('ACME', 'Library', 'cv').returns({'id' => '123'})
|
25
|
-
assert_equal [], run_steps(ContentViewPublish,
|
24
|
+
assert_equal [], run_steps(ContentViewPublish, {}, @content_view)
|
26
25
|
end
|
27
26
|
|
28
27
|
test "plans repository change action for every repo involved" do
|
@@ -30,7 +29,7 @@ module KatelloForemanEngine
|
|
30
29
|
repo = Repository.new
|
31
30
|
@content_view.stubs(:repos).returns([repo])
|
32
31
|
|
33
|
-
action_class, arg = planned_actions(ContentViewPublish,
|
32
|
+
action_class, arg = planned_actions(ContentViewPublish, {}, @content_view).first
|
34
33
|
assert_equal RepositoryChange, action_class
|
35
34
|
assert_equal arg, repo
|
36
35
|
end
|
@@ -9,30 +9,8 @@ module KatelloForemanEngine
|
|
9
9
|
env = KTEnvironment.new(:label => 'dev')
|
10
10
|
env.organization = org
|
11
11
|
|
12
|
-
foreman_env = { 'environment' => { 'id' => '123' } }
|
13
|
-
Bindings.expects(:environment_find).with('org', 'dev').
|
14
|
-
times(2).returns(foreman_env)
|
15
|
-
|
16
|
-
env.library = false
|
17
|
-
step = run_steps(EnvironmentDestroy,{}, env).first
|
18
|
-
assert_equal EnvironmentDestroy, step.action_class
|
19
|
-
assert_equal step.input['foreman_id'], '123'
|
20
|
-
|
21
|
-
env.library = true
|
22
|
-
step = run_steps(EnvironmentDestroy,{}, env).first
|
23
|
-
assert_equal EnvironmentDestroy, step.action_class
|
24
|
-
assert_equal step.input['foreman_id'], '123'
|
25
|
-
|
26
|
-
env.library = false
|
27
|
-
Bindings.expects(:environment_find).returns(nil)
|
28
12
|
assert_equal [], run_steps(EnvironmentDestroy,{}, env)
|
29
13
|
end
|
30
|
-
|
31
|
-
test 'calls bindings to destroy environment' do
|
32
|
-
Bindings.expects(:environment_destroy).with('123')
|
33
|
-
EnvironmentDestroy.new('foreman_id' => '123').run
|
34
|
-
end
|
35
|
-
|
36
14
|
end
|
37
15
|
end
|
38
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katello-foreman-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -53,35 +53,34 @@ files:
|
|
53
53
|
- katello-foreman-engine.gemspec
|
54
54
|
- LICENSE
|
55
55
|
- Rakefile
|
56
|
-
- lib/
|
56
|
+
- lib/katello-foreman-engine.rb
|
57
|
+
- lib/katello_foreman_engine/engine.rb
|
58
|
+
- lib/katello_foreman_engine/actions/environment_destroy.rb
|
59
|
+
- lib/katello_foreman_engine/actions/distribution_unpublish.rb
|
57
60
|
- lib/katello_foreman_engine/actions/changeset_promote.rb
|
58
|
-
- lib/katello_foreman_engine/actions/content_view_promote.rb
|
59
|
-
- lib/katello_foreman_engine/actions/content_view_publish.rb
|
60
|
-
- lib/katello_foreman_engine/actions/repository_change.rb
|
61
61
|
- lib/katello_foreman_engine/actions/content_view_demote.rb
|
62
62
|
- lib/katello_foreman_engine/actions/user_destroy.rb
|
63
|
-
- lib/katello_foreman_engine/actions/distribution_unpublish.rb
|
64
|
-
- lib/katello_foreman_engine/actions/distribution_publish.rb
|
65
63
|
- lib/katello_foreman_engine/actions/org_destroy.rb
|
64
|
+
- lib/katello_foreman_engine/actions/content_view_create.rb
|
65
|
+
- lib/katello_foreman_engine/actions/repository_change.rb
|
66
|
+
- lib/katello_foreman_engine/actions/distribution_publish.rb
|
67
|
+
- lib/katello_foreman_engine/actions/content_view_publish.rb
|
68
|
+
- lib/katello_foreman_engine/actions/content_view_promote.rb
|
66
69
|
- lib/katello_foreman_engine/actions/user_create.rb
|
67
70
|
- lib/katello_foreman_engine/actions/org_create.rb
|
68
|
-
- lib/katello_foreman_engine/actions/environment_create.rb
|
69
|
-
- lib/katello_foreman_engine/actions/environment_destroy.rb
|
70
71
|
- lib/katello_foreman_engine/settings.rb
|
71
|
-
- lib/katello_foreman_engine/engine.rb
|
72
|
-
- lib/katello_foreman_engine/helpers.rb
|
73
72
|
- lib/katello_foreman_engine/bindings.rb
|
74
|
-
- lib/
|
73
|
+
- lib/katello_foreman_engine/helpers.rb
|
74
|
+
- lib/katello_foreman_engine.rb
|
75
75
|
- test/test_helper.rb
|
76
76
|
- test/lib/settings_test.rb
|
77
|
-
- test/lib/actions/
|
78
|
-
- test/lib/actions/distribution_unpublish_test.rb
|
79
|
-
- test/lib/actions/org_destroy_test.rb
|
80
|
-
- test/lib/actions/env_create_test.rb
|
77
|
+
- test/lib/actions/content_view_publish_test.rb
|
81
78
|
- test/lib/actions/org_create_test.rb
|
79
|
+
- test/lib/actions/distribution_unpublish_test.rb
|
82
80
|
- test/lib/actions/repository_change_test.rb
|
81
|
+
- test/lib/actions/org_destroy_test.rb
|
82
|
+
- test/lib/actions/env_destroy_test.rb
|
83
83
|
- test/lib/actions/distribution_publish_test.rb
|
84
|
-
- test/lib/actions/content_view_publish_test.rb
|
85
84
|
- test/lib/bindings_test.rb
|
86
85
|
homepage: http://github.com/katello/katello-foreman-engine
|
87
86
|
licenses:
|
@@ -104,8 +103,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
103
|
version: '0'
|
105
104
|
requirements: []
|
106
105
|
rubyforge_project:
|
107
|
-
rubygems_version: 1.8.
|
106
|
+
rubygems_version: 1.8.23
|
108
107
|
signing_key:
|
109
108
|
specification_version: 3
|
110
109
|
summary: Foreman specific parts of Katello
|
111
110
|
test_files: []
|
111
|
+
has_rdoc:
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
module KatelloForemanEngine
|
4
|
-
module Actions
|
5
|
-
class EnvCreateTest < ActiveSupport::TestCase
|
6
|
-
|
7
|
-
test "runs both for library and non-library envs " do
|
8
|
-
org = Organization.new(:label => 'org')
|
9
|
-
env = KTEnvironment.new(:label => 'dev')
|
10
|
-
env.organization = org
|
11
|
-
|
12
|
-
env.library = false
|
13
|
-
step = run_steps(EnvironmentCreate, {}, env).first
|
14
|
-
assert_equal EnvironmentCreate, step.action_class
|
15
|
-
assert_equal 'org', step.input['org_label']
|
16
|
-
assert_equal 'dev', step.input['label']
|
17
|
-
assert_equal 'env', step.input['content_view_id']
|
18
|
-
|
19
|
-
env.library = true
|
20
|
-
step = run_steps(EnvironmentCreate, {}, env).first
|
21
|
-
assert_equal EnvironmentCreate, step.action_class
|
22
|
-
assert_equal 'org', step.input['org_label']
|
23
|
-
assert_equal 'dev', step.input['label']
|
24
|
-
assert_equal 'env', step.input['content_view_id']
|
25
|
-
end
|
26
|
-
|
27
|
-
test 'calls bindings to create environment' do
|
28
|
-
Bindings.expects(:environment_create).with('env', 'org', 'dev')
|
29
|
-
EnvironmentCreate.new('org_label' => 'org', 'label' => 'dev', 'content_view_id' => 'env').run
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|