foreman_docker 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 641634385303418110c23b2516bc9eeabdf5851a
4
- data.tar.gz: ba787b7bda686cb0b8f117387928656b97f1dd1a
3
+ metadata.gz: 04dedd7aef67d8c8ef5299bd13fba4bd06477b48
4
+ data.tar.gz: 3f6d66e39d798470d169d00a4455b7701b44c92f
5
5
  SHA512:
6
- metadata.gz: 5f44dbbc9ce8d205725004ed20ca8752610a012f86c8e1940cf31337a66fa6c3d3991cf461201b9aee84693f0d11acd690525d9b56909543397ba9cfc9a67274
7
- data.tar.gz: 244b131747e87fa896fbcb103c82b676754e3f985f6ee78b83f14888a42966145cf24a69570453e8f8f91b1ebd72b87459194c212a3f376e9efa10d2938c5c96
6
+ metadata.gz: 2375f44e73e5a5bfc0a7e0cc213295fb6be2e831a8759deb73a846f5ebe565880ce6519d83d2827c4b758deadd1413977bb25d22a6a1b612bcf7d5a66b5f7698
7
+ data.tar.gz: f5626d2ad14734c0337b304c5b85555e88d7116a9883127f570e49c98c5a54b0aa887153afad9237f984da1fe09852a8086f0cb9d21c4288aa1a7d3b951e5a81
@@ -50,6 +50,9 @@ function autoCompleteRepo(item) {
50
50
  search_add_on.addClass('glyphicon-remove');
51
51
  tag.autocomplete('option', 'source', []);
52
52
  }
53
+ },
54
+ error: function(result) {
55
+ $.jnotify(result.responseText, "error", true);
53
56
  }
54
57
  });
55
58
  }
@@ -67,6 +70,9 @@ function setAutocompleteTags(registryType) {
67
70
  source.push({label: value.label, value: value.value});
68
71
  });
69
72
  tag.focus();
73
+ })
74
+ .error(function(result) {
75
+ $.jnotify(result.responseText, "error", true);
70
76
  });
71
77
  tag.autocomplete('option', 'source', source);
72
78
  }
@@ -87,6 +93,9 @@ function searchRepo(item) {
87
93
  success: function (result) {
88
94
  results.html(result);
89
95
  },
96
+ error: function(result) {
97
+ $.jnotify(result.responseText, "error", true);
98
+ },
90
99
  complete: function (result) {
91
100
  searching_spinner.hide();
92
101
  }
@@ -2,34 +2,51 @@ class ImageSearchController < ::ApplicationController
2
2
  before_filter :find_resource
3
3
 
4
4
  def auto_complete_repository_name
5
- render :text => (use_hub? ? hub_image_exists?(params[:search]) :
6
- registry_image_exists?(params[:search])).to_s
5
+ catch_network_errors do
6
+ render :text => (use_hub? ? hub_image_exists?(params[:search]) :
7
+ registry_image_exists?(params[:search])).to_s
8
+ end
7
9
  end
8
10
 
9
11
  def auto_complete_image_tag
10
- # This is the format jQuery UI autocomplete expects
11
- tags = use_hub? ? hub_auto_complete_image_tags(params[:search]) :
12
- registry_auto_complete_image_tags(params[:search])
13
- respond_to do |format|
14
- format.js do
15
- tags.map! { |tag| { :label => CGI.escapeHTML(tag), :value => CGI.escapeHTML(tag) } }
16
- render :json => tags
12
+ catch_network_errors do
13
+ # This is the format jQuery UI autocomplete expects
14
+ tags = use_hub? ? hub_auto_complete_image_tags(params[:search]) :
15
+ registry_auto_complete_image_tags(params[:search])
16
+ respond_to do |format|
17
+ format.js do
18
+ tags.map! { |tag| { :label => CGI.escapeHTML(tag), :value => CGI.escapeHTML(tag) } }
19
+ render :json => tags
20
+ end
17
21
  end
18
22
  end
19
23
  end
20
24
 
21
25
  def search_repository
22
- repositories = use_hub? ? hub_search_image(params[:search]) :
23
- registry_search_image(params[:search])
24
- respond_to do |format|
25
- format.js do
26
- render :partial => 'repository_search_results',
27
- :locals => { :repositories => repositories,
28
- :use_hub => use_hub? }
26
+ catch_network_errors do
27
+ repositories = use_hub? ? hub_search_image(params[:search]) :
28
+ registry_search_image(params[:search])
29
+ respond_to do |format|
30
+ format.js do
31
+ render :partial => 'repository_search_results',
32
+ :locals => { :repositories => repositories,
33
+ :use_hub => use_hub? }
34
+ end
29
35
  end
30
36
  end
31
37
  end
32
38
 
39
+ def catch_network_errors
40
+ yield
41
+ rescue Docker::Error::NotFoundError => e
42
+ # not an error
43
+ logger.debug "image not found: #{e.backtrace}"
44
+ render :js, :nothing => true
45
+ rescue Docker::Error::DockerError, Excon::Errors::Error, SystemCallError => e
46
+ render :js => _("An error occured during repository search: '%s'") % e.message,
47
+ :status => 500
48
+ end
49
+
33
50
  def use_hub?
34
51
  @registry.nil?
35
52
  end
@@ -89,7 +89,7 @@ module ForemanDocker
89
89
  # apipie API documentation
90
90
  # Only available in 1.8, otherwise it has to be in the initializer below
91
91
  if SETTINGS[:version].to_s.include?('develop') ||
92
- Gem::Version.new(SETTINGS[:version]) >= Gem::Version.new('1.8')
92
+ Gem::Version.new(SETTINGS[:version].notag) >= Gem::Version.new('1.8')
93
93
  apipie_documented_controllers [
94
94
  "#{ForemanDocker::Engine.root}/app/controllers/api/v2/*.rb"]
95
95
  end
@@ -100,7 +100,7 @@ module ForemanDocker
100
100
  # this condition is here for compatibility reason to work with Foreman 1.4.x
101
101
  # Also need to handle the reverse of the 1.8 method above
102
102
  unless SETTINGS[:version].to_s.include?('develop') ||
103
- Gem::Version.new(SETTINGS[:version]) >= Gem::Version.new('1.8')
103
+ Gem::Version.new(SETTINGS[:version].notag) >= Gem::Version.new('1.8')
104
104
  if Apipie.configuration.api_controllers_matcher.is_a?(Array)
105
105
  Apipie.configuration.api_controllers_matcher <<
106
106
  "#{ForemanDocker::Engine.root}/app/controllers/api/v2/*.rb"
@@ -1,3 +1,3 @@
1
1
  module ForemanDocker
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
@@ -0,0 +1,33 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ImageSearchControllerTest < ActionController::TestCase
4
+ setup do
5
+ @container = FactoryGirl.create(:docker_cr)
6
+ end
7
+
8
+ [Docker::Error::DockerError, Excon::Errors::Error, Errno::ECONNREFUSED].each do |error|
9
+ test 'auto_complete_repository_name catches exceptions on network errors' do
10
+ ForemanDocker::Docker.any_instance.expects(:exist?).raises(error)
11
+ get :auto_complete_repository_name, { :search => "test", :id => @container.id },
12
+ set_session_user
13
+ assert_response_is_expected
14
+ end
15
+
16
+ test 'auto_complete_image_tag catch exceptions on network errors' do
17
+ ForemanDocker::Docker.any_instance.expects(:tags).raises(error)
18
+ get :auto_complete_image_tag, { :search => "test", :id => @container.id }, set_session_user
19
+ assert_response_is_expected
20
+ end
21
+
22
+ test 'search_repository catch exceptions on network errors' do
23
+ ForemanDocker::Docker.any_instance.expects(:search).raises(error)
24
+ get :search_repository, { :search => "test", :id => @container.id }, set_session_user
25
+ assert_response_is_expected
26
+ end
27
+ end
28
+
29
+ def assert_response_is_expected
30
+ assert_response :error
31
+ assert response.body.include?('An error occured during repository search:')
32
+ end
33
+ 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.1
4
+ version: 1.2.2
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-03 00:00:00.000000000 Z
11
+ date: 2015-03-11 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.
@@ -45,99 +45,100 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - LICENSE
49
- - README.md
50
- - Rakefile
51
- - app/assets/javascripts/foreman_docker/image_step.js
52
- - app/assets/stylesheets/foreman_docker/autocomplete.css.scss
53
- - app/assets/stylesheets/foreman_docker/terminal.css.scss
54
- - app/controllers/api/v2/containers_controller.rb
55
- - app/controllers/concerns/foreman_docker/find_container.rb
56
- - app/controllers/containers/steps_controller.rb
57
- - app/controllers/containers_controller.rb
58
- - app/controllers/image_search_controller.rb
59
- - app/controllers/registries_controller.rb
60
- - app/helpers/container_steps_helper.rb
61
- - app/helpers/containers_helper.rb
62
- - app/models/concerns/fog_extensions/fogdocker/image.rb
63
- - app/models/concerns/fog_extensions/fogdocker/images.rb
64
- - app/models/concerns/fog_extensions/fogdocker/server.rb
65
- - app/models/concerns/foreman_docker/parameter_validators.rb
66
- - app/models/container.rb
67
- - app/models/docker_container_wizard_state.rb
68
- - app/models/docker_container_wizard_states/configuration.rb
69
- - app/models/docker_container_wizard_states/environment.rb
70
- - app/models/docker_container_wizard_states/environment_variable.rb
71
- - app/models/docker_container_wizard_states/image.rb
72
- - app/models/docker_container_wizard_states/preliminary.rb
73
- - app/models/docker_registry.rb
74
- - app/models/environment_variable.rb
75
- - app/models/foreman_docker/docker.rb
76
- - app/models/foreman_docker/taxonomy_extensions.rb
77
- - app/models/service/containers.rb
78
- - app/models/service/registry_api.rb
79
- - app/views/api/v1/compute_resources/docker.json
48
+ - app/views/compute_resources/form/_docker.html.erb
49
+ - app/views/compute_resources/show/_docker.html.erb
50
+ - app/views/image_search/_repository_search_results.html.erb
80
51
  - app/views/api/v2/compute_resources/docker.json
52
+ - app/views/api/v2/containers/main.json.rabl
81
53
  - app/views/api/v2/containers/base.json.rabl
82
54
  - app/views/api/v2/containers/index.json.rabl
83
- - app/views/api/v2/containers/main.json.rabl
84
55
  - app/views/api/v2/containers/show.json.rabl
85
- - app/views/compute_resources/form/_docker.html.erb
86
- - app/views/compute_resources/show/_docker.html.erb
87
- - app/views/compute_resources_vms/form/_docker.html.erb
88
- - app/views/compute_resources_vms/index/_docker.html.erb
89
- - app/views/compute_resources_vms/show/_docker.html.erb
90
- - app/views/containers/_list.html.erb
91
- - app/views/containers/index.html.erb
92
- - app/views/containers/show.html.erb
93
- - app/views/containers/steps/_form_buttons.html.erb
94
- - app/views/containers/steps/_image_hub_tab.html.erb
95
- - app/views/containers/steps/_title.html.erb
96
- - app/views/containers/steps/configuration.html.erb
56
+ - app/views/api/v1/compute_resources/docker.json
97
57
  - app/views/containers/steps/environment.html.erb
58
+ - app/views/containers/steps/_title.html.erb
59
+ - app/views/containers/steps/_form_buttons.html.erb
98
60
  - app/views/containers/steps/image.html.erb
99
61
  - app/views/containers/steps/preliminary.html.erb
100
- - app/views/foreman_docker/common_parameters/_environment_variable.html.erb
101
- - app/views/image_search/_repository_search_results.html.erb
102
- - app/views/images/form/_docker.html.erb
103
- - app/views/registries/_form.html.erb
62
+ - app/views/containers/steps/_image_hub_tab.html.erb
63
+ - app/views/containers/steps/configuration.html.erb
64
+ - app/views/containers/_list.html.erb
65
+ - app/views/containers/show.html.erb
66
+ - app/views/containers/index.html.erb
104
67
  - app/views/registries/edit.html.erb
105
- - app/views/registries/index.html.erb
106
68
  - app/views/registries/new.html.erb
69
+ - app/views/registries/_form.html.erb
70
+ - app/views/registries/index.html.erb
71
+ - app/views/foreman_docker/common_parameters/_environment_variable.html.erb
72
+ - app/views/images/form/_docker.html.erb
73
+ - app/views/compute_resources_vms/form/_docker.html.erb
74
+ - app/views/compute_resources_vms/index/_docker.html.erb
75
+ - app/views/compute_resources_vms/show/_docker.html.erb
76
+ - app/models/docker_registry.rb
77
+ - app/models/service/registry_api.rb
78
+ - app/models/service/containers.rb
79
+ - app/models/concerns/fog_extensions/fogdocker/image.rb
80
+ - app/models/concerns/fog_extensions/fogdocker/images.rb
81
+ - app/models/concerns/fog_extensions/fogdocker/server.rb
82
+ - app/models/concerns/foreman_docker/parameter_validators.rb
83
+ - app/models/docker_container_wizard_state.rb
84
+ - app/models/container.rb
85
+ - app/models/environment_variable.rb
86
+ - app/models/foreman_docker/taxonomy_extensions.rb
87
+ - app/models/foreman_docker/docker.rb
88
+ - app/models/docker_container_wizard_states/environment.rb
89
+ - app/models/docker_container_wizard_states/image.rb
90
+ - app/models/docker_container_wizard_states/configuration.rb
91
+ - app/models/docker_container_wizard_states/environment_variable.rb
92
+ - app/models/docker_container_wizard_states/preliminary.rb
93
+ - app/controllers/api/v2/containers_controller.rb
94
+ - app/controllers/containers/steps_controller.rb
95
+ - app/controllers/concerns/foreman_docker/find_container.rb
96
+ - app/controllers/registries_controller.rb
97
+ - app/controllers/image_search_controller.rb
98
+ - app/controllers/containers_controller.rb
99
+ - app/helpers/containers_helper.rb
100
+ - app/helpers/container_steps_helper.rb
101
+ - app/assets/javascripts/foreman_docker/image_step.js
102
+ - app/assets/stylesheets/foreman_docker/terminal.css.scss
103
+ - app/assets/stylesheets/foreman_docker/autocomplete.css.scss
107
104
  - config/routes.rb
108
- - db/migrate/20140930175337_add_email_to_compute_resource.rb
105
+ - db/migrate/20141018110810_add_uuid_to_containers.rb
106
+ - db/migrate/20141028164206_change_memory_in_container.rb
109
107
  - db/migrate/20141005233312_create_containers.rb
108
+ - db/migrate/20141028164633_change_cpuset_in_container.rb
109
+ - db/migrate/20141009011026_add_attributes_to_container.rb
110
+ - db/migrate/20141222113313_create_wizard_states.rb
111
+ - db/migrate/20150129054944_add_katello_flag_to_containers.rb
110
112
  - db/migrate/20141007225130_add_compute_resource_id_to_container.rb
111
113
  - db/migrate/20141009001613_add_tag_to_container.rb
112
- - db/migrate/20141009011026_add_attributes_to_container.rb
114
+ - db/migrate/20141120123003_add_user_credentials_to_docker_registries.rb
115
+ - db/migrate/20140930175337_add_email_to_compute_resource.rb
113
116
  - db/migrate/20141010173220_create_docker_images.rb
114
- - db/migrate/20141018110810_add_uuid_to_containers.rb
117
+ - db/migrate/20150122011747_add_katello_flag_to_docker_wizard_image.rb
115
118
  - db/migrate/20141024163003_create_docker_registries.rb
116
- - db/migrate/20141028164206_change_memory_in_container.rb
117
- - db/migrate/20141028164633_change_cpuset_in_container.rb
118
- - db/migrate/20141120123003_add_user_credentials_to_docker_registries.rb
119
119
  - db/migrate/20141209182008_remove_docker_tables.rb
120
- - db/migrate/20141222113313_create_wizard_states.rb
121
- - db/migrate/20150122011747_add_katello_flag_to_docker_wizard_image.rb
122
- - db/migrate/20150129054944_add_katello_flag_to_containers.rb
123
- - lib/foreman_docker.rb
124
- - lib/foreman_docker/engine.rb
125
120
  - lib/foreman_docker/tasks/test.rake
126
121
  - lib/foreman_docker/version.rb
122
+ - lib/foreman_docker/engine.rb
123
+ - lib/foreman_docker.rb
127
124
  - locale/Makefile
128
- - test/factories/compute_resources.rb
129
- - test/factories/containers.rb
130
- - test/factories/docker_registry.rb
125
+ - LICENSE
126
+ - Rakefile
127
+ - README.md
131
128
  - test/functionals/api/v2/containers_controller_test.rb
132
- - test/functionals/container_controller_test.rb
133
129
  - test/functionals/containers_steps_controller_test.rb
134
- - test/integration/container_steps_test.rb
135
- - test/integration/container_test.rb
136
- - test/test_plugin_helper.rb
130
+ - test/functionals/image_search_controller_test.rb
131
+ - test/functionals/container_controller_test.rb
132
+ - test/factories/docker_registry.rb
133
+ - test/factories/compute_resources.rb
134
+ - test/factories/containers.rb
137
135
  - test/units/container_test.rb
138
- - test/units/containers_service_test.rb
139
136
  - test/units/docker_registry_test.rb
140
137
  - test/units/registry_api_test.rb
138
+ - test/units/containers_service_test.rb
139
+ - test/test_plugin_helper.rb
140
+ - test/integration/container_steps_test.rb
141
+ - test/integration/container_test.rb
141
142
  homepage: http://github.com/theforeman/foreman-docker
142
143
  licenses:
143
144
  - GPL-3
@@ -148,23 +149,24 @@ require_paths:
148
149
  - lib
149
150
  required_ruby_version: !ruby/object:Gem::Requirement
150
151
  requirements:
151
- - - ">="
152
+ - - '>='
152
153
  - !ruby/object:Gem::Version
153
154
  version: '0'
154
155
  required_rubygems_version: !ruby/object:Gem::Requirement
155
156
  requirements:
156
- - - ">="
157
+ - - '>='
157
158
  - !ruby/object:Gem::Version
158
159
  version: '0'
159
160
  requirements: []
160
161
  rubyforge_project:
161
- rubygems_version: 2.4.5
162
+ rubygems_version: 2.0.14
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: Provision and manage Docker containers and images from Foreman
165
166
  test_files:
166
167
  - test/functionals/api/v2/containers_controller_test.rb
167
168
  - test/functionals/containers_steps_controller_test.rb
169
+ - test/functionals/image_search_controller_test.rb
168
170
  - test/functionals/container_controller_test.rb
169
171
  - test/factories/docker_registry.rb
170
172
  - test/factories/compute_resources.rb