5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-16 10:41:41 +00:00

feat: crear temporalmente los dominios en njalla

el problema es que no podemos delegar `_dnslink.*.sutty.nl` hacia
distributed press, con lo que es necesario crear un subdominio por cada
sitio que lo active.
This commit is contained in:
f 2023-02-09 20:01:22 -03:00
parent 0b96fc44d6
commit 1b5adfb712
4 changed files with 30 additions and 0 deletions

View file

@ -40,6 +40,7 @@ gem 'devise'
gem 'devise-i18n'
gem 'devise_invitable'
gem 'distributed-press-api-client', '~> 0.2.2'
gem 'njalla-api-client'
gem 'email_address', git: 'https://github.com/fauno/email_address', branch: 'i18n'
gem 'exception_notification'
gem 'fast_blank'

View file

@ -387,6 +387,9 @@ GEM
nokogiri (1.12.5-x86_64-linux-musl)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
njalla-api-client (0.1.0)
dry-schema
httparty (~> 0.18)
orm_adapter (0.5.0)
pairing_heap (3.0.0)
parallel (1.21.0)
@ -654,6 +657,7 @@ DEPENDENCIES
mini_magick
mobility
net-ssh
njalla-api-client
nokogiri
pg
pg_search

View file

@ -111,6 +111,12 @@ class DeployDistributedPress < Deploy
self.remote_site_id = created_site[:id]
self.remote_info = created_site.to_h
# XXX: Esto depende de nuestro DNS actual, cuando lo migremos hay
# que eliminarlo.
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']['ns'] = njalla.add_record(name: "_dnslink.#{site.name}", type: 'NS', content: "#{publisher.hostname}.").to_h
nil
end
@ -123,4 +129,16 @@ class DeployDistributedPress < Deploy
build_stats.create action: publisher.to_s,log: log, seconds: time_spent_in_seconds, bytes: size, status: status
nil
end
# Actualizar registros en Njalla
#
# @return [Njalla::V1::Domain]
def njalla
@njalla ||=
begin
client = Njalla::V1::Client.new(token: ENV['NJALLA_TOKEN'])
Njalla::V1::Domain.new(domain: Site.domain, client: client)
end
end
end

View file

@ -40,6 +40,13 @@ class DistributedPressPublisher < ApplicationRecord
"Distributed Press <#{instance}>"
end
# Devuelve el hostname de la instancia
#
# @return [String]
def hostname
@hostname ||= URI.parse(instance).hostname
end
# @return [Logger]
def logger
@logger ||=