mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 19:36:22 +00:00
fix: los registros en njalla no siempre son necesarios
This commit is contained in:
parent
f6a08f1073
commit
d2e4fe0964
1 changed files with 25 additions and 11 deletions
|
@ -34,8 +34,12 @@ class DeployDistributedPress < Deploy
|
||||||
create_njalla_records!
|
create_njalla_records!
|
||||||
save
|
save
|
||||||
|
|
||||||
if remote_site_id.blank? || remote_info['njalla'].blank?
|
if remote_site_id.blank?
|
||||||
raise DeployJob::DeployException, ''
|
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
|
end
|
||||||
|
|
||||||
site_client.tap do |c|
|
site_client.tap do |c|
|
||||||
|
@ -129,17 +133,20 @@ class DeployDistributedPress < Deploy
|
||||||
|
|
||||||
# Crea los registros en Njalla
|
# Crea los registros en Njalla
|
||||||
#
|
#
|
||||||
# @return [nil]
|
|
||||||
def create_njalla_records!
|
|
||||||
# XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
|
# XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
|
||||||
# que eliminarlo.
|
# que eliminarlo.
|
||||||
unless site.name.end_with? '.'
|
#
|
||||||
|
# @return [nil]
|
||||||
|
def create_njalla_records!
|
||||||
|
return unless create_njalla_records?
|
||||||
|
|
||||||
self.remote_info ||= {}
|
self.remote_info ||= {}
|
||||||
self.remote_info['njalla'] ||= {}
|
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']['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']['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
|
self.remote_info['njalla']['ns'] ||= njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h
|
||||||
end
|
|
||||||
|
nil
|
||||||
rescue HTTParty::Error => e
|
rescue HTTParty::Error => e
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
ExceptionNotifier.notify_exception(e, data: { site: site.name })
|
||||||
self.remote_info['njalla'] = nil
|
self.remote_info['njalla'] = nil
|
||||||
|
@ -166,6 +173,8 @@ class DeployDistributedPress < Deploy
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_njalla_records!
|
def delete_njalla_records!
|
||||||
|
return unless create_njalla_records?
|
||||||
|
|
||||||
%w[a ns cname].each do |type|
|
%w[a ns cname].each do |type|
|
||||||
next if (id = remote_info.dig('njalla', type, 'id')).blank?
|
next if (id = remote_info.dig('njalla', type, 'id')).blank?
|
||||||
|
|
||||||
|
@ -184,4 +193,9 @@ class DeployDistributedPress < Deploy
|
||||||
Njalla::V1::Domain.new(domain: Site.domain, client: client)
|
Njalla::V1::Domain.new(domain: Site.domain, client: client)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Detecta si tenemos que crear registros en Njalla
|
||||||
|
def create_njalla_records?
|
||||||
|
!site.name.end_with?('.')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue