Class: TerraformConfig::Workload
- Defined in:
- lib/core/terraform_config/workload.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- RAW_ARGS =
%i[ containers options local_options rollout_options security_options firewall_spec load_balancer job ].freeze
- OPTIONS_KEYS =
%i[autoscaling capacity_ai suspend timeout_seconds].freeze
- LOCAL_OPTIONS_KEYS =
(OPTIONS_KEYS + %i[location]).freeze
- ROLLOUT_OPTIONS_KEYS =
%i[min_ready_seconds max_unavailable_replicas max_surge_replicas scaling_policy].freeze
- SECURITY_OPTIONS_KEYS =
%i[file_system_group_id].freeze
- LOAD_BALANCER_KEYS =
%i[direct geo_location].freeze
- FIREWALL_SPEC_KEYS =
%i[internal external].freeze
- VOLUME_KEYS =
%i[uri path].freeze
- JOB_KEYS =
%i[schedule concurrency_policy history_limit restart_policy active_deadline_seconds].freeze
- LIVENESS_PROBE_KEYS =
%i[ exec http_get tcp_socket grpc failure_threshold initial_delay_seconds period_seconds success_threshold timeout_seconds ].freeze
Constants included from Dsl
Instance Attribute Summary collapse
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#firewall_spec ⇒ Object
readonly
Returns the value of attribute firewall_spec.
-
#gvc ⇒ Object
readonly
Returns the value of attribute gvc.
-
#identity_link ⇒ Object
readonly
Returns the value of attribute identity_link.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#load_balancer ⇒ Object
readonly
Returns the value of attribute load_balancer.
-
#local_options ⇒ Object
readonly
Returns the value of attribute local_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#rollout_options ⇒ Object
readonly
Returns the value of attribute rollout_options.
-
#security_options ⇒ Object
readonly
Returns the value of attribute security_options.
-
#support_dynamic_tags ⇒ Object
readonly
Returns the value of attribute support_dynamic_tags.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #importable? ⇒ Boolean
-
#initialize(type:, gvc:, name:, containers:, description: nil, tags: nil, support_dynamic_tags: false, firewall_spec: nil, identity_link: nil, options: nil, local_options: nil, rollout_options: nil, security_options: nil, load_balancer: nil, job: nil) ⇒ Workload
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #locals ⇒ Object
- #reference ⇒ Object
- #to_tf ⇒ Object
Methods included from Dsl
Constructor Details
#initialize(type:, gvc:, name:, containers:, description: nil, tags: nil, support_dynamic_tags: false, firewall_spec: nil, identity_link: nil, options: nil, local_options: nil, rollout_options: nil, security_options: nil, load_balancer: nil, job: nil) ⇒ Workload
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/core/terraform_config/workload.rb', line 27 def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength type:, gvc:, name:, containers:, description: nil, tags: nil, support_dynamic_tags: false, firewall_spec: nil, identity_link: nil, options: nil, local_options: nil, rollout_options: nil, security_options: nil, load_balancer: nil, job: nil ) super() @type = type @gvc = gvc @name = name @description = description @tags = @containers = containers @firewall_spec = firewall_spec @identity_link = identity_link @options = @local_options = @rollout_options = @security_options = @load_balancer = load_balancer @support_dynamic_tags = @job = job end |
Instance Attribute Details
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def containers @containers end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def description @description end |
#firewall_spec ⇒ Object (readonly)
Returns the value of attribute firewall_spec.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def firewall_spec @firewall_spec end |
#gvc ⇒ Object (readonly)
Returns the value of attribute gvc.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def gvc @gvc end |
#identity_link ⇒ Object (readonly)
Returns the value of attribute identity_link.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def identity_link @identity_link end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def job @job end |
#load_balancer ⇒ Object (readonly)
Returns the value of attribute load_balancer.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def load_balancer @load_balancer end |
#local_options ⇒ Object (readonly)
Returns the value of attribute local_options.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @local_options end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @options end |
#rollout_options ⇒ Object (readonly)
Returns the value of attribute rollout_options.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @rollout_options end |
#security_options ⇒ Object (readonly)
Returns the value of attribute security_options.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @security_options end |
#support_dynamic_tags ⇒ Object (readonly)
Returns the value of attribute support_dynamic_tags.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @support_dynamic_tags end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
23 24 25 |
# File 'lib/core/terraform_config/workload.rb', line 23 def type @type end |
Instance Method Details
#importable? ⇒ Boolean
67 68 69 |
# File 'lib/core/terraform_config/workload.rb', line 67 def importable? true end |
#locals ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/core/terraform_config/workload.rb', line 89 def locals containers.reduce({}) do |result, container| envs = container[:env].to_h { |env_var| [env_var[:name], env_var[:value]] } next result if envs.empty? envs_name = :"#{container.fetch(:name)}_envs" result.merge("#{envs_name}.tf" => LocalVariable.new(envs_name => envs)) end end |
#reference ⇒ Object
71 72 73 |
# File 'lib/core/terraform_config/workload.rb', line 71 def reference "module.#{name}.cpln_workload.workload" end |
#to_tf ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/core/terraform_config/workload.rb', line 75 def to_tf block :module, name do argument :source, "../workload" argument :type, type argument :name, name argument :gvc, gvc argument :identity_link, identity_link, optional: true argument :support_dynamic_tags, , optional: true RAW_ARGS.each { |arg_name| argument arg_name, send(:"#{arg_name}_arg"), raw: true, optional: true } end end |