class
Squarectl::TaskFactory
- Squarectl::TaskFactory
- Reference
- Object
Overview
Builds a fully resolved Task from the config.
Each resolvable attribute (env vars, domains, compose files, networks, SSL
certificates, ...) is gathered from two sources — the global all
environment and the selected environment — keeping only entries whose
target: matches (see .find_matching_target), then merged global-first so
the environment overrides the globals. The two define_method_* macros
generate this identical select/merge logic for hash- and array-shaped
attributes respectively.
:nodoc:
Defined in:
squarectl/task_factory.crClass Method Summary
- ._build_task_compose_files(target, environment, all)
- ._build_task_compose_networks(target, environment, all)
- ._build_task_domains(target, environment, all)
- ._build_task_env_vars(target, environment, all)
- ._build_task_ssl_certificates(target, environment, all)
-
.build(target, environment, all, executor = Executor.new)
Resolves every attribute for the given (target, environment) pair — with
allsupplying the global defaults — and assembles theTask. -
.build_task_compose_files(target, environment, all)
Resolves the compose file list.
- .build_task_compose_networks(target, environment, all)
-
.build_task_deploy_configs(target, environment, all)
Resolves swarm config files.
-
.build_task_deploy_secrets(target, environment, all)
Resolves swarm secret files.
-
.build_task_deploy_server(target, environment, all)
The remote Docker host (
DOCKER_HOST) for swarm deploys — the first matchingserverentry's host, or empty when none is declared. -
.build_task_domains(target, environment, all)
Resolves domains, then expands any
*_URLvar into*_DOMAIN/*_SCHEME. - .build_task_env_vars(target, environment, all)
- .build_task_setup_commands(target, environment, all)
- .build_task_ssl_certificates(target, environment, all)
-
.decompose_urls(hash)
For every entry whose key ends with
_URL, derives sibling*_DOMAINand*_SCHEMEvars from the parsed URI and merges them in, so compose files can reference the parts separately. -
.find_matching_target(e, target)
A config entry applies to a target when its
target:is that string (or the wildcard"all"), or when it is an array that includes the target.
Macro Summary
-
define_method_array(name, klass, default_value, accessor, method)
Generates a resolver for an array-shaped attribute: same selection, but concatenates (globals first, then environment) instead of merging.
-
define_method_hash(name, klass, default_key, default_value, accessor, method)
Generates a resolver for a hash-shaped attribute: selects matching entries from
alland the environment, reduces each side withmerge, then merges the environment result over the globals.
Class Method Detail
Resolves every attribute for the given (target, environment) pair — with
all supplying the global defaults — and assembles the Task. The
executor is injectable so specs can capture output instead of shelling out.
Resolves the compose file list. Config-declared files are looked up under
squarectl/targets/common/, and the conventional base files
(base.yml, <target>/common.yml, <target>/<env>.yml) are always
prepended so they load first.
Resolves swarm config files. Keys are namespaced as
<app>-<envshort>__<key> and values resolved to absolute paths.
Resolves swarm secret files. Same namespacing and path resolution as
.build_task_deploy_configs.
The remote Docker host (DOCKER_HOST) for swarm deploys — the first
matching server entry's host, or empty when none is declared.
Resolves domains, then expands any *_URL var into *_DOMAIN/*_SCHEME.
For every entry whose key ends with _URL, derives sibling *_DOMAIN and
*_SCHEME vars from the parsed URI and merges them in, so compose files can
reference the parts separately. Non-_URL keys are left untouched, and a
_URL value missing a host or scheme is skipped rather than crashing.
A config entry applies to a target when its target: is that string (or
the wildcard "all"), or when it is an array that includes the target.
Macro Detail
Generates a resolver for an array-shaped attribute: same selection, but concatenates (globals first, then environment) instead of merging.
Generates a resolver for a hash-shaped attribute: selects matching entries
from all and the environment, reduces each side with merge, then merges
the environment result over the globals.