foreman_docker 1.2.3 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 312b5ebf35209421ab37d4f6ce21b42f5c8a4f4c
4
- data.tar.gz: a62f11d57a4d7eaadade21338983bf135883b7e8
3
+ metadata.gz: 535366638d0c74fc0d0902bf69a124ef157d4baf
4
+ data.tar.gz: f4f6b1a8d0d816e58b2123ab7c93a44867b6172a
5
5
  SHA512:
6
- metadata.gz: 5bbd89c9d4efe80997326ebc6fb46487144e443628de9dfeca2ee8e319bbd0cadee4c79ac9bf75d97eda83ccebb3f3457bc1301955610d11e4573d198581e438
7
- data.tar.gz: 9a93d2c256eec38df60fa1d4d3c83c94f99641cef7f3960978f6c2da2ab4edc215c7ab3aa0098a4b7358cfd958d29e8ce02c1f80750e6fa81353d5b153d21df5
6
+ metadata.gz: 2d3ff95541102881f8a73b04d185a2715caf0f28e30d8e5cb2bfa592fa6916abfecb8b58184d70a286ca70d663713bafeb5c4737415d5acab79745bf507bfb29
7
+ data.tar.gz: d3f63fa79b9b614a44f6f44f45910b6a3ece99aa47524265984991f135b10075162fb2dec22c58ca47270d80ccd3cc397dbc39b4f487eeb9eb92f4525b7dd246
@@ -14,14 +14,16 @@ module Api
14
14
  api :GET, '/compute_resources/:compute_resource_id/containers/',
15
15
  N_('List all containers in a compute resource')
16
16
  param :compute_resource_id, :identifier
17
- param_group :pagination, ::Api::V2::BaseController
17
+ param_group :search_and_pagination, ::Api::V2::BaseController
18
18
 
19
19
  def index
20
20
  if params[:compute_resource_id].present?
21
- @containers = Container.where(:compute_resource_id => params[:compute_resource_id])
21
+ scoped = Container.where(:compute_resource_id => params[:compute_resource_id])
22
22
  else
23
- @containers = Container.all
23
+ scoped = Container.scoped
24
24
  end
25
+ @containers = scoped.search_for(params[:search], :order => params[:order])
26
+ .paginate(:page => params[:page])
25
27
  end
26
28
 
27
29
  api :GET, '/containers/:id/', N_('Show a container')
@@ -38,13 +40,16 @@ module Api
38
40
  param :name, String, :required => true
39
41
  param_group :taxonomies, ::Api::V2::BaseController
40
42
  param :compute_resource_id, :identifier, :required => true
41
- param :registry_id, :identifier, :desc => N_('Registry this container will have to use
42
- to get the image')
43
- param :image, String, :desc => N_('Image to use to create the container.
44
- Format should be repository:tag, e.g: centos:7')
43
+ param :registry_id, :identifier, :desc => N_('Registry this container will have to
44
+ use to get the image')
45
+ param :repository_name, String, :required => true,
46
+ :desc => N_('Name of the repository to use
47
+ to create the container. e.g: centos')
48
+ param :tag, String, :required => true,
49
+ :desc => N_('Tag to use to create the container. e.g: latest')
45
50
  param :tty, :bool
46
51
  param :entrypoint, String
47
- param :cmd, String
52
+ param :command, String, :required => true
48
53
  param :memory, String
49
54
  param :cpu_shares, :number
50
55
  param :cpu_sets, String
@@ -52,7 +57,9 @@ module Api
52
57
  param :attach_stdout, :bool
53
58
  param :attach_stdin, :bool
54
59
  param :attach_stderr, :bool
55
- param :katello, :bool
60
+ param :capsule_id, :identifier, :desc => N_('The capsule this container will have to use
61
+ to get the image. Relevant for images
62
+ retrieved from katello registry.')
56
63
  end
57
64
  end
58
65
 
@@ -123,14 +130,20 @@ module Api
123
130
 
124
131
  private
125
132
 
126
- def set_wizard_state
127
- wizard_properties = { :preliminary => [:compute_resource_id],
128
- :image => [:registry_id, :repository_name, :tag, :katello],
129
- :configuration => [:name, :command, :entrypoint, :cpu_set,
130
- :cpu_shares, :memory],
131
- :environment => [:tty, :attach_stdin, :attach_stdout,
132
- :attach_stderr] }
133
+ def wizard_properties
134
+ wizard_props = { :preliminary => [:compute_resource_id],
135
+ :image => [:registry_id, :repository_name, :tag],
136
+ :configuration => [:name, :command, :entrypoint, :cpu_set,
137
+ :cpu_shares, :memory],
138
+ :environment => [:tty, :attach_stdin, :attach_stdout,
139
+ :attach_stderr] }
140
+ if DockerContainerWizardStates::Image.attribute_names.include?("capsule_id")
141
+ wizard_props[:image] << :capsule_id
142
+ end
143
+ wizard_props
144
+ end
133
145
 
146
+ def set_wizard_state
134
147
  wizard_state = DockerContainerWizardState.create
135
148
  wizard_properties.each do |step, properties|
136
149
  property_values = properties.each_with_object({}) do |property, values|
@@ -11,6 +11,8 @@ class Container < ActiveRecord::Base
11
11
  accepts_nested_attributes_for :environment_variables, :allow_destroy => true
12
12
  include ForemanDocker::ParameterValidators
13
13
 
14
+ scoped_search :on => :name
15
+
14
16
  attr_accessible :command, :repository_name, :name, :compute_resource_id, :entrypoint,
15
17
  :cpu_set, :cpu_shares, :memory, :tty, :attach_stdin, :registry_id,
16
18
  :attach_stdout, :attach_stderr, :tag, :uuid, :environment_variables_attributes,
@@ -15,7 +15,6 @@ class DockerContainerWizardState < ActiveRecord::Base
15
15
  { :repository_name => image.repository_name,
16
16
  :tag => image.tag,
17
17
  :registry_id => image.registry_id,
18
- :katello => image.katello?,
19
18
  :name => configuration.name,
20
19
  :compute_resource_id => preliminary.compute_resource_id,
21
20
  :tty => environment.tty,
@@ -0,0 +1,9 @@
1
+ class RemoveKatelloFlagFromContainers < ActiveRecord::Migration
2
+ def up
3
+ remove_column :containers, :katello
4
+ end
5
+
6
+ def down
7
+ add_column :containers, :katello, :boolean
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ForemanDocker
2
- VERSION = '1.2.3'
2
+ VERSION = '1.2.4'
3
3
  end
@@ -9,9 +9,20 @@ module Api
9
9
  assert_template 'index'
10
10
  end
11
11
 
12
+ test 'index can be filtered by name' do
13
+ %w(thomas clayton wolfe).each do |name|
14
+ FactoryGirl.create(:container, :name => name)
15
+ end
16
+ get :index, { :search => 'name = thomas' }, set_session_user
17
+ assert_response :success
18
+ assert_equal 1, assigns(:containers).length
19
+ end
20
+
12
21
  context 'container operations' do
13
22
  setup do
14
23
  @container = FactoryGirl.create(:container, :name => 'foo')
24
+ @registry = FactoryGirl.create(:docker_registry)
25
+ @compute_resource = FactoryGirl.create(:docker_cr)
15
26
  end
16
27
 
17
28
  test 'logs returns latest lines of container log' do
@@ -59,9 +70,53 @@ module Api
59
70
  end
60
71
 
61
72
  test 'creates a container with correct params' do
73
+ repository_name = "centos"
74
+ tag = "7"
75
+ name = "foo"
76
+ registry_uri = URI.parse(@registry.url)
62
77
  Service::Containers.any_instance.expects(:pull_image).returns(true)
63
- Service::Containers.any_instance.expects(:start_container).returns(true)
64
- post :create, :container => { :name => 'foo', :registry_id => 3, :image => 'centos:7' }
78
+ Service::Containers.any_instance
79
+ .expects(:start_container).returns(true).with do |container|
80
+ container.must_be_kind_of(Container)
81
+ container.repository_name.must_equal(repository_name)
82
+ container.tag.must_equal(tag)
83
+ container.compute_resource_id.must_equal(@compute_resource.id)
84
+ container.name.must_equal(name)
85
+ container.repository_pull_url.must_include(registry_uri.host)
86
+ container.repository_pull_url.must_include("#{repository_name}:#{tag}")
87
+ end
88
+ post :create, :container => { :compute_resource_id => @compute_resource.id,
89
+ :name => name,
90
+ :registry_id => @registry.id,
91
+ :repository_name => repository_name,
92
+ :tag => tag }
93
+ assert_response :created
94
+ end
95
+
96
+ test 'creates a katello container with correct params' do
97
+ DockerContainerWizardStates::Image.class_eval do
98
+ attr_accessor :capsule_id
99
+ end
100
+ DockerContainerWizardStates::Image.attribute_names.stubs(:include?).returns(true)
101
+ repository_name = "katello_centos"
102
+ tag = "7"
103
+ name = "foo"
104
+ capsule_id = "10000"
105
+ Service::Containers.any_instance.expects(:start_container!)
106
+ .returns(@container).with do |wizard_state|
107
+ wizard_state.must_be_kind_of(DockerContainerWizardState)
108
+ container_attributes = wizard_state.container_attributes
109
+ container_attributes[:repository_name].must_equal(repository_name)
110
+ container_attributes[:tag].must_equal(tag)
111
+ container_attributes[:compute_resource_id].must_equal(@compute_resource.id)
112
+ container_attributes[:name].must_equal(name)
113
+ wizard_state.image.capsule_id.must_equal(capsule_id)
114
+ end
115
+ post :create, :container => { :compute_resource_id => @compute_resource.id,
116
+ :name => name,
117
+ :capsule_id => capsule_id,
118
+ :repository_name => repository_name,
119
+ :tag => tag }
65
120
  assert_response :created
66
121
  end
67
122
  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: 1.2.3
4
+ version: 1.2.4
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: 2015-03-19 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: wicked
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
41
  description: Provision and manage Docker containers and images from Foreman.
@@ -120,6 +120,7 @@ files:
120
120
  - db/migrate/20141222113313_create_wizard_states.rb
121
121
  - db/migrate/20150122011747_add_katello_flag_to_docker_wizard_image.rb
122
122
  - db/migrate/20150129054944_add_katello_flag_to_containers.rb
123
+ - db/migrate/20150303175646_remove_katello_flag_from_containers.rb
123
124
  - lib/foreman_docker.rb
124
125
  - lib/foreman_docker/engine.rb
125
126
  - lib/foreman_docker/tasks/test.rake
@@ -149,33 +150,32 @@ require_paths:
149
150
  - lib
150
151
  required_ruby_version: !ruby/object:Gem::Requirement
151
152
  requirements:
152
- - - '>='
153
+ - - ">="
153
154
  - !ruby/object:Gem::Version
154
155
  version: '0'
155
156
  required_rubygems_version: !ruby/object:Gem::Requirement
156
157
  requirements:
157
- - - '>='
158
+ - - ">="
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
162
  rubyforge_project:
162
- rubygems_version: 2.4.3
163
+ rubygems_version: 2.4.5
163
164
  signing_key:
164
165
  specification_version: 4
165
166
  summary: Provision and manage Docker containers and images from Foreman
166
167
  test_files:
167
- - test/factories/compute_resources.rb
168
- - test/factories/containers.rb
169
- - test/factories/docker_registry.rb
170
- - test/test_plugin_helper.rb
171
168
  - test/functionals/api/v2/containers_controller_test.rb
172
- - test/functionals/containers_controller_test.rb
173
169
  - test/functionals/containers_steps_controller_test.rb
174
170
  - test/functionals/image_search_controller_test.rb
175
- - test/integration/container_steps_test.rb
176
- - test/integration/container_test.rb
171
+ - test/functionals/containers_controller_test.rb
172
+ - test/factories/docker_registry.rb
173
+ - test/factories/compute_resources.rb
174
+ - test/factories/containers.rb
177
175
  - test/units/container_test.rb
178
- - test/units/containers_service_test.rb
179
176
  - test/units/docker_registry_test.rb
180
177
  - test/units/registry_api_test.rb
181
- has_rdoc:
178
+ - test/units/containers_service_test.rb
179
+ - test/test_plugin_helper.rb
180
+ - test/integration/container_steps_test.rb
181
+ - test/integration/container_test.rb