metatron 0.10.1 → 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 +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +20 -0
- data/Gemfile.lock +5 -3
- data/lib/metatron/templates/secret.rb +27 -5
- data/lib/metatron/templates/service.rb +5 -2
- data/lib/metatron/templates/volume_snapshot.rb +64 -0
- data/lib/metatron/templates/volume_snapshot_content.rb +69 -0
- data/lib/metatron/version.rb +1 -1
- data/lib/metatron.rb +5 -0
- data/metatron.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 637a01440642c97b47387f9de1865755b910c2ea65a875942fb1a93baf222092
|
4
|
+
data.tar.gz: 6a490b15624d363fb64099c8b8218e5814a2d0b4a263391f11441d409cce21da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 817b348a265c5f447614e4e7cfb486ddc8fa9f95225f3750a2f0beb5ecd13c5fac252b3d82a3a941d52db472055897acb1202702f7279b3b56cfaa88c8aafa07
|
7
|
+
data.tar.gz: 1e3178a2e560588fe36cf8c933862805f07facd1e583f71edbb872bd1075c6cd650c3c49e4334a5a0a3261c469c0960a171b47ea6b9b0eca655ada86f289dd24
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,25 @@
|
|
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
|
+
|
10
|
+
## [0.11.0](https://github.com/jgnagy/metatron/compare/metatron/v0.10.1...metatron/v0.11.0) (2025-03-28)
|
11
|
+
|
12
|
+
|
13
|
+
### ⚠ BREAKING CHANGES
|
14
|
+
|
15
|
+
* **templates:** secret now base64 encodes
|
16
|
+
* **templates:** omit attribute when default
|
17
|
+
|
18
|
+
### Code Refactoring
|
19
|
+
|
20
|
+
* **templates:** omit attribute when default ([0add60c](https://github.com/jgnagy/metatron/commit/0add60c5ef9faca5e1c7be050415ef3a1f15227b))
|
21
|
+
* **templates:** secret now base64 encodes ([3d263ec](https://github.com/jgnagy/metatron/commit/3d263ec85b9d7e87b987c2fcf4c6fc9664eb84d6))
|
22
|
+
|
3
23
|
## [0.10.1](https://github.com/jgnagy/metatron/compare/metatron/v0.10.0...metatron/v0.10.1) (2025-03-21)
|
4
24
|
|
5
25
|
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
metatron (0.
|
4
|
+
metatron (0.11.1)
|
5
|
+
base64
|
5
6
|
json (~> 2.6)
|
6
7
|
rack (>= 2.2.8, < 4)
|
7
8
|
|
@@ -10,6 +11,7 @@ GEM
|
|
10
11
|
specs:
|
11
12
|
ast (2.4.2)
|
12
13
|
backport (1.2.0)
|
14
|
+
base64 (0.2.0)
|
13
15
|
benchmark (0.4.0)
|
14
16
|
byebug (11.1.3)
|
15
17
|
diff-lcs (1.6.0)
|
@@ -23,9 +25,9 @@ GEM
|
|
23
25
|
language_server-protocol (3.17.0.4)
|
24
26
|
lint_roller (1.1.0)
|
25
27
|
logger (1.6.6)
|
26
|
-
nokogiri (1.18.
|
28
|
+
nokogiri (1.18.4-arm64-darwin)
|
27
29
|
racc (~> 1.4)
|
28
|
-
nokogiri (1.18.
|
30
|
+
nokogiri (1.18.4-x86_64-linux-gnu)
|
29
31
|
racc (~> 1.4)
|
30
32
|
observer (0.1.2)
|
31
33
|
ostruct (0.6.1)
|
@@ -7,15 +7,38 @@ module Metatron
|
|
7
7
|
include Concerns::Annotated
|
8
8
|
include Concerns::Namespaced
|
9
9
|
|
10
|
-
attr_accessor :additional_labels, :type, :data
|
10
|
+
attr_accessor :additional_labels, :type, :data, :string_data
|
11
11
|
|
12
|
-
|
12
|
+
alias stringData string_data
|
13
|
+
|
14
|
+
def initialize(name, provided_string_data = nil, string_data: nil, data: nil)
|
13
15
|
super(name)
|
16
|
+
@string_data = string_data || provided_string_data
|
14
17
|
@data = data
|
15
18
|
@additional_labels = {}
|
16
19
|
@type = "Opaque"
|
17
20
|
end
|
18
21
|
|
22
|
+
def formatted_data
|
23
|
+
data_hash = {}
|
24
|
+
|
25
|
+
# Only include one of data or string_data, preferring data if both are present
|
26
|
+
return data_hash unless data || string_data
|
27
|
+
|
28
|
+
# If string_data is provided, it should be a hash of string values
|
29
|
+
# and will be base64 encoded
|
30
|
+
if string_data
|
31
|
+
data_hash[:data] = string_data.transform_values do |value|
|
32
|
+
Base64.strict_encode64(value.to_s).gsub("\n", "")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# If data is provided, it should be a hash of base64 encoded values
|
37
|
+
data_hash[:data] = data if data
|
38
|
+
|
39
|
+
data_hash
|
40
|
+
end
|
41
|
+
|
19
42
|
def render
|
20
43
|
{
|
21
44
|
apiVersion:,
|
@@ -24,9 +47,8 @@ module Metatron
|
|
24
47
|
name:,
|
25
48
|
labels: base_labels.merge(additional_labels)
|
26
49
|
}.merge(formatted_annotations).merge(formatted_namespace).compact,
|
27
|
-
type
|
28
|
-
|
29
|
-
}.compact
|
50
|
+
type:
|
51
|
+
}.compact.merge(formatted_data).compact
|
30
52
|
end
|
31
53
|
end
|
32
54
|
end
|
@@ -40,6 +40,10 @@ module Metatron
|
|
40
40
|
ports&.any? ? { ports: } : {}
|
41
41
|
end
|
42
42
|
|
43
|
+
def formatted_publish_not_ready_addresses
|
44
|
+
publish_not_ready_addresses ? { publishNotReadyAddresses: } : {}
|
45
|
+
end
|
46
|
+
|
43
47
|
def render
|
44
48
|
{
|
45
49
|
apiVersion:,
|
@@ -51,9 +55,8 @@ module Metatron
|
|
51
55
|
spec: {
|
52
56
|
type:,
|
53
57
|
selector: selector.merge(additional_selector_labels),
|
54
|
-
publishNotReadyAddresses:,
|
55
58
|
clusterIP:
|
56
|
-
}.compact.merge(formatted_ports)
|
59
|
+
}.compact.merge(formatted_ports).merge(formatted_publish_not_ready_addresses)
|
57
60
|
}
|
58
61
|
end
|
59
62
|
end
|
@@ -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
|
data/lib/metatron/version.rb
CHANGED
data/lib/metatron.rb
CHANGED
@@ -6,6 +6,9 @@ require "securerandom"
|
|
6
6
|
require "time"
|
7
7
|
require "logger"
|
8
8
|
|
9
|
+
# external requirements
|
10
|
+
require "base64"
|
11
|
+
|
9
12
|
# The top-level module for Metatron
|
10
13
|
module Metatron
|
11
14
|
class Error < StandardError; end
|
@@ -44,6 +47,8 @@ require "metatron/templates/secret"
|
|
44
47
|
require "metatron/templates/service"
|
45
48
|
require "metatron/templates/service_account"
|
46
49
|
require "metatron/templates/stateful_set"
|
50
|
+
require "metatron/templates/volume_snapshot"
|
51
|
+
require "metatron/templates/volume_snapshot_content"
|
47
52
|
require "metatron/controller"
|
48
53
|
require "metatron/composite_controller"
|
49
54
|
require "metatron/controllers/ping"
|
data/metatron.gemspec
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metatron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 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-
|
11
|
+
date: 2025-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: base64
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: json
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,6 +281,8 @@ files:
|
|
267
281
|
- lib/metatron/templates/service.rb
|
268
282
|
- lib/metatron/templates/service_account.rb
|
269
283
|
- lib/metatron/templates/stateful_set.rb
|
284
|
+
- lib/metatron/templates/volume_snapshot.rb
|
285
|
+
- lib/metatron/templates/volume_snapshot_content.rb
|
270
286
|
- lib/metatron/version.rb
|
271
287
|
- metatron.gemspec
|
272
288
|
- release-please-config.json
|