Repository navigation
設定ファイルを書き出す責務をクラス分割 - #65
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the configuration generation logic by extracting Nginx and logrotate rendering into dedicated renderer classes and adding corresponding unit tests. Feedback highlights critical issues where Ruby 3.1 keyword argument shorthand is incorrectly applied to methods, which will result in NameErrors. Additionally, a new check for the 'socat' binary in the SocatManager initializer is flagged as out-of-scope and potentially disruptive to environments not requiring socat.
| if @no_ssl | ||
| # HTTPS 非対応 | ||
| render_nginx template: :http | ||
| nginx_renderer.render(template: :http, output_path:) |
| # 証明書ファイルが指定されていなければ、Let's Encrypt を使って生成する | ||
| if force_update_cert || !File.exist?("/etc/letsencrypt/live/#{domain}") | ||
| render_nginx template: :cert | ||
| nginx_renderer.render(template: :cert, output_path:) |
| end | ||
|
|
||
| render_nginx template: :https | ||
| nginx_renderer.render(template: :https, output_path:) |
|
|
||
| def initialize | ||
| @dest_list = {} # { dest => unix_socket } な連想配列 | ||
| raise "socat is not installed" unless system('which socat > /dev/null 2>&1') |
There was a problem hiding this comment.
| require_relative 'test_helper' | ||
|
|
||
| Dir[File.join(__dir__, "*_test.rb")].sort.each do |file| | ||
| Dir[File.join(__dir__, "**/*_test.rb")].sort.each do |file| |
|
|
||
| def initialize | ||
| @dest_list = {} # { dest => unix_socket } な連想配列 | ||
| raise "socat is not installed" unless system('which socat > /dev/null 2>&1') |
There was a problem hiding this comment.
socat がインストールされているかのチェックを追加
haruyan-hopemucci
left a comment
There was a problem hiding this comment.
レビューOKです! ありがとうございました!
| class BaseRenderer | ||
| def initialize(config) | ||
| @config = config | ||
| end | ||
|
|
||
| def render(template_path:, output_path:) |
| def render(template:, output_path:) | ||
| template_path = File.join(TEMPLATE_DIR, "#{template}.erb") | ||
| super template_path:, output_path: | ||
| end |
| if @no_ssl | ||
| # HTTPS 非対応 | ||
| render_nginx template: :http | ||
| nginx_renderer.render(template: :http, output_path:) |
| require 'lib/config' | ||
| require 'lib/renderers/nginx_by_domain/renderer' | ||
|
|
||
| class NginxByDomainRendererTest < Minitest::Test |
There was a problem hiding this comment.
👍
レンダラーごとのテストに分割できて保守性が上がったと思います!
#57 (comment)
Config#generate_nginx_configがまだ残っていますが、これも将来的にはクラス切り出ししていく流れです。