uffizzi_core 0.5.0 → 0.6.0
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 +4 -4
- data/app/clients/uffizzi_core/docker_hub_client.rb +0 -38
- data/app/services/uffizzi_core/deployment_service.rb +0 -23
- data/app/services/uffizzi_core/docker_hub_service.rb +0 -37
- data/config/routes.rb +0 -8
- data/lib/uffizzi_core/version.rb +1 -1
- metadata +2 -4
- data/app/jobs/uffizzi_core/credential/docker_hub/create_webhook_job.rb +0 -15
- data/app/jobs/uffizzi_core/deployment/create_webhooks_job.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 906801fea12b493de551c88a90e6a8fb576d76e07cca94d599387a620dcca920
|
4
|
+
data.tar.gz: e42b3989f0cee2e2ca4a87c7231d477cffc426d73ba26368a5ed47a60ac2c569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ccf182b08308c44d6b62c00832cefd031b34abad8b7c5eace999d6c34ec43976b5d2c577c5044bcf83299cef80776a55a9ebdd56a4dc82e12013bee47dd9582
|
7
|
+
data.tar.gz: 4e6a3c3921e8d360a73eeeb615c24039b362148a9f4119f04e0bfa7f8f9cff3ab8b27ed9f5923d033d482cd668f65e669a9af60609f2b060a0ed9276b56cdee2
|
@@ -43,34 +43,6 @@ class UffizziCore::DockerHubClient
|
|
43
43
|
RequestResult.new(result: response.body)
|
44
44
|
end
|
45
45
|
|
46
|
-
def get_webhooks(slug:, registry:)
|
47
|
-
url = BASE_URL + "/v2/repositories/#{slug}/webhook_pipeline/"
|
48
|
-
|
49
|
-
response = connection.get(url, { registry: registry, page_size: 100 }) do |request|
|
50
|
-
request.headers['Authorization'] = "JWT #{jwt}"
|
51
|
-
end
|
52
|
-
|
53
|
-
RequestResult.new(status: response.status, result: response.body)
|
54
|
-
end
|
55
|
-
|
56
|
-
def create_webhook(slug:, name:, expect_final_callback:, webhooks:)
|
57
|
-
raise NotAuthorizedError if !authentificated?
|
58
|
-
|
59
|
-
url = BASE_URL + "/v2/repositories/#{slug}/webhook_pipeline/"
|
60
|
-
|
61
|
-
params = {
|
62
|
-
name: name,
|
63
|
-
expect_final_callback: expect_final_callback,
|
64
|
-
webhooks: webhooks,
|
65
|
-
}
|
66
|
-
|
67
|
-
response = connection.post(url, params) do |request|
|
68
|
-
request.headers['Authorization'] = "JWT #{jwt}"
|
69
|
-
end
|
70
|
-
|
71
|
-
RequestResult.new(status: response.status, result: response.body)
|
72
|
-
end
|
73
|
-
|
74
46
|
def accounts
|
75
47
|
raise NotAuthorizedError if !authentificated?
|
76
48
|
|
@@ -115,16 +87,6 @@ class UffizziCore::DockerHubClient
|
|
115
87
|
RequestResult.new(result: response.body)
|
116
88
|
end
|
117
89
|
|
118
|
-
def send_webhook_answer(url, params)
|
119
|
-
conn = Faraday.new do |c|
|
120
|
-
c.request(:json)
|
121
|
-
c.adapter(Faraday.default_adapter)
|
122
|
-
end
|
123
|
-
response = conn.post(url, params)
|
124
|
-
|
125
|
-
RequestResult.quiet.new(result: response.body)
|
126
|
-
end
|
127
|
-
|
128
90
|
def authentificated?
|
129
91
|
jwt.present?
|
130
92
|
end
|
@@ -23,7 +23,6 @@ class UffizziCore::DeploymentService
|
|
23
23
|
update_subdomain!(deployment_form)
|
24
24
|
|
25
25
|
UffizziCore::Deployment::CreateJob.perform_async(deployment_form.id)
|
26
|
-
UffizziCore::Deployment::CreateWebhooksJob.perform_async(deployment_form.id)
|
27
26
|
end
|
28
27
|
|
29
28
|
deployment_form
|
@@ -208,28 +207,6 @@ class UffizziCore::DeploymentService
|
|
208
207
|
deployment.save!
|
209
208
|
end
|
210
209
|
|
211
|
-
def create_webhooks(deployment)
|
212
|
-
credential = deployment.project.account.credentials.docker_hub.active.first
|
213
|
-
|
214
|
-
if !deployment.containers.with_docker_hub_repo.exists? || !credential.present?
|
215
|
-
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment.id} create_webhooks no dockerhub containers or credential")
|
216
|
-
return
|
217
|
-
end
|
218
|
-
|
219
|
-
accounts = UffizziCore::DockerHubService.accounts(credential)
|
220
|
-
|
221
|
-
deployment.containers.with_docker_hub_repo.find_each do |container|
|
222
|
-
if !accounts.include?(container.repo.namespace)
|
223
|
-
logger_message = "DEPLOYMENT_PROCESS deployment_id=#{deployment.id} no namespace(#{container.repo.namespace})
|
224
|
-
in accounts(#{accounts.inspect})"
|
225
|
-
Rails.logger.info(logger_message)
|
226
|
-
next
|
227
|
-
end
|
228
|
-
|
229
|
-
UffizziCore::Credential::DockerHub::CreateWebhookJob.perform_async(credential.id, container.image, deployment.id)
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
210
|
def pull_request_payload_present?(deployment)
|
234
211
|
deployment.continuous_preview_payload.present? && deployment.continuous_preview_payload['pull_request'].present?
|
235
212
|
end
|
@@ -1,44 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class UffizziCore::DockerHubService
|
4
|
-
HOOK_NAME = 'Uffizzi OpenSource Deploy Webhook'
|
5
|
-
HOOK_URL = "#{Settings.app.host}api/cli/v1/webhooks/docker_hub"
|
6
|
-
REGISTRY = 'registry-1.docker.io'
|
7
|
-
|
8
4
|
class << self
|
9
|
-
def create_webhook(credential, image)
|
10
|
-
client = user_client(credential)
|
11
|
-
|
12
|
-
webhooks_response = client.get_webhooks(slug: image, registry: REGISTRY)
|
13
|
-
Rails.logger.info("DockerHubService create_webhook get_webhooks_response=#{webhooks_response.inspect}")
|
14
|
-
|
15
|
-
return false if webhooks_response.status != 200
|
16
|
-
|
17
|
-
webhooks = webhooks_response.result['results']
|
18
|
-
|
19
|
-
webhook = webhooks.detect { |hook| hook['name'] == HOOK_NAME }
|
20
|
-
|
21
|
-
return true if !webhook.nil?
|
22
|
-
|
23
|
-
params = {
|
24
|
-
slug: image,
|
25
|
-
name: HOOK_NAME,
|
26
|
-
expect_final_callback: false,
|
27
|
-
webhooks: [{ name: HOOK_NAME, hook_url: HOOK_URL, registry: REGISTRY }],
|
28
|
-
}
|
29
|
-
|
30
|
-
response = client.create_webhook(params)
|
31
|
-
|
32
|
-
Rails.logger.info("DockerHubService create_webhook create_webhook_response=#{response.inspect} params=#{params.inspect}")
|
33
|
-
|
34
|
-
response.status == 201
|
35
|
-
end
|
36
|
-
|
37
|
-
def send_webhook_answer(callback_url)
|
38
|
-
params = { state: 'success', description: 'Successfully deployed to Uffizzi' }
|
39
|
-
public_docker_hub_client.send_webhook_answer(callback_url, params)
|
40
|
-
end
|
41
|
-
|
42
5
|
def accounts(credential)
|
43
6
|
client = user_client(credential)
|
44
7
|
response = client.accounts
|
data/config/routes.rb
CHANGED
@@ -7,14 +7,6 @@ UffizziCore::Engine.routes.draw do
|
|
7
7
|
namespace :api, defaults: { format: :json } do
|
8
8
|
namespace :cli do
|
9
9
|
namespace :v1 do
|
10
|
-
resource :webhooks, only: [] do
|
11
|
-
post :docker_hub
|
12
|
-
post :github
|
13
|
-
post :azure
|
14
|
-
post :amazon
|
15
|
-
post :google
|
16
|
-
end
|
17
|
-
|
18
10
|
resources :projects, only: ['index', 'show', 'create', 'destroy'], param: :slug do
|
19
11
|
scope module: :projects do
|
20
12
|
resource :compose_file, only: ['show', 'create', 'destroy']
|
data/lib/uffizzi_core/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uffizzi_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Thurman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-08-
|
12
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: aasm
|
@@ -754,11 +754,9 @@ files:
|
|
754
754
|
- app/jobs/uffizzi_core/activity_item/docker/update_digest_job.rb
|
755
755
|
- app/jobs/uffizzi_core/application_job.rb
|
756
756
|
- app/jobs/uffizzi_core/config_file/apply_job.rb
|
757
|
-
- app/jobs/uffizzi_core/credential/docker_hub/create_webhook_job.rb
|
758
757
|
- app/jobs/uffizzi_core/deployment/create_credential_job.rb
|
759
758
|
- app/jobs/uffizzi_core/deployment/create_credentials_job.rb
|
760
759
|
- app/jobs/uffizzi_core/deployment/create_job.rb
|
761
|
-
- app/jobs/uffizzi_core/deployment/create_webhooks_job.rb
|
762
760
|
- app/jobs/uffizzi_core/deployment/delete_credential_job.rb
|
763
761
|
- app/jobs/uffizzi_core/deployment/delete_job.rb
|
764
762
|
- app/jobs/uffizzi_core/deployment/deploy_containers_job.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class UffizziCore::Credential::DockerHub::CreateWebhookJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :accounts, retry: 5
|
5
|
-
|
6
|
-
def perform(credential_id, image, deployment_id = nil)
|
7
|
-
if deployment_id.present?
|
8
|
-
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{deployment_id} DockerHub CreateWebhooksJob")
|
9
|
-
end
|
10
|
-
|
11
|
-
credential = UffizziCore::Credential.find(credential_id)
|
12
|
-
|
13
|
-
UffizziCore::DockerHubService.create_webhook(credential, image)
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class UffizziCore::Deployment::CreateWebhooksJob < UffizziCore::ApplicationJob
|
4
|
-
sidekiq_options queue: :deployments, retry: 5
|
5
|
-
|
6
|
-
def perform(id)
|
7
|
-
Rails.logger.info("DEPLOYMENT_PROCESS deployment_id=#{id} CreateWebhooksJob")
|
8
|
-
|
9
|
-
deployment = UffizziCore::Deployment.find(id)
|
10
|
-
|
11
|
-
UffizziCore::DeploymentService.create_webhooks(deployment)
|
12
|
-
end
|
13
|
-
end
|