diff --git a/app/models/integration.rb b/app/models/integration.rb index 54eeab1036086bd709597328310c4e7404c9e849..cbf1fd91c3f71cf6cc9aa136d9c2ff23013cb3ca 100644 --- a/app/models/integration.rb +++ b/app/models/integration.rb @@ -18,7 +18,7 @@ class Integration < ApplicationRecord self.inheritance_column = :type_new INTEGRATION_NAMES = %w[ - asana assembla bamboo bugzilla buildkite campfire confluence custom_issue_tracker datadog discord + asana assembla bamboo bugzilla buildkite campfire cloudflare confluence custom_issue_tracker datadog discord drone_ci emails_on_push ewm external_wiki hangouts_chat harbor irker jira mattermost mattermost_slash_commands microsoft_teams packagist pipelines_email pivotaltracker prometheus pumble pushover redmine slack slack_slash_commands teamcity unify_circuit webex_teams youtrack zentao diff --git a/app/models/integrations/cloudflare.rb b/app/models/integrations/cloudflare.rb new file mode 100644 index 0000000000000000000000000000000000000000..a169106de9c00445b09f04576e19d0b8f0550903 --- /dev/null +++ b/app/models/integrations/cloudflare.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true +module Integrations + class Cloudflare < Integration + # include HasWebHook + + prop_accessor :api_token + prop_accessor :service_account_id + + def self.supported_events + %w[push] + end + + def title + 'Cloudflare' + end + + def self.to_param + 'cloudflare' + end + + def fields + [ + { + type: 'text', + name: 'api_token', + title: s_('CloudflareIntegration|API Token'), + required: true + }, + { + type: 'text', + name: 'service_account_id', + title: s_('CloudflareIntegration|Serviceaccount ID'), + required: true + } + ] + end + end + + def execute(data) + # return unless supported_events.include?(data[:object_kind]) + Gitlab::AppLogger.warn("executing Cloudflare Integration") + Gitlab::HTTP.post("http://localhost:7676/dump", body: { payload: data }.to_json, headers: { 'Content-Type' => + 'application/json' }) + end +end diff --git a/app/models/project.rb b/app/models/project.rb index 561a842f23a499d656e8fc654c6bbe03c4a454d2..280824557e3c101814e28aed81cdf0dbf4767a33 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -177,6 +177,7 @@ def self.integration_association_name(name) has_one :bugzilla_integration, class_name: 'Integrations::Bugzilla' has_one :buildkite_integration, class_name: 'Integrations::Buildkite' has_one :campfire_integration, class_name: 'Integrations::Campfire' + has_one :cloudflare_integration, class_name: 'Integrations::Cloudflare' has_one :confluence_integration, class_name: 'Integrations::Confluence' has_one :custom_issue_tracker_integration, class_name: 'Integrations::CustomIssueTracker' has_one :datadog_integration, class_name: 'Integrations::Datadog'