# @summary Global defaults for defined resource types. # # @param worker_work_dir # Default work dir for each worker # @param default_cluster # Cluster used by all resources if no specific cluster is specified. # @param worker_service # Name of the the system service for workers. # @param clusters # Hash from cluster name to default values for each cluster. # Each key should be the name of a cluster, and the options are as follows: # @option clusters :external_domain # @option clusters :postgres_user # @option clusters :postgres_password # @option clusters :session_signing_key # @option clusters :tsa_private_key # @option clusters :tsa_public_key # @option clusters :db_name class concourse ( String $default_cluster, String $worker_work_dir = '/opt/concourse/worker', String $worker_service = 'concourse-worker', Hash[String, Hash[String, Any]] $clusters = {}, ) { # Merge all configured clusters we find in hiera, and append those # explicitly added to the class. $configured_clusters_ = lookup('concourse::clusters', { merge => 'hash', default_value => {}, }) + $clusters # Populate each configured cluster with some default values. $populated_clusters_ = $configured_clusters_.map |$cluster_name, $opts| { # Defaults need to be declared *inside* the loop, since they may # depend on other values in the configuration. $cluster_defaults = { 'db_name' => "atc-${cluster_name}", 'postgres_user' => 'concourse', } $finalized_opts = $cluster_defaults.keys().reduce($opts) |$opts, $key| { if $key in $opts { $opts } else { $opts + { $key => $cluster_defaults[$key] } } } [$cluster_name, $finalized_opts] } # This variable is the "exported" item other resources should look at to get # cluster default configuration. $configured_clusters = Hash($populated_clusters_) }