lib/metatron/templates/concerns/pod_producer.rb in metatron-0.2.1 vs lib/metatron/templates/concerns/pod_producer.rb in metatron-0.2.2

- old
+ new

@@ -9,11 +9,11 @@ # base.extend ClassMethods base.class_eval do attr_accessor :additional_labels, :additional_pod_labels, :security_context, :volumes, :containers, :init_containers, :affinity, :termination_grace_period_seconds, - :tolerations, :pod_annotations + :tolerations, :pod_annotations, :persistent_volume_claims initializer :pod_producer_initialize alias_method :securityContext, :security_context alias_method :terminationGracePeriodSeconds, :termination_grace_period_seconds @@ -29,10 +29,11 @@ @additional_labels = {} @additional_pod_labels = {} @pod_annotations = {} @termination_grace_period_seconds = nil @tolerations = [] + @persistent_volume_claims = [] end def formatted_affinity = affinity && !affinity.empty? ? { affinity: } : {} def formatted_pod_annotations @@ -43,9 +44,21 @@ security_context && !security_context.empty? ? { securityContext: } : {} end def formatted_tolerations = tolerations&.any? ? { tolerations: } : {} def formatted_volumes = volumes&.any? ? { volumes: } : {} + + def volume_claim_templates + if persistent_volume_claims&.any? + { + volumeClaimTemplates: persistent_volume_claims.map do |c| + c.respond_to?(:render) ? c.render : c + end + } + else + {} + end + end end end end end