foreman_pipeline 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTExYjU0YWQ1ZTkxNjM2MTdhNDJkMWVmMTA4ZmQ3MjgxNTljMmUzMg==
4
+ ZmQ0YWZmODEyOGVmNmJiNGU3ZTg0OWM3OTdjNjQyMjU5ZDgwMzM2NQ==
5
5
  data.tar.gz: !binary |-
6
- NGRmYjhjOWE5MGNlODJmYmQ5ZWQ0MzY3NDkyYjJhZGQ4ZDE4NzZmMg==
6
+ ZDM5ZDRiNWRmYzU3NTBmMjk3NzRjMGY1ZjVlNjRiMjY5NzNmZWM2Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWJjZjczMDQ3NmNmOWUzZmE0YjQ5MWQ0OTNjMjQxMGYyZjlhZTAxZGIzMWJk
10
- MTNlZGNlZDZhMzYyY2U5OTczMzdiNjQxZWYwZGQ0NDY2NTA3NzJmMDk3OGQy
11
- ZmZhMWRlOTMwNTkwMzYzMmVkNDFiZDI0ZTM4Yjc4Y2FkN2RmNjU=
9
+ ODFmOWMyODM4ZGEwNjRkNDQyYTYxNTFiYWQwYjI0MjBhZTQzYjk3ZDM1ODhk
10
+ YzJlMGU3NDU4MTRiMzhiNDhlZmU5Y2Q2MDhlYjNlZWE3N2YxZjQyMjFmZDBh
11
+ NzRlZjZjZDYwNmYwMWZkMTgwZjk5N2NlMGQ3ZDM4MjNiN2U3MTI=
12
12
  data.tar.gz: !binary |-
13
- OTg0NjQyYTNlMjkxY2M4MWVjYmFiNTMyZmMxMTZmMjhjNzJhYjU1NzRiOWM0
14
- OGY1ZTZiMjFiMmFmZGFiNWU4YTAyZjAyMGY4ZTcwMzg4NGNkOGJjNjdiNDU0
15
- NWIxY2Y4ZDI2NmFhNzFlZTA2M2FkZDQ5ZjlmYjNiMGQzM2I5OWM=
13
+ YzlmYzYwYmM5OWEzMjM3ZWFiMjRlZTk4N2Y0MjQ4YWRjZDI0ZjcyOWEyNzkx
14
+ MjA2Mjk1OWNiNTk5Y2UyMmZmYzMxNjVhMTEwZjQyMjViNzNlODE3MmUzZWM1
15
+ OGI0ZmQyMGRhYzZkNWU1YjBjZGEzMzVhMjExYjM5NDg2NThlNmE=
@@ -3,10 +3,10 @@ module ForemanPipeline
3
3
  respond_to :json
4
4
 
5
5
  include Api::Rendering
6
+ include Concerns::ApiControllerExtensions
6
7
 
7
8
  before_filter :find_jenkins_instance, :only => [:show, :update, :destroy, :check_jenkins, :set_jenkins_user]
8
9
  before_filter :find_organization, :only => [:index, :create]
9
- before_filter :load_search_service, :only => [:index]
10
10
 
11
11
  def_param_group :jenkins_instance do
12
12
  param :name, String, :desc => N_("Jenkins instance's name")
@@ -24,16 +24,13 @@ module ForemanPipeline
24
24
  param :organization_id, :number, :desc => N_("organization identifier"), :required => true
25
25
  param :name, String, :desc => N_("Name of the jenkins instance")
26
26
  def index
27
- ids = JenkinsInstance.readable.where(:organization_id => @organization.id).pluck(:id)
28
- filters = [:terms => {:id => ids}]
29
- filters << {:term => {:name => params[:name]}} if params[:name]
30
-
31
- options = {
32
- :filters => filters,
33
- :load_records? => true
34
- }
27
+ respond_for_index(:collection => scoped_search(index_relation.uniq, params[:sort_by], params[:sort_order]))
28
+ end
35
29
 
36
- respond_for_index(:collection => item_search(JenkinsInstance, params, options))
30
+ def index_relation
31
+ query = JenkinsInstance.where(:organization_id => @organization.id)
32
+ query = query.where(:name => params[:name]) if params[:name]
33
+ query
37
34
  end
38
35
 
39
36
  api :POST, "/organizations/:organization_id/jenkins_instances/:id", N_("Create jenkins instance")
@@ -3,6 +3,7 @@ module ForemanPipeline
3
3
  respond_to :json
4
4
 
5
5
  include Api::Rendering
6
+ include Concerns::ApiControllerExtensions
6
7
 
7
8
  before_filter :find_organization, :only => [:create, :index]
8
9
  before_filter :find_jenkins_user, :only => [:show, :destroy, :update]
@@ -21,17 +22,13 @@ module ForemanPipeline
21
22
  param :organization_id, :number, :desc => N_("organization identifier"), :required => true
22
23
  param :name, String, :desc => N_("Name of the jenkins instance")
23
24
  def index
24
- ids = JenkinsUser.readable
25
- .where(:organization_id => @organization.id)
26
- .pluck(:id)
27
- filters = [:terms => {:id => ids}]
28
- filters << {:term => {:name => params[:name]}} if params[:name]
29
-
30
- options = {
31
- :filters => filters,
32
- :load_records? => true
33
- }
34
- respond_for_index(:collection => item_search(JenkinsUser, params, options))
25
+ respond_for_index(:collection => scoped_search(index_relation.uniq, params[:sort_by], params[:sort_order]))
26
+ end
27
+
28
+ def index_relation
29
+ query = JenkinsUser.where(:organization_id => @organization.id)
30
+ query = query.where(:name => params[:name]) if params[:name]
31
+ query
35
32
  end
36
33
 
37
34
  api :GET, "/organizations/:organization_id/jenkins_users/:id", N_("Get jenkins user by identifier")
@@ -3,6 +3,7 @@ module ForemanPipeline
3
3
  respond_to :json
4
4
 
5
5
  include Api::Rendering
6
+ include Concerns::ApiControllerExtensions
6
7
 
7
8
  before_filter :find_organization, :only => [:create, :index, :add_projects, :available_paths]
8
9
 
@@ -12,8 +13,6 @@ module ForemanPipeline
12
13
  :add_projects, :remove_projects, :set_to_environments,
13
14
  :available_paths]
14
15
 
15
- before_filter :load_search_service, :only => [:index]
16
-
17
16
  def_param_group :job do
18
17
  param :name, String, :desc => N_("Name of the job"), :required => true
19
18
  param :manual_trigger, :bool, :desc => N_("Allow starting job manually"), :required => false
@@ -31,15 +30,17 @@ module ForemanPipeline
31
30
  param :organization_id, :number, :desc => N_("organization identifier"), :required => true
32
31
  param :name, String, :desc => N_("Name of the job")
33
32
  def index
34
- ids = Job.readable.where(:organization_id => @organization.id).pluck(:id)
35
- filters = [:terms => {:id => ids}]
36
- filters << {:term => {:name => params[:name]}} if params[:name]
33
+ respond_for_index(:collection => scoped_search(index_relation.uniq, params[:sort_by], params[:sort_order]))
34
+ end
37
35
 
38
- options = {
39
- :filters => filters,
40
- :load_records? => true
41
- }
42
- respond_for_index(:collection => item_search(Job, params, options))
36
+ def index_relation
37
+ query = Job.readable.where(:organization_id => @organization.id)
38
+ query = query.where(:name => params[:name]) if params[:name]
39
+ query = query.where(:manual_trigger => params[:manual_trigger]) if params[:manual_trigger]
40
+ query = query.where(:sync_trigger => params[:sync_trigger]) if params[:sync_trigger]
41
+ query = query.where(:levelup_trigger => params[:levelup_trigger]) if params[:levelup_trigger]
42
+ query = query.where(:promote => params[:promote]) if params[:promote]
43
+ query
43
44
  end
44
45
 
45
46
  api :GET, "/organizations/:organization_id/jobs/:id", N_("Get job by identifier")
@@ -0,0 +1,13 @@
1
+ module ForemanPipeline
2
+ module Concerns
3
+ module ApiControllerExtensions
4
+ extend ActiveSupport::Concern
5
+
6
+ def resource_class
7
+ @resource_class ||= resource_name.classify.constantize
8
+ rescue NameError
9
+ @resource_class ||= "ForemanPipeline::#{resource_name.classify}".constantize
10
+ end
11
+ end
12
+ end
13
+ end
@@ -6,7 +6,6 @@ module ForemanPipeline
6
6
 
7
7
  attr_accessor :client, :server_version
8
8
  include Katello::Glue
9
- include Glue::ElasticSearch::JenkinsInstance
10
9
  include ForemanPipeline::Authorization::JenkinsInstance
11
10
 
12
11
  attr_accessible :name, :url, :organization_id, :pubkey, :jenkins_home, :cert_path, :jenkins_user_id
@@ -23,6 +22,8 @@ module ForemanPipeline
23
22
  validates :organization, :presence => true
24
23
  validates :jenkins_home, :format => { :with => FILEPATH_REGEX }
25
24
 
25
+ scoped_search :on => :name , :complete_value => true
26
+
26
27
  # TODO: loose coupling
27
28
  def create_client(username = nil, password = nil)
28
29
  fail "Cannot create Jenkins client: no url in Jenkins Instance" if url.nil?
@@ -3,7 +3,6 @@ module ForemanPipeline
3
3
  self.include_root_in_json = false
4
4
 
5
5
  include Katello::Glue
6
- include Glue::ElasticSearch::JenkinsProject
7
6
  include ForemanPipeline::Authorization::JenkinsProject
8
7
 
9
8
  belongs_to :organization
@@ -3,7 +3,6 @@ module ForemanPipeline
3
3
  self.include_root_in_json = false
4
4
 
5
5
  include Katello::Glue
6
-
7
6
  include ForemanPipeline::Authorization::JenkinsProjectParam
8
7
 
9
8
  self.inheritance_column = :_inheritance_type_disabled
@@ -3,7 +3,6 @@ module ForemanPipeline
3
3
  self.include_root_in_json = false
4
4
 
5
5
  include Katello::Glue
6
- include Glue::ElasticSearch::JenkinsUser
7
6
  include ForemanPipeline::Authorization::JenkinsUser
8
7
 
9
8
  belongs_to :organization
@@ -13,5 +12,7 @@ module ForemanPipeline
13
12
  validates :token, :presence => true
14
13
 
15
14
  attr_accessible :name, :token, :organization_id
15
+
16
+ scoped_search :on => :name, :complete_value => true
16
17
  end
17
18
  end
@@ -3,7 +3,6 @@ module ForemanPipeline
3
3
  self.include_root_in_json = false
4
4
 
5
5
  include Katello::Glue
6
- include Glue::ElasticSearch::Job
7
6
  include ForemanPipeline::Authorization::Job
8
7
  include ActiveModel::Validations
9
8
 
@@ -31,6 +30,12 @@ module ForemanPipeline
31
30
  attr_accessible :name, :content_view_id, :hostgroup_id, :organization_id, :compute_resource_id, :jenkins_instance_id,
32
31
  :environment_id, :manual_trigger, :levelup_trigger, :sync_trigger
33
32
 
33
+ scoped_search :on => :name, :complete_value => true
34
+ scoped_search :on => :organization_id, :complete_value => true
35
+ scoped_search :on => :manual_trigger, :complete_value => true
36
+ scoped_search :on => :levelup_trigger, :complete_value => true
37
+ scoped_search :on => :sync_trigger, :complete_value => true
38
+
34
39
  def is_valid?
35
40
  !self.attributes.values.include?(nil) && !self.jenkins_instance.jenkins_user.nil?
36
41
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanPipeline
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Pražák
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman_deployments
@@ -176,6 +176,7 @@ files:
176
176
  - app/controllers/foreman_pipeline/api/jenkins_users_controller.rb
177
177
  - app/controllers/foreman_pipeline/api/jobs_controller.rb
178
178
  - app/controllers/foreman_pipeline/application_controller.rb
179
+ - app/controllers/foreman_pipeline/concerns/api_controller_extensions.rb
179
180
  - app/helpers/foreman_pipeline/application_helper.rb
180
181
  - app/lib/actions/foreman_pipeline/jenkins/abstract_jenkins_action.rb
181
182
  - app/lib/actions/foreman_pipeline/jenkins/build.rb
@@ -218,11 +219,6 @@ files:
218
219
  - app/models/foreman_pipeline/concerns/hostgroup_extension.rb
219
220
  - app/models/foreman_pipeline/concerns/kt_environment_extension.rb
220
221
  - app/models/foreman_pipeline/concerns/repository_extension.rb
221
- - app/models/foreman_pipeline/glue/elastic_search/base_model.rb
222
- - app/models/foreman_pipeline/glue/elastic_search/jenkins_instance.rb
223
- - app/models/foreman_pipeline/glue/elastic_search/jenkins_project.rb
224
- - app/models/foreman_pipeline/glue/elastic_search/jenkins_user.rb
225
- - app/models/foreman_pipeline/glue/elastic_search/job.rb
226
222
  - app/models/foreman_pipeline/jenkins_instance.rb
227
223
  - app/models/foreman_pipeline/jenkins_project.rb
228
224
  - app/models/foreman_pipeline/jenkins_project_param.rb
@@ -1,21 +0,0 @@
1
- module ForemanPipeline
2
- module Glue::ElasticSearch::BaseModel
3
-
4
- def self.included(base)
5
- base.send :include, Katello::Ext::IndexedModel
6
-
7
- base.class_eval do
8
- index_options :extended_json => :extended_index_attrs,
9
- :display_attrs => [:name]
10
- mapping do
11
- indexes :name, :type => 'string', :analyzer => :kt_name_analyzer
12
- indexes :name_sort, :type => 'string', :index => :not_analyzed
13
- end
14
- end
15
- end
16
-
17
- def extended_index_attrs
18
- {:name_sort => name.downcase}
19
- end
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- module ForemanPipeline
2
- module Glue::ElasticSearch::JenkinsInstance
3
-
4
- def self.included(base)
5
- base.class_eval do
6
- include Glue::ElasticSearch::BaseModel
7
- end
8
- end
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module ForemanPipeline
2
- module Glue::ElasticSearch::JenkinsProject
3
-
4
- def self.included(base)
5
- base.class_eval do
6
- include Glue::ElasticSearch::BaseModel
7
- end
8
- end
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module ForemanPipeline
2
- module Glue::ElasticSearch::JenkinsUser
3
-
4
- def self.included(base)
5
- base.class_eval do
6
- include Glue::ElasticSearch::BaseModel
7
- end
8
- end
9
-
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module ForemanPipeline
2
- module Glue::ElasticSearch::Job
3
-
4
- def self.included(base)
5
- base.class_eval do
6
- include Glue::ElasticSearch::BaseModel
7
- end
8
- end
9
-
10
- end
11
- end