Class: Metatron::Templates::VolumeSnapshotContent
- Inherits:
-
Metatron::Template
- Object
- Metatron::Template
- Metatron::Templates::VolumeSnapshotContent
- Includes:
- Concerns::Annotated, Concerns::Namespaced
- Defined in:
- lib/metatron/templates/volume_snapshot_content.rb
Overview
The VolumeSnapshotContent Kubernetes resource
Instance Attribute Summary collapse
-
#deletion_policy ⇒ Object
(also: #deletionPolicy)
Returns the value of attribute deletion_policy.
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_volume_mode ⇒ Object
(also: #sourceVolumeMode)
Returns the value of attribute source_volume_mode.
-
#volume_snapshot_ref ⇒ Object
(also: #volumeSnapshotRef)
Returns the value of attribute volume_snapshot_ref.
Attributes inherited from Metatron::Template
#additional_labels, #api_version, #base_labels, #kind, #name
Instance Method Summary collapse
- #formatted_source ⇒ Object
- #formatted_volume_snapshot_ref ⇒ Object
-
#initialize(name, driver:, source: {}, deletion_policy: "Delete", volume_snapshot_ref: nil, source_volume_mode: "Filesystem") ⇒ VolumeSnapshotContent
constructor
A new instance of VolumeSnapshotContent.
- #render ⇒ Object
Methods included from Concerns::Namespaced
#formatted_namespace, included, #namespaced_initialize
Methods included from Concerns::Annotated
#annotated_initialize, #formatted_annotations, included
Methods inherited from Metatron::Template
initializer, initializers, metatron_template_class?, nearest_metatron_ancestor
Constructor Details
permalink #initialize(name, driver:, source: {}, deletion_policy: "Delete", volume_snapshot_ref: nil, source_volume_mode: "Filesystem") ⇒ VolumeSnapshotContent
Returns a new instance of VolumeSnapshotContent.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 16 def initialize(name, driver:, source: {}, deletion_policy: "Delete", volume_snapshot_ref: nil, source_volume_mode: "Filesystem") super(name) @api_version = "snapshot.storage.k8s.io/v1" @driver = driver @source = source @source_volume_mode = source_volume_mode @deletion_policy = deletion_policy @volume_snapshot_ref = volume_snapshot_ref end |
Instance Attribute Details
permalink #deletion_policy ⇒ Object Also known as: deletionPolicy
Returns the value of attribute deletion_policy.
10 11 12 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 10 def deletion_policy @deletion_policy end |
permalink #driver ⇒ Object
Returns the value of attribute driver.
10 11 12 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 10 def driver @driver end |
permalink #source ⇒ Object
Returns the value of attribute source.
10 11 12 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 10 def source @source end |
permalink #source_volume_mode ⇒ Object Also known as: sourceVolumeMode
Returns the value of attribute source_volume_mode.
10 11 12 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 10 def source_volume_mode @source_volume_mode end |
permalink #volume_snapshot_ref ⇒ Object Also known as: volumeSnapshotRef
Returns the value of attribute volume_snapshot_ref.
10 11 12 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 10 def volume_snapshot_ref @volume_snapshot_ref end |
Instance Method Details
permalink #formatted_source ⇒ Object
43 44 45 46 47 48 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 43 def formatted_source return {} unless source raise ArgumentError, "Invalid source type: #{source.class}." unless source.is_a?(Hash) { source: } end |
permalink #formatted_volume_snapshot_ref ⇒ Object
[View source]
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 50 def formatted_volume_snapshot_ref return {} unless volume_snapshot_ref if volume_snapshot_ref.is_a?(Hash) { volumeSnapshotRef: } elsif volume_snapshot_ref.is_a?(VolumeSnapshot) { volumeSnapshotRef: { name: volume_snapshot_ref.name, namespace: volume_snapshot_ref.namespace }.compact } else raise ArgumentError, "Invalid volume_snapshot_ref type: #{volume_snapshot_ref.class}." end end |
permalink #render ⇒ Object
[View source]
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/metatron/templates/volume_snapshot_content.rb', line 27 def render { apiVersion:, kind:, metadata: { name:, labels: base_labels.merge(additional_labels) }.merge(formatted_annotations).merge(formatted_namespace).compact, spec: { driver:, deletionPolicy:, sourceVolumeMode: }.merge(formatted_source).merge(formatted_volume_snapshot_ref).compact }.compact end |