foreman_webhooks 0.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/webhook_templates_controller.rb +2 -6
- data/app/controllers/api/v2/webhooks_controller.rb +11 -3
- data/app/controllers/concerns/foreman_webhooks/controller/parameters/webhook.rb +3 -1
- data/app/controllers/webhooks_controller.rb +1 -24
- data/app/lib/foreman_webhooks/renderer/scope/webhook_template.rb +3 -1
- data/app/models/concerns/foreman_webhooks/taxonomy_extensions.rb +11 -0
- data/app/models/webhook.rb +1 -10
- data/app/services/foreman_webhooks/webhook_service.rb +49 -11
- data/app/views/api/v2/webhooks/show.json.rabl +3 -1
- data/app/views/foreman_webhooks/webhook_templates/katello_-_content_view.erb +16 -0
- data/app/views/foreman_webhooks/webhook_templates/katello_-_promote.erb +23 -0
- data/app/views/foreman_webhooks/webhook_templates/katello_-_publish.erb +24 -0
- data/app/views/foreman_webhooks/webhook_templates/katello_-_repo_sync.erb +27 -0
- data/app/views/foreman_webhooks/webhook_templates/remote_execution_-_host_job.erb +20 -0
- data/config/routes.rb +6 -2
- data/db/migrate/20210322144728_add_proxy_authorization_to_webhook.rb +7 -0
- data/db/seeds.d/62_shellhooks_proxy_feature.rb +6 -0
- data/lib/foreman_webhooks/engine.rb +14 -5
- data/lib/foreman_webhooks/version.rb +1 -1
- data/package.json +6 -6
- data/webpack/ForemanWebhooks/Routes/ForemanWebhooksRoutes.js +2 -2
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/ForemanFormikField.js +117 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.css +7 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/Components/WebhookFormTabs.js +163 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookForm.js +69 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/WebhookFormSelectors.js +58 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/WebhookForm.test.js +51 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/__tests__/__snapshots__/WebhookForm.test.js.snap +510 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/constants.js +9 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/Components/WebhookForm/index.js +73 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksIndexPage/index.js +63 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookCreateModal.js +69 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookDeleteModal.js +1 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModal.js +107 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookEditModalSelectors.js +22 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhookModal.scss +6 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/index.js +1 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/Formatters/nameToEditFormatter.js +19 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/Components/NameToEditCell.js +35 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTable.js +31 -14
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/WebhooksTableSchema.js +12 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/WebhooksTable.test.js +13 -4
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/__tests__/__snapshots__/WebhooksTable.test.js.snap +62 -19
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/WebhooksTable/index.js +27 -5
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/WebhooksIndexPage.js +61 -32
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.fixtures.js +36 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/WebhooksIndexPage.test.js +3 -1
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/WebhooksIndexPage.test.js.snap +18 -60
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/__snapshots__/integration.test.js.snap +43 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/__tests__/integration.test.js +34 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksPageActions.js +3 -0
- data/webpack/ForemanWebhooks/Routes/Webhooks/constants.js +11 -1
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
- data/webpack/__mocks__/foremanReact/common/HOC.js +30 -2
- data/webpack/__mocks__/foremanReact/common/urlHelpers.js +7 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +6 -1
- data/webpack/__mocks__/foremanReact/components/Loading/Loading.js +2 -0
- data/webpack/__mocks__/foremanReact/components/Loading/index.js +3 -0
- data/webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js +3 -1
- data/webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js +9 -0
- data/webpack/__mocks__/foremanReact/components/common/forms/FormField.js +3 -0
- data/webpack/__mocks__/foremanReact/components/common/table.js +21 -0
- data/webpack/__mocks__/foremanReact/history.js +3 -0
- data/webpack/__mocks__/foremanReact/redux/actions/common/forms.js +1 -0
- data/webpack/test_setup.js +15 -0
- metadata +48 -17
- data/app/views/webhooks/_form.html.erb +0 -37
- data/app/views/webhooks/_templates.html.erb +0 -5
- data/app/views/webhooks/edit.html.erb +0 -3
- data/app/views/webhooks/new.html.erb +0 -3
- data/webpack/ForemanWebhooks/Routes/Webhooks/WebhooksIndexPage/Components/EmptyWebhooksTable/index.js +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a3a4ed0dd48b24eff5ad505def967db53ce75d7fc2028931e1d2e3dd296bc82
|
4
|
+
data.tar.gz: 4967cc533c7643041e6c7a533a4b38f2897d605dc5327b79bc80c8fa13759399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c329d395342ed2d557f8d9d8e0229a1be906b502fd4314afb308ecb1b6a535db68f3b074515ea830bfb215a3d7e78bfb02271248b1129b00c768549ee6ad1b78
|
7
|
+
data.tar.gz: fdb4584f33e2e1de069b5c780372280bd0e8200e7d7c80f788d4c024f2bd0f14b7c3460b607a13a021dc13f8d833fb3bc54ca1e2264e64bab933f82de4b18507
|
@@ -28,7 +28,8 @@ module Api
|
|
28
28
|
param :snippet, :bool, allow_nil: true
|
29
29
|
param :audit_comment, String, allow_nil: true
|
30
30
|
param :locked, :bool, desc: N_('Whether or not the template is locked for editing')
|
31
|
-
param :default, :bool,
|
31
|
+
param :default, :bool,
|
32
|
+
desc: N_('Whether or not the template is added automatically to new organizations and locations')
|
32
33
|
param_group :taxonomies, ::Api::V2::BaseController
|
33
34
|
end
|
34
35
|
end
|
@@ -90,11 +91,6 @@ module Api
|
|
90
91
|
|
91
92
|
private
|
92
93
|
|
93
|
-
# Overload this method to avoid using search_for method
|
94
|
-
def resource_scope_for_index(options = {})
|
95
|
-
resource_scope(options).paginate(paginate_options)
|
96
|
-
end
|
97
|
-
|
98
94
|
def action_permission
|
99
95
|
case params[:action]
|
100
96
|
when 'clone', 'import'
|
@@ -5,12 +5,12 @@ module Api
|
|
5
5
|
class WebhooksController < V2::BaseController
|
6
6
|
include Api::Version2
|
7
7
|
include ForemanWebhooks::Controller::Parameters::Webhook
|
8
|
-
include Foreman::Controller::TemplateImport
|
9
8
|
|
10
|
-
before_action :find_resource, only: %i[show
|
9
|
+
before_action :find_resource, only: %i[show destroy]
|
11
10
|
|
12
11
|
api :GET, '/webhooks/', N_('List Webhooks')
|
13
12
|
param_group :search_and_pagination, ::Api::V2::BaseController
|
13
|
+
add_scoped_search_description_for(Webhook)
|
14
14
|
def index
|
15
15
|
@webhooks = resource_scope_for_index
|
16
16
|
end
|
@@ -25,7 +25,8 @@ module Api
|
|
25
25
|
param :target_url, String, required: true
|
26
26
|
param :http_method, Webhook::ALLOWED_HTTP_METHODS
|
27
27
|
param :http_content_type, String
|
28
|
-
|
28
|
+
events = Webhook.available_events.sort.map { |e| e.delete_suffix(Webhook::EVENT_POSTFIX) }
|
29
|
+
param :event, events, required: true
|
29
30
|
param :webhook_template_id, :identifier
|
30
31
|
param :enabled, :boolean
|
31
32
|
param :verify_ssl, :boolean
|
@@ -33,6 +34,7 @@ module Api
|
|
33
34
|
param :user, String
|
34
35
|
param :password, String
|
35
36
|
param :http_headers, String
|
37
|
+
param :proxy_authorization, :boolean, N_('Authorize with Foreman client certificate and validate smart-proxy CA from Settings')
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
@@ -48,6 +50,7 @@ module Api
|
|
48
50
|
param :id, :identifier, required: true
|
49
51
|
param_group :webhook, as: :update
|
50
52
|
def update
|
53
|
+
@webhook = Webhook.find(params[:id])
|
51
54
|
process_response @webhook.update(webhook_params)
|
52
55
|
end
|
53
56
|
|
@@ -56,6 +59,11 @@ module Api
|
|
56
59
|
def destroy
|
57
60
|
process_response @webhook.destroy
|
58
61
|
end
|
62
|
+
|
63
|
+
api :GET, '/webhooks/events', N_('List available events for subscription')
|
64
|
+
def events
|
65
|
+
render json: Webhook.available_events.sort.map { |e| e.delete_suffix(Webhook::EVENT_POSTFIX) }.to_json
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -20,12 +20,14 @@ module ForemanWebhooks
|
|
20
20
|
:ssl_ca_certs,
|
21
21
|
:user,
|
22
22
|
:password,
|
23
|
-
:http_headers
|
23
|
+
:http_headers,
|
24
|
+
:proxy_authorization
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
def webhook_params
|
30
|
+
params['webhook']['event'] = params['event'] unless params['event'].blank?
|
29
31
|
self.class.webhook_params_filter.filter_params(params, parameter_filter_context)
|
30
32
|
end
|
31
33
|
end
|
@@ -4,30 +4,7 @@ class WebhooksController < ::ApplicationController
|
|
4
4
|
include ForemanWebhooks::Controller::Parameters::Webhook
|
5
5
|
include Foreman::Controller::AutoCompleteSearch
|
6
6
|
|
7
|
-
before_action :find_resource, only: %i[
|
8
|
-
|
9
|
-
def new
|
10
|
-
@webhook = Webhook.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def create
|
14
|
-
@webhook = Webhook.new(webhook_params)
|
15
|
-
if @webhook.save
|
16
|
-
process_success success_redirect: '/webhooks'
|
17
|
-
else
|
18
|
-
process_error
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def edit; end
|
23
|
-
|
24
|
-
def update
|
25
|
-
if @webhook.update(webhook_params)
|
26
|
-
process_success success_redirect: '/webhooks'
|
27
|
-
else
|
28
|
-
process_error
|
29
|
-
end
|
30
|
-
end
|
7
|
+
before_action :find_resource, only: %i[destroy]
|
31
8
|
|
32
9
|
def destroy
|
33
10
|
if @webhook.destroy
|
@@ -24,7 +24,9 @@ module ForemanWebhooks
|
|
24
24
|
required :hash, Hash, 'Key=value object with with data that should be present in payload'
|
25
25
|
keyword :with_defaults, [true, false], 'If set to true, adds default entries to the payload', default: true
|
26
26
|
returns String, 'JSON string with the final payload'
|
27
|
-
example 'payload({ id: @object.id, name: @object.name }) #=>
|
27
|
+
example 'payload({ id: @object.id, name: @object.name }) #=> ' \
|
28
|
+
'"{ "id": 1, "name": "host.example.com", "context": { ... }, ' \
|
29
|
+
'"event_name": "host_created.event.foreman" }"'
|
28
30
|
end
|
29
31
|
def payload(hash, with_defaults: true)
|
30
32
|
hash.merge!(@defaults) if with_defaults
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanWebhooks
|
4
|
+
module TaxonomyExtensions
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
has_many :webhook_templates, -> { where(type: 'WebhookTemplate') }, through: :taxable_taxonomies, source: :taxable, source_type: 'WebhookTemplate'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
data/app/models/webhook.rb
CHANGED
@@ -11,15 +11,6 @@ class Webhook < ApplicationRecord
|
|
11
11
|
|
12
12
|
EVENT_POSTFIX = ".#{Foreman::Observable::DEFAULT_NAMESPACE}"
|
13
13
|
|
14
|
-
EVENT_ALLOWLIST = %w[
|
15
|
-
host_created host_updated host_destroyed
|
16
|
-
hostgroup_created hostgroup_updated hostgroup_destroyed
|
17
|
-
user_created user_updated user_destroyed
|
18
|
-
domain_created domain_updated domain_destroyed
|
19
|
-
subnet_created subnet_updated subnet_destroyed
|
20
|
-
build_entered build_exited status_changed
|
21
|
-
].map { |e| e + EVENT_POSTFIX }.freeze
|
22
|
-
|
23
14
|
DEFAULT_PAYLOAD_TEMPLATE = 'Webhook Template - Payload Default'
|
24
15
|
|
25
16
|
ALLOWED_HTTP_METHODS = %w[POST GET PUT DELETE PATCH].freeze
|
@@ -47,7 +38,7 @@ class Webhook < ApplicationRecord
|
|
47
38
|
scoped_search on: :enabled, complete_value: { true: true, false: false }
|
48
39
|
|
49
40
|
def self.available_events
|
50
|
-
::Foreman::EventSubscribers.all_observable_events
|
41
|
+
::Foreman::EventSubscribers.all_observable_events
|
51
42
|
end
|
52
43
|
|
53
44
|
def self.deliver(event_name:, payload:)
|
@@ -14,6 +14,22 @@ module ForemanWebhooks
|
|
14
14
|
@rendered_url = url
|
15
15
|
end
|
16
16
|
|
17
|
+
def foreman_ssl_auth_params
|
18
|
+
cert = Setting[:ssl_certificate]
|
19
|
+
ca_cert = Setting[:ssl_ca_file]
|
20
|
+
hostprivkey = Setting[:ssl_priv_key]
|
21
|
+
|
22
|
+
{
|
23
|
+
cert: OpenSSL::X509::Certificate.new(File.read(cert)),
|
24
|
+
key: OpenSSL::PKey::RSA.new(File.read(hostprivkey)),
|
25
|
+
ca_file: ca_cert
|
26
|
+
}
|
27
|
+
rescue StandardError => e
|
28
|
+
msg = 'Unable to read SSL proxy CA, cert or key'
|
29
|
+
Foreman::Logging.exception(msg, e)
|
30
|
+
raise Foreman::WrappedException.new(e, msg)
|
31
|
+
end
|
32
|
+
|
17
33
|
def execute
|
18
34
|
logger.info("Performing '#{webhook.name}' webhook request for event '#{event_name}'")
|
19
35
|
Foreman::Logging.blob("Payload for '#{event_name}'", payload)
|
@@ -25,15 +41,28 @@ module ForemanWebhooks
|
|
25
41
|
logger.debug("Headers: #{rendered_headers}")
|
26
42
|
end
|
27
43
|
|
28
|
-
|
44
|
+
verify = webhook.verify_ssl?
|
45
|
+
ca_string = webhook.ca_certs_store
|
46
|
+
if webhook.proxy_authorization
|
47
|
+
foreman_ssl = foreman_ssl_auth_params
|
48
|
+
verify = true
|
49
|
+
ca_file = foreman_ssl[:ca_file]
|
50
|
+
cert = foreman_ssl[:cert]
|
51
|
+
key = foreman_ssl[:key]
|
52
|
+
end
|
53
|
+
|
54
|
+
response = self.class.request(url: rendered_url,
|
29
55
|
payload: payload,
|
30
56
|
http_method: webhook.http_method,
|
31
57
|
user: webhook.user,
|
32
58
|
password: webhook.password,
|
33
59
|
content_type: webhook.http_content_type,
|
34
60
|
headers: headers,
|
35
|
-
ca_verify:
|
36
|
-
ca_string:
|
61
|
+
ca_verify: verify,
|
62
|
+
ca_string: ca_string,
|
63
|
+
ca_file: ca_file,
|
64
|
+
cert: cert,
|
65
|
+
key: key,
|
37
66
|
follow_redirects: true)
|
38
67
|
|
39
68
|
status = case response.code.to_i
|
@@ -50,7 +79,8 @@ module ForemanWebhooks
|
|
50
79
|
message: response.message,
|
51
80
|
http_status: response.code.to_i
|
52
81
|
}
|
53
|
-
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNREFUSED, Errno::ECONNRESET,
|
82
|
+
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNREFUSED, Errno::ECONNRESET,
|
83
|
+
Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout => e
|
54
84
|
Foreman::Logging.exception("Failed to execute the webhook #{webhook.name} -> #{event_name}", e)
|
55
85
|
{
|
56
86
|
status: :error,
|
@@ -58,16 +88,19 @@ module ForemanWebhooks
|
|
58
88
|
}
|
59
89
|
end
|
60
90
|
|
61
|
-
def self.request(url:, payload: '', http_method: :GET, user: nil, password: nil,
|
91
|
+
def self.request(url:, payload: '', http_method: :GET, user: nil, password: nil,
|
92
|
+
content_type: 'application/json', headers: {}, ca_string: nil,
|
93
|
+
ca_file: nil, cert: nil, key: nil,
|
94
|
+
ca_verify: false, follow_redirects: true, redirect_limit: 3)
|
62
95
|
uri = URI.parse(url)
|
63
96
|
|
64
97
|
request = Object.const_get("Net::HTTP::#{http_method.to_s.capitalize}").new(uri.request_uri)
|
65
|
-
request.basic_auth(user, password) if user && password
|
98
|
+
request.basic_auth(user, password) if !user.blank? && !password.blank?
|
66
99
|
request['Content-Type'] = content_type
|
67
100
|
request['X-Request-Id'] = ::Logging.mdc['request'] || SecureRandom.uuid
|
68
101
|
request['X-Session-Id'] = ::Logging.mdc['session'] || SecureRandom.uuid
|
69
|
-
headers.each_pair do |
|
70
|
-
request[
|
102
|
+
headers.each_pair do |hkey, value|
|
103
|
+
request[hkey.to_s] = value.to_s
|
71
104
|
end
|
72
105
|
request.body = payload
|
73
106
|
|
@@ -83,14 +116,19 @@ module ForemanWebhooks
|
|
83
116
|
http.use_ssl = true
|
84
117
|
http.verify_mode = ca_verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
85
118
|
http.cert_store = ca_string if ca_string
|
119
|
+
http.ca_file = ca_file if ca_file
|
120
|
+
http.cert = cert if cert
|
121
|
+
http.key = key if key
|
86
122
|
end
|
87
123
|
http.request(request) do |response|
|
88
124
|
case response
|
89
|
-
when Net::HTTPRedirection
|
125
|
+
when Net::HTTPRedirection
|
90
126
|
new_location = response['location']
|
91
127
|
Rails.logger.debug "Redirected to #{new_location} (redirects left: #{redirect_limit})"
|
92
|
-
|
93
|
-
|
128
|
+
if redirect_limit <= 0
|
129
|
+
raise(::Foreman::Exception,
|
130
|
+
N_(format('Too many HTTP redirects when calling %{uri}', uri: uri, code: response.code)))
|
131
|
+
end
|
94
132
|
self.request(url: new_location,
|
95
133
|
payload: payload,
|
96
134
|
http_method: http_method,
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%#
|
2
|
+
name: Katello Content View
|
3
|
+
description: Example payload for content_view_*.event.foreman
|
4
|
+
snippet: false
|
5
|
+
model: WebhookTemplate
|
6
|
+
-%>
|
7
|
+
#
|
8
|
+
# Example webhook template, @object carries Action instance.
|
9
|
+
# For more information about available helpers visit /templates_doc
|
10
|
+
#
|
11
|
+
# Content view id <%= @object.id %>
|
12
|
+
# Content view name <%= @object.name %>
|
13
|
+
# Content view label <%= @object.label %>
|
14
|
+
# Organization id <%= @object.organization.id %>
|
15
|
+
# Organization name <%= @object.organization.name %>
|
16
|
+
# Organization label <%= @object.organization.label %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%#
|
2
|
+
name: Katello Promote
|
3
|
+
description: Example payload for actions.katello.content_view.promote_suceeded
|
4
|
+
snippet: false
|
5
|
+
model: WebhookTemplate
|
6
|
+
-%>
|
7
|
+
#
|
8
|
+
# Example webhook template, @object carries Action instance.
|
9
|
+
# For more information about available helpers visit /templates_doc
|
10
|
+
#
|
11
|
+
# Environments <%= @object.environments %>
|
12
|
+
# Content view ID <%= @object.content_view_id %>
|
13
|
+
# Content view name <%= @object.content_view_name %>
|
14
|
+
# Content view label <%= @object.content_view_label %>
|
15
|
+
# Organization id <%= @object.organization_id %>
|
16
|
+
# Organization name <%= @object.organization_name %>
|
17
|
+
# Organization label <%= @object.organization_label %>
|
18
|
+
# Task label <%= @object.task.label %>
|
19
|
+
# Task started at <%= @object.task.started_at %>
|
20
|
+
# Task ended at <%= @object.task.ended_at %>
|
21
|
+
# Task resulted with <%= @object.task.result %>
|
22
|
+
# Task state <%= @object.task.state %>
|
23
|
+
# Task action output <%= @object.task.action_output %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%#
|
2
|
+
name: Katello Publish
|
3
|
+
description: Example payload for actions.katello.content_view.publish_suceeded
|
4
|
+
snippet: false
|
5
|
+
model: WebhookTemplate
|
6
|
+
-%>
|
7
|
+
#
|
8
|
+
# Example webhook template, @object carries Action instance.
|
9
|
+
# For more information about available helpers visit /templates_doc
|
10
|
+
#
|
11
|
+
# Content view version id <%= @object.content_view_version_id %>
|
12
|
+
# Content view version name <%= @object.content_view_version_name %>
|
13
|
+
# Content view id <%= @object.content_view_id %>
|
14
|
+
# Content view name <%= @object.content_view_name %>
|
15
|
+
# Content view label <%= @object.content_view_label %>
|
16
|
+
# Organization id <%= @object.organization_id %>
|
17
|
+
# Organization name <%= @object.organization_name %>
|
18
|
+
# Organization label <%= @object.organization_label %>
|
19
|
+
# Task label <%= @object.task.label %>
|
20
|
+
# Task started at <%= @object.task.started_at %>
|
21
|
+
# Task ended at <%= @object.task.ended_at %>
|
22
|
+
# Task resulted with <%= @object.task.result %>
|
23
|
+
# Task state <%= @object.task.state %>
|
24
|
+
# Task action output <%= @object.task.action_output %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<%#
|
2
|
+
name: Katello Sync
|
3
|
+
description: Example payload for actions.katello.repository.sync_succeeded
|
4
|
+
snippet: false
|
5
|
+
model: WebhookTemplate
|
6
|
+
-%>
|
7
|
+
#
|
8
|
+
# Example webhook template, @object carries Action instance.
|
9
|
+
# For more information about available helpers visit /templates_doc
|
10
|
+
#
|
11
|
+
# Repository id <%= @object.repository_id %>
|
12
|
+
# Repository name <%= @object.repository_name %>
|
13
|
+
# Repository label <%= @object.repository_label %>
|
14
|
+
# Repository contents_changed <%= @object.contents_changed %>
|
15
|
+
# Repository sync_result <%= @object.sync_result %>
|
16
|
+
# Product id <%= @object.product_id %>
|
17
|
+
# Product name <%= @object.product_name %>
|
18
|
+
# Product label <%= @object.product_label %>
|
19
|
+
# Organization id <%= @object.organization_id %>
|
20
|
+
# Organization name <%= @object.organization_name %>
|
21
|
+
# Organization label <%= @object.organization_label %>
|
22
|
+
# Task label <%= @object.task.label %>
|
23
|
+
# Task started at <%= @object.task.started_at %>
|
24
|
+
# Task ended at <%= @object.task.ended_at %>
|
25
|
+
# Task resulted with <%= @object.task.result %>
|
26
|
+
# Task state <%= @object.task.state %>
|
27
|
+
# Task action output <%= @object.task.action_output %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%#
|
2
|
+
name: Remote Execution Host Job
|
3
|
+
description: Example payload for actions.remote_execution.run_host_job_succeeded
|
4
|
+
snippet: false
|
5
|
+
model: WebhookTemplate
|
6
|
+
-%>
|
7
|
+
#
|
8
|
+
# Example webhook template, @object carries Action instance.
|
9
|
+
# For more information about available helpers visit /templates_doc
|
10
|
+
#
|
11
|
+
# Run job host name <%= @object.host_name %>
|
12
|
+
# Run job host id <%= @object.host_id %>
|
13
|
+
# Run job full host object <%= @object.host %>
|
14
|
+
# Run job job_invocation_id <%= @object.job_invocation_id %>
|
15
|
+
# Run job job_invocation <%= @object.job_invocation %>
|
16
|
+
# Task label <%= @object.task.label %>
|
17
|
+
# Task started at <%= @object.task.started_at %>
|
18
|
+
# Task ended at <%= @object.task.ended_at %>
|
19
|
+
# Task resulted with <%= @object.task.result %>
|
20
|
+
# Task state <%= @object.task.state %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
|
-
resources :webhooks, except: %i[index show] do
|
4
|
+
resources :webhooks, except: %i[index show new edit update] do
|
5
5
|
collection do
|
6
6
|
get 'auto_complete_search'
|
7
7
|
end
|
@@ -14,7 +14,11 @@ Rails.application.routes.draw do
|
|
14
14
|
defaults: { apiv: 'v2' },
|
15
15
|
apiv: /v1|v2/,
|
16
16
|
constraints: ApiConstraints.new(version: 2, default: true) do
|
17
|
-
resources :webhooks, only: %i[index show create update destroy]
|
17
|
+
resources :webhooks, only: %i[index show create update destroy] do
|
18
|
+
collection do
|
19
|
+
get :events
|
20
|
+
end
|
21
|
+
end
|
18
22
|
resources :webhook_templates, except: %i[new edit] do
|
19
23
|
member do
|
20
24
|
post :clone
|