Class: TerraformConfig::Policy
- Defined in:
- lib/core/terraform_config/policy.rb
Overview
rubocop:disable Metrics/ClassLength
Constant Summary collapse
- TARGET_KINDS =
%w[ agent auditctx cloudaccount domain group gvc identity image ipset kubernetes location org policy quota secret serviceaccount task user volumeset workload ].freeze
- GVC_REQUIRED_TARGET_KINDS =
%w[identity workload volumeset].freeze
Constants included from Dsl
Instance Attribute Summary collapse
-
#bindings ⇒ Object
readonly
Returns the value of attribute bindings.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#gvc ⇒ Object
readonly
Returns the value of attribute gvc.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#target_kind ⇒ Object
readonly
Returns the value of attribute target_kind.
-
#target_links ⇒ Object
readonly
Returns the value of attribute target_links.
-
#target_query ⇒ Object
readonly
Returns the value of attribute target_query.
Instance Method Summary collapse
- #importable? ⇒ Boolean
-
#initialize(name:, description: nil, tags: nil, target_kind: nil, gvc: nil, target: nil, target_links: nil, target_query: nil, bindings: nil) ⇒ Policy
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #reference ⇒ Object
- #to_tf ⇒ Object
Methods inherited from Base
Methods included from Dsl
Constructor Details
#initialize(name:, description: nil, tags: nil, target_kind: nil, gvc: nil, target: nil, target_links: nil, target_query: nil, bindings: nil) ⇒ Policy
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/core/terraform_config/policy.rb', line 14 def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength name:, description: nil, tags: nil, target_kind: nil, gvc: nil, target: nil, target_links: nil, target_query: nil, bindings: nil ) super() @name = name @description = description @tags = @target_kind = target_kind validate_target_kind! @gvc = gvc validate_gvc! @target = target @target_links = target_links @target_query = target_query&.deep_underscore_keys&.deep_symbolize_keys @bindings = bindings&.map { |data| data.deep_underscore_keys.deep_symbolize_keys } end |
Instance Attribute Details
#bindings ⇒ Object (readonly)
Returns the value of attribute bindings.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def bindings @bindings end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def description @description end |
#gvc ⇒ Object (readonly)
Returns the value of attribute gvc.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def gvc @gvc end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def name @name end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def @tags end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def target @target end |
#target_kind ⇒ Object (readonly)
Returns the value of attribute target_kind.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def target_kind @target_kind end |
#target_links ⇒ Object (readonly)
Returns the value of attribute target_links.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def target_links @target_links end |
#target_query ⇒ Object (readonly)
Returns the value of attribute target_query.
12 13 14 |
# File 'lib/core/terraform_config/policy.rb', line 12 def target_query @target_query end |
Instance Method Details
#importable? ⇒ Boolean
44 45 46 |
# File 'lib/core/terraform_config/policy.rb', line 44 def importable? true end |
#reference ⇒ Object
48 49 50 |
# File 'lib/core/terraform_config/policy.rb', line 48 def reference "cpln_policy.#{name}" end |
#to_tf ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/core/terraform_config/policy.rb', line 52 def to_tf block :resource, :cpln_policy, name do argument :name, name %i[description tags target_kind gvc target target_links].each do |arg_name| argument arg_name, send(arg_name), optional: true end bindings_tf target_query_tf end end |