5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-07-01 22:16:07 +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?
end
# Variables de entorno
#
# @return [Hash]
def local_env
@local_env ||= {}
end
private
# @param [String]
@ -99,4 +106,12 @@ class Deploy < ApplicationRecord
def readable_cmd(cmd)
cmd.split(' -', 2).first.tr(' ', '_')
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

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