5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-03 23:35:45 +00:00

soportar distributed press apiv0 #7839

This commit is contained in:
f 2022-10-05 18:44:23 -03:00
parent ba91ed56aa
commit 6f4e91d318
3 changed files with 76 additions and 11 deletions

View file

@ -92,6 +92,13 @@ class Deploy < ApplicationRecord
r&.success? r&.success?
end end
# Variables de entorno
#
# @return [Hash]
def local_env
@local_env ||= {}
end
private private
# @param [String] # @param [String]
@ -99,4 +106,12 @@ class Deploy < ApplicationRecord
def readable_cmd(cmd) def readable_cmd(cmd)
cmd.split(' -', 2).first.tr(' ', '_') cmd.split(' -', 2).first.tr(' ', '_')
end end
def deploy_local
@deploy_local ||= site.deploys.find_by(type: 'DeployLocal')
end
def non_local_deploys
@non_local_deploys ||= site.deploys.where.not(type: 'DeployLocal')
end
end end

View file

@ -0,0 +1,34 @@
# frozen_string_literal: true
# Soportar Distributed Press APIv0
#
# No se realiza ninguna acción porque el deploy se hace desde el plugin
# local.
class DeployDistributedPress < Deploy
store :values, accessors: %i[api_key hostname], coder: JSON
def deploy; end
def limit; end
def size
deploy_local.size
end
# TODO: Devolver hyper:// y otras
def url
"ipfs://#{hostname}/"
end
# Devuelve variables de entorno para enviarle a DeployLocal
#
# @return [Hash]
def local_env
{
'DISTRIBUTED_PRESS_PROJECT_DOMAIN' => hostname,
'DISTRIBUTED_PRESS_API_KEY' => api_key
}
end
def destination; end
end

View file

@ -67,21 +67,24 @@ class DeployLocal < Deploy
end end
# Un entorno que solo tiene lo que necesitamos # Un entorno que solo tiene lo que necesitamos
#
# @return [Hash]
def env def env
# XXX: This doesn't support Windows paths :B # XXX: This doesn't support Windows paths :B
paths = [File.dirname(`which bundle`), '/usr/bin', '/bin'] paths = [File.dirname(`which bundle`), '/usr/bin', '/bin']
{ # Las variables de entorno extra no pueden superponerse al local.
'HOME' => home_dir, extra_env.merge({
'PATH' => paths.join(':'), 'HOME' => home_dir,
'SPREE_API_KEY' => site.tienda_api_key, 'PATH' => paths.join(':'),
'SPREE_URL' => site.tienda_url, 'SPREE_API_KEY' => site.tienda_api_key,
'AIRBRAKE_PROJECT_ID' => site.id.to_s, 'SPREE_URL' => site.tienda_url,
'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key, 'AIRBRAKE_PROJECT_ID' => site.id.to_s,
'JEKYLL_ENV' => Rails.env, 'AIRBRAKE_PROJECT_KEY' => site.airbrake_api_key,
'LANG' => ENV['LANG'], 'JEKYLL_ENV' => Rails.env,
'YARN_CACHE_FOLDER' => yarn_cache_dir 'LANG' => ENV['LANG'],
} 'YARN_CACHE_FOLDER' => yarn_cache_dir
})
end end
def yarn_cache_dir def yarn_cache_dir
@ -125,4 +128,17 @@ class DeployLocal < Deploy
def remove_destination! def remove_destination!
FileUtils.rm_rf destination FileUtils.rm_rf destination
end end
# Consigue todas las variables de entorno configuradas por otros
# deploys.
#
# @return [Hash]
def extra_env
@extra_env ||=
non_local_deploys.reduce({}) do |extra_env, deploy|
extra_env.tap do |e|
e.merge! deploy.local_env
end
end
end
end end