metatron 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e624bf8ef1365843b3a1af54bdb89b377776358f84693d7f1a2dad737494393
4
- data.tar.gz: e6c7576f3b2a6d3ca1d81aa1a6ee3295ae7d19811854173eb3e850343d34b19f
3
+ metadata.gz: 637a01440642c97b47387f9de1865755b910c2ea65a875942fb1a93baf222092
4
+ data.tar.gz: 6a490b15624d363fb64099c8b8218e5814a2d0b4a263391f11441d409cce21da
5
5
  SHA512:
6
- metadata.gz: 3c1002350e83eb88f492b81930bde8636dd7de7ff7b21abb28b1f1d719ebc8f07e334495270d5440bcf92f8af5493add44a6d9e852e42eda6cde4efa52e734c4
7
- data.tar.gz: 3628be437221e7d0608afd2944510bc05f65a5d388feb01fd044d3f0c24f6d84e7788360b04286525a4bddc90697246f9611f4ab693c39544062cac21d1245c5
6
+ metadata.gz: 817b348a265c5f447614e4e7cfb486ddc8fa9f95225f3750a2f0beb5ecd13c5fac252b3d82a3a941d52db472055897acb1202702f7279b3b56cfaa88c8aafa07
7
+ data.tar.gz: 1e3178a2e560588fe36cf8c933862805f07facd1e583f71edbb872bd1075c6cd650c3c49e4334a5a0a3261c469c0960a171b47ea6b9b0eca655ada86f289dd24
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.11.0"
2
+ ".": "0.11.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.1](https://github.com/jgnagy/metatron/compare/metatron/v0.11.0...metatron/v0.11.1) (2025-04-11)
4
+
5
+
6
+ ### Features
7
+
8
+ * **templates:** add volume snapshot and content ([b969ce6](https://github.com/jgnagy/metatron/commit/b969ce6dc93503eb08c15d72356691acf88f7db9))
9
+
3
10
  ## [0.11.0](https://github.com/jgnagy/metatron/compare/metatron/v0.10.1...metatron/v0.11.0) (2025-03-28)
4
11
 
5
12
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.11.0)
4
+ metatron (0.11.1)
5
5
  base64
6
6
  json (~> 2.6)
7
7
  rack (>= 2.2.8, < 4)
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The VolumeSnapshot Kubernetes resource
6
+ class VolumeSnapshot < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :source, :volume_snapshot_class_name
11
+
12
+ alias volumeSnapshotClassName volume_snapshot_class_name
13
+
14
+ def initialize(name, source: {}, volume_snapshot_class_name: nil)
15
+ super(name)
16
+ @source = source
17
+ @volume_snapshot_class_name = volume_snapshot_class_name
18
+ @api_version = "snapshot.storage.k8s.io/v1"
19
+ end
20
+
21
+ def render
22
+ {
23
+ apiVersion:,
24
+ kind:,
25
+ metadata: {
26
+ name:,
27
+ labels: base_labels.merge(additional_labels)
28
+ }.merge(formatted_annotations).merge(formatted_namespace).compact,
29
+ spec: {}.merge(formatted_source).merge(formatted_volume_snapshot_class_name).compact
30
+ }.compact
31
+ end
32
+
33
+ def formatted_source
34
+ case source
35
+ when Hash
36
+ { source: }
37
+ when Metatron::Templates::VolumeSnapshotContent
38
+ { source: { volumeSnapshotContentName: source.name } }
39
+ when Metatron::Templates::PersistentVolumeClaim
40
+ { source: { persistentVolumeClaimName: source.name } }
41
+ when nil
42
+ {}
43
+ else
44
+ raise ArgumentError,
45
+ "Invalid source type: #{source.class}. " \
46
+ "Expected Hash, VolumeSnapshotContent, or PersistentVolumeClaim."
47
+ end
48
+ end
49
+
50
+ def formatted_volume_snapshot_class_name
51
+ return {} unless volume_snapshot_class_name
52
+
53
+ if volume_snapshot_class_name.is_a?(String)
54
+ { volumeSnapshotClassName: }
55
+ elsif volume_snapshot_class_name.respond_to?(:name)
56
+ { volumeSnapshotClassName: volume_snapshot_class_name.name }
57
+ else
58
+ raise ArgumentError,
59
+ "Invalid volume_snapshot_class_name type: #{volume_snapshot_class_name.class}."
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The VolumeSnapshotContent Kubernetes resource
6
+ class VolumeSnapshotContent < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :source, :deletion_policy, :driver, :source_volume_mode, :volume_snapshot_ref
11
+
12
+ alias deletionPolicy deletion_policy
13
+ alias sourceVolumeMode source_volume_mode
14
+ alias volumeSnapshotRef volume_snapshot_ref
15
+
16
+ def initialize(name, driver:, source: {}, deletion_policy: "Delete",
17
+ volume_snapshot_ref: nil, source_volume_mode: "Filesystem")
18
+ super(name)
19
+ @api_version = "snapshot.storage.k8s.io/v1"
20
+ @driver = driver
21
+ @source = source
22
+ @source_volume_mode = source_volume_mode
23
+ @deletion_policy = deletion_policy
24
+ @volume_snapshot_ref = volume_snapshot_ref
25
+ end
26
+
27
+ def render
28
+ {
29
+ apiVersion:,
30
+ kind:,
31
+ metadata: {
32
+ name:,
33
+ labels: base_labels.merge(additional_labels)
34
+ }.merge(formatted_annotations).merge(formatted_namespace).compact,
35
+ spec: {
36
+ driver:,
37
+ deletionPolicy:,
38
+ sourceVolumeMode:
39
+ }.merge(formatted_source).merge(formatted_volume_snapshot_ref).compact
40
+ }.compact
41
+ end
42
+
43
+ def formatted_source
44
+ return {} unless source
45
+ raise ArgumentError, "Invalid source type: #{source.class}." unless source.is_a?(Hash)
46
+
47
+ { source: }
48
+ end
49
+
50
+ def formatted_volume_snapshot_ref
51
+ return {} unless volume_snapshot_ref
52
+
53
+ if volume_snapshot_ref.is_a?(Hash)
54
+ { volumeSnapshotRef: }
55
+ elsif volume_snapshot_ref.is_a?(VolumeSnapshot)
56
+ {
57
+ volumeSnapshotRef: {
58
+ name: volume_snapshot_ref.name,
59
+ namespace: volume_snapshot_ref.namespace
60
+ }.compact
61
+ }
62
+ else
63
+ raise ArgumentError,
64
+ "Invalid volume_snapshot_ref type: #{volume_snapshot_ref.class}."
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metatron
4
- VERSION = "0.11.0"
4
+ VERSION = "0.11.1"
5
5
  end
data/lib/metatron.rb CHANGED
@@ -47,6 +47,8 @@ require "metatron/templates/secret"
47
47
  require "metatron/templates/service"
48
48
  require "metatron/templates/service_account"
49
49
  require "metatron/templates/stateful_set"
50
+ require "metatron/templates/volume_snapshot"
51
+ require "metatron/templates/volume_snapshot_content"
50
52
  require "metatron/controller"
51
53
  require "metatron/composite_controller"
52
54
  require "metatron/controllers/ping"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-28 00:00:00.000000000 Z
11
+ date: 2025-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -281,6 +281,8 @@ files:
281
281
  - lib/metatron/templates/service.rb
282
282
  - lib/metatron/templates/service_account.rb
283
283
  - lib/metatron/templates/stateful_set.rb
284
+ - lib/metatron/templates/volume_snapshot.rb
285
+ - lib/metatron/templates/volume_snapshot_content.rb
284
286
  - lib/metatron/version.rb
285
287
  - metatron.gemspec
286
288
  - release-please-config.json