From aaf2ca8757e32cc4d0cd567105ecfd46abf18388 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 Nov 2023 18:41:49 -0300 Subject: [PATCH] fix: deshabilitar njalla #14696 --- Gemfile | 1 - Gemfile.lock | 4 -- app/models/deploy_distributed_press.rb | 60 +------------------------- 3 files changed, 2 insertions(+), 63 deletions(-) diff --git a/Gemfile b/Gemfile index 972560b4..bf9e875c 100644 --- a/Gemfile +++ b/Gemfile @@ -40,7 +40,6 @@ gem 'devise' gem 'devise-i18n' gem 'devise_invitable' gem 'distributed-press-api-client', '~> 0.3.0rc0' -gem 'njalla-api-client', '~> 0.2.0' gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n' gem 'exception_notification' gem 'fast_blank' diff --git a/Gemfile.lock b/Gemfile.lock index 39394a8c..3faad5e8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -366,9 +366,6 @@ GEM net-ssh (7.1.0) netaddr (2.0.6) nio4r (2.5.9-x86_64-linux-musl) - njalla-api-client (0.2.0) - dry-schema - httparty (~> 0.18) nokogiri (1.15.4-x86_64-linux-musl) mini_portile2 (~> 2.8.2) racc (~> 1.4) @@ -636,7 +633,6 @@ DEPENDENCIES mini_magick mobility net-ssh - njalla-api-client (~> 0.2.0) nokogiri pg pg_search diff --git a/app/models/deploy_distributed_press.rb b/app/models/deploy_distributed_press.rb index 2c892b55..da8fe209 100644 --- a/app/models/deploy_distributed_press.rb +++ b/app/models/deploy_distributed_press.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'distributed_press/v1/client/site' -require 'njalla/v1' # Soportar Distributed Press APIv1 # @@ -15,8 +14,8 @@ require 'njalla/v1' class DeployDistributedPress < Deploy store :values, accessors: %i[hostname remote_site_id remote_info], coder: JSON - before_create :create_remote_site!, :create_njalla_records! - before_destroy :delete_remote_site!, :delete_njalla_records! + before_create :create_remote_site! + before_destroy :delete_remote_site! DEPENDENCIES = %i[deploy_local] @@ -31,17 +30,12 @@ class DeployDistributedPress < Deploy time_start create_remote_site! if remote_site_id.blank? - create_njalla_records! save if remote_site_id.blank? raise DeployJob::DeployException, 'El sitio no se creĆ³ en Distributed Press' end - if create_njalla_records? && remote_info[:njalla].blank? - raise DeployJob::DeployException, 'No se pudieron crear los registros necesarios en Njalla' - end - site_client.tap do |c| stdout = Thread.new(publisher.logger_out) do |io| until io.eof? @@ -145,29 +139,6 @@ class DeployDistributedPress < Deploy nil end - # Crea los registros en Njalla - # - # XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay - # que eliminarlo. - # - # @return [nil] - def create_njalla_records! - return unless create_njalla_records? - - self.remote_info ||= {} - self.remote_info[:njalla] ||= {} - self.remote_info[:njalla][:a] ||= njalla.add_record(name: site.name, type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info[:njalla][:cname] ||= njalla.add_record(name: "www.#{site.name}", type: 'CNAME', content: "#{Site.domain}.").to_h - self.remote_info[:njalla][:ns] ||= njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h - - nil - rescue HTTParty::Error => e - ExceptionNotifier.notify_exception(e, data: { site: site.name }) - self.remote_info.delete :njalla - ensure - nil - end - # Registra lo que sucediĆ³ # # @param status [Bool] @@ -185,31 +156,4 @@ class DeployDistributedPress < Deploy ExceptionNotifier.notify_exception(e, data: { site: site.name }) nil end - - def delete_njalla_records! - return unless create_njalla_records? - - %w[a ns cname].each do |type| - next if (id = remote_info.dig('njalla', type, 'id')).blank? - - njalla.remove_record(id: id.to_i) - end - end - - # Actualizar registros en Njalla - # - # @return [Njalla::V1::Domain] - def njalla - @njalla ||= - begin - client = Njalla::V1::Client.new(token: Rails.application.credentials.njalla) - - Njalla::V1::Domain.new(domain: Site.domain, client: client) - end - end - - # Detecta si tenemos que crear registros en Njalla - def create_njalla_records? - !site.name.end_with?('.') - end end