metatron 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2595e703b422eadf0c748386541eae93f9b447d74e2bd70160a85dc14c7f59a
4
- data.tar.gz: 599adf4652b4e2bbf35f86f95c083f6e6e03780d44fa563c83ca714c90aa3004
3
+ metadata.gz: 1c91b426279a0fdc0bc7403da99aad467346c6d9eed8ed662ba4224f51e35988
4
+ data.tar.gz: c9f9915e91f61eea3a78f8e201572f37ee24d74dc477e9678066f0b8225f9911
5
5
  SHA512:
6
- metadata.gz: fd16efd8685097c4fdb321de668cecb60ac24c0dab98e1e97ab40590007d524dfa9b0ba644174786d659a0fc6bc1225b48b62cb0ae2a1224e1503ee8a6aa40c7
7
- data.tar.gz: d0255911256d4e233f300b5a82dbeba91feeba7819d920bdd2e2e3c505a02b1b7343fdfc8ec938912bc4f650491ddfdc51efc007f7e57e58527ecf0665b07adf
6
+ metadata.gz: 2a3c97156c6dbd3aa2e368639825434be822d90a9bab663dfc8b19fee68fe45e2565ebc762c16381d5c3faeb1a4df91153d1e13302ffe9a18a9bcb1673b22067
7
+ data.tar.gz: dd31a78a1b92dcae20582921b33b0befc3560c43203b339f68617d736dc98cc358c4b4c8474d6f73f632eb1699857eba674ab578ede827bd6580ff8ca2478b5f
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ metatron-*.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.2.0)
4
+ metatron (0.2.2)
5
5
  json (~> 2.6)
6
6
  puma (~> 6.3)
7
7
  sinatra (~> 2.2)
@@ -18,7 +18,7 @@ module Metatron
18
18
  @name = name
19
19
  @label_namespace = self.class.label_namespace
20
20
  @api_version = "v1"
21
- @kind = self.class.name.split("::").last
21
+ @kind = find_kind
22
22
  run_initializers
23
23
  end
24
24
 
@@ -38,5 +38,15 @@ module Metatron
38
38
  def run_initializers
39
39
  self.class.initializers.each { |initializer| send(initializer.to_sym) }
40
40
  end
41
+
42
+ def find_kind
43
+ return self.class.name.split("::").last if metatron_template?
44
+
45
+ self.class.ancestors.find { |klass| metatron_template?(klass) }.name.split("::").last
46
+ end
47
+
48
+ def metatron_template?(klass = self)
49
+ klass.name.include?("Metatron::Templates") && !klass.name.include?("Concerns")
50
+ end
41
51
  end
42
52
  end
@@ -11,7 +11,7 @@ module Metatron
11
11
  attr_accessor :additional_labels, :additional_pod_labels,
12
12
  :security_context, :volumes, :containers, :init_containers,
13
13
  :affinity, :termination_grace_period_seconds,
14
- :tolerations, :pod_annotations
14
+ :tolerations, :pod_annotations, :persistent_volume_claims
15
15
 
16
16
  initializer :pod_producer_initialize
17
17
 
@@ -31,6 +31,7 @@ module Metatron
31
31
  @pod_annotations = {}
32
32
  @termination_grace_period_seconds = nil
33
33
  @tolerations = []
34
+ @persistent_volume_claims = []
34
35
  end
35
36
 
36
37
  def formatted_affinity = affinity && !affinity.empty? ? { affinity: } : {}
@@ -45,6 +46,18 @@ module Metatron
45
46
 
46
47
  def formatted_tolerations = tolerations&.any? ? { tolerations: } : {}
47
48
  def formatted_volumes = volumes&.any? ? { volumes: } : {}
49
+
50
+ def volume_claim_templates
51
+ if persistent_volume_claims&.any?
52
+ {
53
+ volumeClaimTemplates: persistent_volume_claims.map do |c|
54
+ c.respond_to?(:render) ? c.render : c
55
+ end
56
+ }
57
+ else
58
+ {}
59
+ end
60
+ end
48
61
  end
49
62
  end
50
63
  end
@@ -9,6 +9,9 @@ module Metatron
9
9
 
10
10
  attr_accessor :additional_labels, :storage_class, :access_modes, :storage
11
11
 
12
+ alias storageClassName storage_class
13
+ alias accessModes access_modes
14
+
12
15
  def initialize(
13
16
  name,
14
17
  storage_class:,
@@ -31,8 +34,8 @@ module Metatron
31
34
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
32
35
  }.merge(formatted_annotations).merge(formatted_namespace),
33
36
  spec: {
34
- accessModes: access_modes,
35
- storageClassName: storage_class,
37
+ accessModes:,
38
+ storageClassName:,
36
39
  resources: {
37
40
  requests: {
38
41
  storage:
@@ -55,7 +55,7 @@ module Metatron
55
55
  .compact
56
56
  }
57
57
  }
58
- }
58
+ }.merge(volume_claim_templates)
59
59
  end
60
60
  # rubocop:enable Metrics/AbcSize
61
61
  # rubocop:enable Metrics/MethodLength
@@ -4,6 +4,6 @@ module Metatron
4
4
  VERSION = [
5
5
  0, # major
6
6
  2, # minor
7
- 0 # patch
7
+ 2 # patch
8
8
  ].join(".")
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy