mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 17:36:22 +00:00
soportar distributed press apiv0 #7839
This commit is contained in:
parent
64e93506b7
commit
44de522764
3 changed files with 76 additions and 11 deletions
|
@ -75,6 +75,13 @@ class Deploy < ApplicationRecord
|
|||
r&.success?
|
||||
end
|
||||
|
||||
# Variables de entorno
|
||||
#
|
||||
# @return [Hash]
|
||||
def local_env
|
||||
@local_env ||= {}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# @param [String]
|
||||
|
@ -82,4 +89,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
|
||||
|
|
34
app/models/deploy_distributed_press.rb
Normal file
34
app/models/deploy_distributed_press.rb
Normal 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
|
|
@ -50,21 +50,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
|
||||
|
@ -112,4 +115,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
|
||||
|
|
Loading…
Reference in a new issue