class Squarectl::TaskFactory

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.cr

Class Method Summary

Macro Summary

Class Method Detail

def self._build_task_compose_files(target, environment, all) #

[View source]
def self._build_task_compose_networks(target, environment, all) #

[View source]
def self._build_task_domains(target, environment, all) #

[View source]
def self._build_task_env_vars(target, environment, all) #

[View source]
def self._build_task_ssl_certificates(target, environment, all) #

[View source]
def self.build(target, environment, all, executor = Executor.new) #

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.


[View source]
def self.build_task_compose_files(target, environment, all) #

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.


[View source]
def self.build_task_compose_networks(target, environment, all) #

[View source]
def self.build_task_deploy_configs(target, environment, all) #

Resolves swarm config files. Keys are namespaced as <app>-<envshort>__<key> and values resolved to absolute paths.


[View source]
def self.build_task_deploy_secrets(target, environment, all) #

Resolves swarm secret files. Same namespacing and path resolution as .build_task_deploy_configs.


[View source]
def self.build_task_deploy_server(target, environment, all) #

The remote Docker host (DOCKER_HOST) for swarm deploys — the first matching server entry's host, or empty when none is declared.


[View source]
def self.build_task_domains(target, environment, all) #

Resolves domains, then expands any *_URL var into *_DOMAIN/*_SCHEME.


[View source]
def self.build_task_env_vars(target, environment, all) #

[View source]
def self.build_task_setup_commands(target, environment, all) #

[View source]
def self.build_task_ssl_certificates(target, environment, all) #

[View source]
def self.decompose_urls(hash) #

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.


[View source]
def self.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.


[View source]

Macro Detail

macro 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.


[View source]
macro define_method_hash(name, klass, default_key, default_value, accessor, method) #

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.


[View source]