Skip to content

Commit

Permalink
Remove unnecessary Deployer::Response#set_finish_proc
Browse files Browse the repository at this point in the history
Because we can just use Thread to call release tasks.
  • Loading branch information
otegami committed Dec 23, 2024
1 parent 2f40dc8 commit 89dc83f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
17 changes: 7 additions & 10 deletions ansible/files/home/deployer/webhook/lib/deployer/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def process(request, response)
end
verify_signature!(request)
payload = parse_body!(request)
process_payload!(payload, response)
process_payload!(payload)
rescue RequestError => request_error
response.set(request_error.status, request_error.message)
rescue => e
Expand Down Expand Up @@ -77,27 +77,24 @@ def parse_body!(request)
Payload.new(raw_payload, metadata)
end

def process_payload!(payload, response)
def process_payload!(payload)
case payload.event_name
when "ping"
# Do nothing because this is a kind of healthcheck.
nil
when "workflow_run"
return unless payload.released?
deploy(payload, response)
deploy(payload)
else
raise RequestError.new(:bad_request, "Unsupported event: <#{payload.event_name}>")
end
end

def deploy(payload, response)
release_tasks = Proc.new do
Thread.new do
# TODO: call rake tasks for sign packages.
# TODO: write down the errors into log files.
end
def deploy(payload)
Thread.new do
# TODO: call rake tasks for sign packages.
# TODO: write down the errors into log files.
end
response.set_finish_proc(release_tasks)
end
end
end
10 changes: 0 additions & 10 deletions ansible/files/home/deployer/webhook/lib/deployer/response.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (C) 2010-2019 Sutou Kouhei <[email protected]>
# Copyright (C) 2015 Kenji Okimoto <[email protected]>
# Copyright (C) 2024 Horimoto Yasuhiro <[email protected]>
# Copyright (C) 2024 Takuya Kodama <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -25,13 +23,5 @@ def set(status_keyword, message)
self["Content-Type"] = "text/plain"
write(message)
end

def set_finish_proc(proc)
@proc = proc
end

def finish
super(&@proc)
end
end
end

0 comments on commit 89dc83f

Please sign in to comment.