foreman_docker 4.0.0 → 4.1.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/containers_controller.rb +3 -3
- data/app/models/concerns/foreman_docker/parameter_validators.rb +2 -2
- data/app/models/container.rb +1 -1
- data/app/models/docker_container_wizard_state.rb +4 -4
- data/app/models/docker_container_wizard_states/configuration.rb +1 -1
- data/app/models/docker_container_wizard_states/environment.rb +1 -1
- data/app/models/docker_container_wizard_states/image.rb +1 -1
- data/app/models/docker_container_wizard_states/preliminary.rb +1 -1
- data/app/models/service/containers.rb +1 -1
- data/db/migrate/20180105090316_remove_docker_search_permission.rb +13 -0
- data/lib/foreman_docker/engine.rb +1 -1
- data/lib/foreman_docker/version.rb +1 -1
- data/test/functionals/containers_controller_test.rb +2 -2
- data/test/functionals/image_search_controller_test.rb +51 -28
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 742be737268d18e9406b2e44b41fe3f8a76add83
|
4
|
+
data.tar.gz: 020370eb15873e7527a2efd2d3577d48b84ad00d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ebeae9695d4cf06e6e22485c14252864a57416bfc8f4db3ffbb79f15359c1648a51fe7332a74f87e50a77e12a3092637562b693972ef84e786a7156ca17e9d3
|
7
|
+
data.tar.gz: 02b9638cbe1075186286781625210fd3112c41b593be3886843f895efbe93409dcfb7a029f66fae03a70d5bdbe3cb8b1775fd8780d6033b74c2f732eacbeeb64
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|

|
31
31
|
|
32
32
|
### Planned
|
33
|
-
* [Kubernetes](https://github.com/
|
33
|
+
* [Kubernetes](https://github.com/kubernetes/kubernetes/) integration
|
34
34
|
* Events stream ([#8037](http://projects.theforeman.org/issues/8037))
|
35
35
|
* Tight integration between Docker hosts [Atomic](http://www.projectatomic.io/) and [CoreOS](http://coreos.com/) and containers ([#7653](http://projects.theforeman.org/issues/7653), [#7652](http://projects.theforeman.org/issues/7652))
|
36
36
|
* Quickstart images - pre-supplied images and configuration ([#7869](http://projects.theforeman.org/issues/7869))
|
@@ -29,7 +29,7 @@ class ContainersController < ::ApplicationController
|
|
29
29
|
if @container.present?
|
30
30
|
process_error(:redirect => containers_path)
|
31
31
|
else
|
32
|
-
|
32
|
+
redirect_back(:fallback_location => containers_path)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
rescue ActiveRecord::RecordNotFound
|
@@ -67,12 +67,12 @@ class ContainersController < ::ApplicationController
|
|
67
67
|
redirect_to containers_path(:id => @container.id)
|
68
68
|
else
|
69
69
|
error _("failed to %{action} %{vm}") % { :action => _(action), :vm => @docker_container }
|
70
|
-
|
70
|
+
redirect_back(:fallback_location => containers_path)
|
71
71
|
end
|
72
72
|
# This should only rescue Fog::Errors, but Fog returns all kinds of errors...
|
73
73
|
rescue => e
|
74
74
|
error _("Error - %{message}") % { :message => _(e.message) }
|
75
|
-
|
75
|
+
redirect_back(:fallback_location => containers_path)
|
76
76
|
end
|
77
77
|
|
78
78
|
private
|
@@ -16,13 +16,13 @@ module ForemanDocker
|
|
16
16
|
errors = duplicate_key?(keys, param)
|
17
17
|
end
|
18
18
|
|
19
|
-
self.errors
|
19
|
+
self.errors.add(param_symbol, _('Please ensure the following parameters are unique')) if errors
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def duplicate_key?(keys, param)
|
24
24
|
if keys.include?(param.key)
|
25
|
-
param.errors
|
25
|
+
param.errors.add(:key, _('has already been taken'))
|
26
26
|
return true
|
27
27
|
else
|
28
28
|
keys << param.key
|
data/app/models/container.rb
CHANGED
@@ -3,7 +3,7 @@ class Container < ApplicationRecord
|
|
3
3
|
include Taxonomix
|
4
4
|
|
5
5
|
belongs_to :compute_resource
|
6
|
-
belongs_to :registry, :class_name =>
|
6
|
+
belongs_to :registry, :class_name => 'DockerRegistry', :foreign_key => :registry_id
|
7
7
|
has_many :environment_variables, :dependent => :destroy, :foreign_key => :reference_id,
|
8
8
|
:inverse_of => :container,
|
9
9
|
:class_name => 'EnvironmentVariable'
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class DockerContainerWizardState < ApplicationRecord
|
2
|
-
has_one :preliminary, :class_name => DockerContainerWizardStates::Preliminary,
|
2
|
+
has_one :preliminary, :class_name => 'DockerContainerWizardStates::Preliminary',
|
3
3
|
:dependent => :destroy, :validate => true, :autosave => true
|
4
|
-
has_one :image, :class_name => DockerContainerWizardStates::Image,
|
4
|
+
has_one :image, :class_name => 'DockerContainerWizardStates::Image',
|
5
5
|
:dependent => :destroy, :validate => true, :autosave => true
|
6
|
-
has_one :configuration, :class_name => DockerContainerWizardStates::Configuration,
|
6
|
+
has_one :configuration, :class_name => 'DockerContainerWizardStates::Configuration',
|
7
7
|
:dependent => :destroy, :validate => true, :autosave => true
|
8
|
-
has_one :environment, :class_name => DockerContainerWizardStates::Environment,
|
8
|
+
has_one :environment, :class_name => 'DockerContainerWizardStates::Environment',
|
9
9
|
:dependent => :destroy, :validate => true, :autosave => true
|
10
10
|
|
11
11
|
delegate :compute_resource_id, :to => :preliminary
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module DockerContainerWizardStates
|
2
2
|
class Configuration < ApplicationRecord
|
3
3
|
self.table_name_prefix = 'docker_container_wizard_states_'
|
4
|
-
belongs_to :wizard_state, :class_name => DockerContainerWizardState,
|
4
|
+
belongs_to :wizard_state, :class_name => 'DockerContainerWizardState',
|
5
5
|
:foreign_key => :docker_container_wizard_state_id
|
6
6
|
end
|
7
7
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module DockerContainerWizardStates
|
2
2
|
class Environment < ApplicationRecord
|
3
3
|
self.table_name_prefix = 'docker_container_wizard_states_'
|
4
|
-
belongs_to :wizard_state, :class_name => DockerContainerWizardState
|
4
|
+
belongs_to :wizard_state, :class_name => 'DockerContainerWizardState'
|
5
5
|
|
6
6
|
has_many :environment_variables, :dependent => :destroy, :foreign_key => :reference_id,
|
7
7
|
:inverse_of => :environment,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module DockerContainerWizardStates
|
2
2
|
class Image < ApplicationRecord
|
3
3
|
self.table_name_prefix = 'docker_container_wizard_states_'
|
4
|
-
belongs_to :wizard_state, :class_name => DockerContainerWizardState,
|
4
|
+
belongs_to :wizard_state, :class_name => 'DockerContainerWizardState',
|
5
5
|
:foreign_key => :docker_container_wizard_state_id
|
6
6
|
delegate :compute_resource_id, :to => :wizard_state
|
7
7
|
delegate :compute_resource, :to => :wizard_state
|
@@ -3,7 +3,7 @@ module DockerContainerWizardStates
|
|
3
3
|
include Taxonomix
|
4
4
|
|
5
5
|
self.table_name_prefix = 'docker_container_wizard_states_'
|
6
|
-
belongs_to :wizard_state, :class_name => DockerContainerWizardState,
|
6
|
+
belongs_to :wizard_state, :class_name => 'DockerContainerWizardState',
|
7
7
|
:foreign_key => :docker_container_wizard_state_id
|
8
8
|
|
9
9
|
belongs_to :compute_resource, :required => true
|
@@ -74,7 +74,7 @@ module Service
|
|
74
74
|
|
75
75
|
def destroy_wizard_state(wizard_state)
|
76
76
|
wizard_state.destroy
|
77
|
-
DockerContainerWizardState.
|
77
|
+
DockerContainerWizardState.where(["updated_at < ?", (Time.now.utc - 24.hours)]).destroy_all
|
78
78
|
end
|
79
79
|
|
80
80
|
def load_environment_variables(state, r)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class RemoveDockerSearchPermission < ActiveRecord::Migration[4.2]
|
2
|
+
def up
|
3
|
+
Permission.where(
|
4
|
+
:name => "search_repository_image_search",
|
5
|
+
:resource_type => 'Docker/ImageSearch').destroy_all
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
Permission.where(
|
10
|
+
:name => "search_repository_image_search",
|
11
|
+
:resource_type => 'DockerRegistry').destroy_all
|
12
|
+
end
|
13
|
+
end
|
@@ -102,7 +102,7 @@ module ForemanDocker
|
|
102
102
|
{ :image_search => [:auto_complete_repository_name,
|
103
103
|
:auto_complete_image_tag,
|
104
104
|
:search_repository] },
|
105
|
-
:resource_type => '
|
105
|
+
:resource_type => 'DockerRegistry'
|
106
106
|
end
|
107
107
|
|
108
108
|
add_all_permissions_to_default_roles
|
@@ -40,10 +40,10 @@ class ContainersControllerTest < ActionController::TestCase
|
|
40
40
|
test 'failed deletion of unmanaged container in Docker' do
|
41
41
|
ComputeResource.any_instance.stubs(:destroy_vm).
|
42
42
|
raises(::Foreman::Exception.new('Could not destroy Docker container'))
|
43
|
-
@request.env['HTTP_REFERER'] = "http://test.host
|
43
|
+
@request.env['HTTP_REFERER'] = "http://test.host#{containers_path}"
|
44
44
|
delete :destroy, params: { :compute_resource_id => @container_resource, :id => @container.id }, session: set_session_user
|
45
45
|
assert @container.present?
|
46
|
-
assert_redirected_to
|
46
|
+
assert_redirected_to containers_path
|
47
47
|
assert_equal 'Your container could not be deleted in Docker',
|
48
48
|
flash[:error]
|
49
49
|
end
|
@@ -12,12 +12,13 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
12
12
|
|
13
13
|
setup do
|
14
14
|
Service::RegistryApi.stubs(:docker_hub).returns(docker_hub)
|
15
|
-
ComputeResource
|
15
|
+
ComputeResource.const_get(:ActiveRecord_Relation).any_instance
|
16
16
|
.stubs(:find).returns(compute_resource)
|
17
|
-
DockerRegistry
|
17
|
+
DockerRegistry.const_get(:ActiveRecord_Relation).any_instance
|
18
18
|
.stubs(:find).returns(registry)
|
19
19
|
end
|
20
20
|
|
21
|
+
# rubocop:disable Metrics/BlockLength
|
21
22
|
describe '#search_repository' do
|
22
23
|
let(:search_types) { ['hub', 'registry'] }
|
23
24
|
|
@@ -30,17 +31,22 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
30
31
|
tags_enabled = ['true', 'false'].sample
|
31
32
|
image_search_service.expects(:search).with({ term: term, tags: tags_enabled })
|
32
33
|
.returns([])
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
get :search_repository,
|
35
|
+
params: { registry: search_types.sample, search: term, tags: tags_enabled,
|
36
|
+
id: compute_resource },
|
37
|
+
session: set_session_user,
|
38
|
+
xhr: true
|
36
39
|
end
|
37
40
|
|
38
41
|
test 'returns an array of { label:, value: } hashes' do
|
39
42
|
image_search_service.expects(:search).with({ term: term, tags: 'true' })
|
40
43
|
.returns(tags)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
+
get :search_repository,
|
45
|
+
params: { registry: search_types.sample, search: term, tags: 'true',
|
46
|
+
id: compute_resource },
|
47
|
+
session: set_session_user,
|
48
|
+
xhr: true
|
49
|
+
|
44
50
|
assert_equal tags.first, JSON.parse(response.body).first['value']
|
45
51
|
end
|
46
52
|
|
@@ -48,9 +54,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
48
54
|
image_search_service.expects(:search)
|
49
55
|
.with({ term: term, tags: 'false' })
|
50
56
|
.returns([{ 'name' => term }])
|
51
|
-
|
57
|
+
get :search_repository, params:
|
52
58
|
{ registry: search_types.sample, search: term,
|
53
|
-
id: compute_resource, format: :html},
|
59
|
+
id: compute_resource, format: :html },
|
60
|
+
session: set_session_user, xhr: true
|
61
|
+
|
54
62
|
assert response.body.include?(term)
|
55
63
|
end
|
56
64
|
|
@@ -58,8 +66,9 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
58
66
|
test "search_repository catch exceptions on network errors like #{error}" do
|
59
67
|
image_search_service.expects(:search)
|
60
68
|
.raises(error)
|
61
|
-
|
62
|
-
|
69
|
+
get :search_repository,
|
70
|
+
params: { registry: search_types.sample, search: term, id: compute_resource },
|
71
|
+
session: set_session_user, xhr: true
|
63
72
|
|
64
73
|
assert_response :error
|
65
74
|
assert response.body.include?('An error occured during repository search:')
|
@@ -76,8 +85,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
76
85
|
"star_count" => 0
|
77
86
|
}]
|
78
87
|
image_search_service.expects(:search).returns(expected)
|
79
|
-
|
80
|
-
|
88
|
+
get :search_repository,
|
89
|
+
params: { registry: search_types.sample, search: 'centos', id: compute_resource, format: :html },
|
90
|
+
session: set_session_user,
|
91
|
+
xhr: true
|
92
|
+
|
81
93
|
assert_response :success
|
82
94
|
refute response.body.include?(repo_full_name)
|
83
95
|
assert response.body.include?(repository)
|
@@ -94,8 +106,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
94
106
|
"star_count" => 0
|
95
107
|
}]
|
96
108
|
image_search_service.expects(:search).returns(expected)
|
97
|
-
|
98
|
-
|
109
|
+
get :search_repository,
|
110
|
+
params: { registry: search_types.sample, search: term, id: compute_resource, format: :html },
|
111
|
+
session: set_session_user,
|
112
|
+
xhr: true
|
113
|
+
|
99
114
|
assert_response :success
|
100
115
|
assert response.body.include?(repo_full_name)
|
101
116
|
assert response.body.include?(repository)
|
@@ -111,9 +126,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
111
126
|
.returns([OpenStruct.new(info: { 'RepoTags' => [term] })])
|
112
127
|
docker_hub.expects(:search).returns({})
|
113
128
|
|
114
|
-
|
115
|
-
|
116
|
-
|
129
|
+
get :search_repository,
|
130
|
+
params: { registry: search_type, search: term,
|
131
|
+
id: compute_resource },
|
132
|
+
session: set_session_user,
|
133
|
+
xhr: true
|
117
134
|
end
|
118
135
|
end
|
119
136
|
|
@@ -126,9 +143,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
126
143
|
registry.api.expects(:search).with(docker_image)
|
127
144
|
.returns({})
|
128
145
|
|
129
|
-
|
130
|
-
|
131
|
-
search: term, id: compute_resource },
|
146
|
+
get :search_repository,
|
147
|
+
params: { registry: search_type, registry_id: registry,
|
148
|
+
search: term, id: compute_resource },
|
149
|
+
session: set_session_user,
|
150
|
+
xhr: true
|
132
151
|
end
|
133
152
|
end
|
134
153
|
end
|
@@ -147,9 +166,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
147
166
|
.returns(tags)
|
148
167
|
docker_hub.expects(:tags).returns([])
|
149
168
|
|
150
|
-
|
151
|
-
|
152
|
-
|
169
|
+
get :search_repository,
|
170
|
+
params: { registry: search_type, search: term,
|
171
|
+
tags: 'true', id: compute_resource },
|
172
|
+
session: set_session_user,
|
173
|
+
xhr: true
|
153
174
|
end
|
154
175
|
end
|
155
176
|
|
@@ -162,9 +183,11 @@ class ImageSearchControllerTest < ActionController::TestCase
|
|
162
183
|
registry.api.expects(:tags).with(docker_image, tag_fragment)
|
163
184
|
.returns([])
|
164
185
|
|
165
|
-
|
166
|
-
|
167
|
-
|
186
|
+
get :search_repository,
|
187
|
+
params: { registry: search_type, registry_id: registry, tags: 'true',
|
188
|
+
search: term, id: compute_resource },
|
189
|
+
session: set_session_user,
|
190
|
+
xhr: true
|
168
191
|
end
|
169
192
|
end
|
170
193
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_docker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lobato, Amos Benari
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docker-api
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- db/migrate/20160605133025_create_docker_parameters.rb
|
192
192
|
- db/migrate/20160605134652_move_parameters_to_docker_parameters.rb
|
193
193
|
- db/migrate/20170508130316_add_verify_ssl_option_to_docker_registries.rb
|
194
|
+
- db/migrate/20180105090316_remove_docker_search_permission.rb
|
194
195
|
- lib/foreman_docker.rb
|
195
196
|
- lib/foreman_docker/engine.rb
|
196
197
|
- lib/foreman_docker/version.rb
|
@@ -270,9 +271,9 @@ test_files:
|
|
270
271
|
- test/factories/docker_registry.rb
|
271
272
|
- test/functionals/api/v2/containers_controller_test.rb
|
272
273
|
- test/functionals/api/v2/registries_controller_test.rb
|
273
|
-
- test/functionals/image_search_controller_test.rb
|
274
|
-
- test/functionals/containers_controller_test.rb
|
275
274
|
- test/functionals/containers_steps_controller_test.rb
|
275
|
+
- test/functionals/containers_controller_test.rb
|
276
|
+
- test/functionals/image_search_controller_test.rb
|
276
277
|
- test/integration/container_test.rb
|
277
278
|
- test/integration/container_steps_test.rb
|
278
279
|
- test/integration/registry_creation_test.rb
|