metatron 0.1.2 → 0.1.4

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: b4b8fe90bd51b3fd43c1a56d3850ead7fc93cbef70d271a10aebc8c50a97d510
4
- data.tar.gz: c7f99d54b269782cd33ef70e530a09db84a7a5f26bf35039fab73cd4eabf6bf9
3
+ metadata.gz: 37a819a08c08352f187437129f83f9998a84ddf8519ca2b9b59f2e809c95f757
4
+ data.tar.gz: ff428cba5a1c1d80d4dff0b54a6e6da81b787c66dd83332fc6ead84c62a14ffd
5
5
  SHA512:
6
- metadata.gz: f1bae3e43187121b62d87316c3d988862c235c894bf07f058f04d817434332c44f5327cc17d62f2e2f6653b17cad4152d6f49f54cd90e5f97b026c812e72c906
7
- data.tar.gz: 9936e4e04b25cdf2d051940d4ededac2d2886ffc39ead1db011c19aba4d025b48dfcc237946c64c758983e2f3877e5c95b6c398c9811174352096e0801afce26
6
+ metadata.gz: b53f3d0572ded8a3f88c83501616fb67782e71bf8a54e504733461d468674b8f09ca2af67eba0c840708a47c3a6d803d004454a11941d8fb8f62a85592a74ee7
7
+ data.tar.gz: 6b371bff00705c714220a36062bca85038aa14344648de4ee7b9d030b2bd115552b24f6ae48625790c73d5c7886424afb8f3f2c01daf8673da49e20bb8891a32
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.2
1
+ 3.2.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.1.2)
4
+ metatron (0.1.4)
5
5
  json (~> 2.6)
6
6
  puma (~> 5.6)
7
7
  sinatra (~> 2.2)
@@ -37,7 +37,7 @@ GEM
37
37
  puma (5.6.5)
38
38
  nio4r (~> 2.0)
39
39
  racc (1.6.2)
40
- rack (2.2.6.2)
40
+ rack (2.2.6.3)
41
41
  rack-protection (2.2.4)
42
42
  rack
43
43
  rack-test (2.0.2)
@@ -61,26 +61,26 @@ GEM
61
61
  diff-lcs (>= 1.2.0, < 2.0)
62
62
  rspec-support (~> 3.12.0)
63
63
  rspec-support (3.12.0)
64
- rubocop (1.45.1)
64
+ rubocop (1.47.0)
65
65
  json (~> 2.3)
66
66
  parallel (~> 1.10)
67
67
  parser (>= 3.2.0.0)
68
68
  rainbow (>= 2.2.2, < 4.0)
69
69
  regexp_parser (>= 1.8, < 3.0)
70
70
  rexml (>= 3.2.5, < 4.0)
71
- rubocop-ast (>= 1.24.1, < 2.0)
71
+ rubocop-ast (>= 1.26.0, < 2.0)
72
72
  ruby-progressbar (~> 1.7)
73
73
  unicode-display_width (>= 2.4.0, < 3.0)
74
- rubocop-ast (1.26.0)
74
+ rubocop-ast (1.27.0)
75
75
  parser (>= 3.2.1.0)
76
- rubocop-capybara (2.17.0)
76
+ rubocop-capybara (2.17.1)
77
77
  rubocop (~> 1.41)
78
78
  rubocop-rake (0.6.0)
79
79
  rubocop (~> 1.0)
80
80
  rubocop-rspec (2.18.1)
81
81
  rubocop (~> 1.33)
82
82
  rubocop-capybara (~> 2.17)
83
- ruby-progressbar (1.11.0)
83
+ ruby-progressbar (1.13.0)
84
84
  ruby2_keywords (0.0.5)
85
85
  simplecov (0.22.0)
86
86
  docile (~> 1.1)
@@ -118,7 +118,7 @@ GEM
118
118
  tilt (~> 2.0)
119
119
  yard (~> 0.9, >= 0.9.24)
120
120
  thor (1.2.1)
121
- tilt (2.0.11)
121
+ tilt (2.1.0)
122
122
  unicode-display_width (2.4.2)
123
123
  webrick (1.7.0)
124
124
  yard (0.9.28)
@@ -126,6 +126,7 @@ GEM
126
126
 
127
127
  PLATFORMS
128
128
  arm64-darwin-21
129
+ arm64-darwin-22
129
130
  x86_64-linux
130
131
 
131
132
  DEPENDENCIES
@@ -144,4 +145,4 @@ DEPENDENCIES
144
145
  yard (~> 0.9)
145
146
 
146
147
  BUNDLED WITH
147
- 2.3.18
148
+ 2.4.6
@@ -11,7 +11,8 @@ module Metatron
11
11
  attr_accessor :image, :image_pull_policy, :additional_labels, :env, :envfrom,
12
12
  :resource_limits, :resource_requests, :probes, :ports, :security_context,
13
13
  :volume_mounts, :volumes, :additional_containers,
14
- :container_security_context, :affinity
14
+ :container_security_context, :affinity, :termination_grace_period_seconds,
15
+ :tolerations
15
16
 
16
17
  initializer :pod_producer_initialize
17
18
 
@@ -19,6 +20,7 @@ module Metatron
19
20
  alias_method :volumeMounts, :volume_mounts
20
21
  alias_method :securityContext, :security_context
21
22
  alias_method :environment, :env
23
+ alias_method :terminationGracePeriodSeconds, :termination_grace_period_seconds
22
24
  end
23
25
  end
24
26
 
@@ -38,11 +40,11 @@ module Metatron
38
40
  @container_security_context = {}
39
41
  @additional_containers = []
40
42
  @additional_labels = {}
43
+ @termination_grace_period_seconds = 60
44
+ @tolerations = []
41
45
  end
42
46
 
43
- def formatted_affinity
44
- affinity && !affinity.empty? ? { affinity: } : {}
45
- end
47
+ def formatted_affinity = affinity && !affinity.empty? ? { affinity: } : {}
46
48
 
47
49
  def formatted_environment
48
50
  env && !env.empty? ? { env: env.map { |k, v| { name: k, value: v } } } : {}
@@ -56,9 +58,7 @@ module Metatron
56
58
  end
57
59
  end
58
60
 
59
- def formatted_ports
60
- ports&.any? ? { ports: } : {}
61
- end
61
+ def formatted_ports = ports&.any? ? { ports: } : {}
62
62
 
63
63
  def formatted_security_context
64
64
  security_context && !security_context.empty? ? { securityContext: } : {}
@@ -72,13 +72,9 @@ module Metatron
72
72
  end
73
73
  end
74
74
 
75
- def formatted_volume_mounts
76
- volume_mounts&.any? ? { volumeMounts: } : {}
77
- end
78
-
79
- def formatted_volumes
80
- volumes&.any? ? { volumes: } : {}
81
- end
75
+ def formatted_tolerations = tolerations&.any? ? { tolerations: } : {}
76
+ def formatted_volume_mounts = volume_mounts&.any? ? { volumeMounts: } : {}
77
+ def formatted_volumes = volumes&.any? ? { volumes: } : {}
82
78
  end
83
79
  end
84
80
  end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The DaemonSet Kubernetes resource
6
+ class DaemonSet < Template
7
+ include Concerns::Annotated
8
+ include Concerns::PodProducer
9
+
10
+ attr_accessor :replicas, :pod_annotations,
11
+ :additional_labels, :additional_pod_labels
12
+
13
+ def initialize(name)
14
+ super(name)
15
+ @api_version = "apps/v1"
16
+ @kind = "DaemonSet"
17
+ @pod_annotations = {}
18
+ @additional_pod_labels = {}
19
+ end
20
+
21
+ def formatted_pod_annotations
22
+ pod_annotations && !pod_annotations.empty? ? { annotations: pod_annotations } : {}
23
+ end
24
+
25
+ # rubocop:disable Metrics/MethodLength
26
+ # rubocop:disable Metrics/AbcSize
27
+ def render
28
+ {
29
+ apiVersion:,
30
+ kind:,
31
+ metadata: {
32
+ name:,
33
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
34
+ }.merge(formatted_annotations),
35
+ spec: {
36
+ selector: {
37
+ matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
38
+ },
39
+ template: {
40
+ metadata: {
41
+ labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
42
+ }.merge(formatted_pod_annotations),
43
+ spec: {
44
+ terminationGracePeriodSeconds:,
45
+ containers: [
46
+ {
47
+ name: "app",
48
+ image:,
49
+ imagePullPolicy:,
50
+ stdin: true,
51
+ tty: true,
52
+ resources: { limits: resource_limits, requests: resource_requests }
53
+ }.merge(probes)
54
+ .merge(formatted_environment)
55
+ .merge(formatted_envfrom)
56
+ .merge(formatted_ports)
57
+ .merge(formatted_volume_mounts)
58
+ .merge(formatted_container_security_context)
59
+ ] + additional_containers
60
+ }.merge(formatted_volumes)
61
+ .merge(formatted_security_context)
62
+ .merge(formatted_tolerations)
63
+ }
64
+ }
65
+ }
66
+ end
67
+ # rubocop:enable Metrics/AbcSize
68
+ # rubocop:enable Metrics/MethodLength
69
+ end
70
+ end
71
+ end
@@ -44,6 +44,7 @@ module Metatron
44
44
  labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
45
45
  }.merge(formatted_pod_annotations),
46
46
  spec: {
47
+ terminationGracePeriodSeconds:,
47
48
  containers: [
48
49
  {
49
50
  name: "app",
@@ -59,7 +60,9 @@ module Metatron
59
60
  .merge(formatted_volume_mounts)
60
61
  .merge(formatted_container_security_context)
61
62
  ] + additional_containers
62
- }.merge(formatted_volumes).merge(formatted_security_context)
63
+ }.merge(formatted_volumes)
64
+ .merge(formatted_security_context)
65
+ .merge(formatted_tolerations)
63
66
  }
64
67
  }
65
68
  }
@@ -12,6 +12,7 @@ module Metatron
12
12
  @kind = "Pod"
13
13
  end
14
14
 
15
+ # rubocop:disable Metrics/MethodLength
15
16
  # rubocop:disable Metrics/AbcSize
16
17
  def render
17
18
  {
@@ -22,6 +23,7 @@ module Metatron
22
23
  name:
23
24
  }.merge(formatted_annotations),
24
25
  spec: {
26
+ terminationGracePeriodSeconds:,
25
27
  containers: [
26
28
  {
27
29
  name: "app",
@@ -37,10 +39,13 @@ module Metatron
37
39
  .merge(formatted_volume_mounts)
38
40
  .merge(formatted_container_security_context)
39
41
  ] + additional_containers
40
- }.merge(formatted_volumes).merge(formatted_security_context)
42
+ }.merge(formatted_volumes)
43
+ .merge(formatted_security_context)
44
+ .merge(formatted_tolerations)
41
45
  }
42
46
  end
43
47
  # rubocop:enable Metrics/AbcSize
48
+ # rubocop:enable Metrics/MethodLength
44
49
  end
45
50
  end
46
51
  end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The ReplicaSet Kubernetes resource
6
+ class ReplicaSet < Template
7
+ include Concerns::Annotated
8
+ include Concerns::PodProducer
9
+
10
+ attr_accessor :replicas, :pod_annotations,
11
+ :additional_labels, :additional_pod_labels
12
+
13
+ def initialize(name, replicas: 2)
14
+ super(name)
15
+ @api_version = "apps/v1"
16
+ @kind = "ReplicaSet"
17
+ @replicas = replicas
18
+ @pod_annotations = {}
19
+ @additional_pod_labels = {}
20
+ end
21
+
22
+ def formatted_pod_annotations
23
+ pod_annotations && !pod_annotations.empty? ? { annotations: pod_annotations } : {}
24
+ end
25
+
26
+ # rubocop:disable Metrics/MethodLength
27
+ # rubocop:disable Metrics/AbcSize
28
+ def render
29
+ {
30
+ apiVersion:,
31
+ kind:,
32
+ metadata: {
33
+ name:,
34
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
35
+ }.merge(formatted_annotations),
36
+ spec: {
37
+ replicas:,
38
+ selector: {
39
+ matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
40
+ },
41
+ template: {
42
+ metadata: {
43
+ labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
44
+ }.merge(formatted_pod_annotations),
45
+ spec: {
46
+ terminationGracePeriodSeconds:,
47
+ containers: [
48
+ {
49
+ name: "app",
50
+ image:,
51
+ imagePullPolicy:,
52
+ stdin: true,
53
+ tty: true,
54
+ resources: { limits: resource_limits, requests: resource_requests }
55
+ }.merge(probes)
56
+ .merge(formatted_environment)
57
+ .merge(formatted_envfrom)
58
+ .merge(formatted_ports)
59
+ .merge(formatted_volume_mounts)
60
+ .merge(formatted_container_security_context)
61
+ ] + additional_containers
62
+ }.merge(formatted_volumes)
63
+ .merge(formatted_security_context)
64
+ .merge(formatted_tolerations)
65
+ }
66
+ }
67
+ }
68
+ end
69
+ # rubocop:enable Metrics/AbcSize
70
+ # rubocop:enable Metrics/MethodLength
71
+ end
72
+ end
73
+ end
@@ -9,7 +9,7 @@ module Metatron
9
9
 
10
10
  attr_accessor :replicas, :pod_annotations, :service_name,
11
11
  :pod_management_policy, :enable_service_links,
12
- :termination_grace_period_seconds, :additional_pod_labels
12
+ :additional_pod_labels
13
13
 
14
14
  def initialize(name, replicas: 1)
15
15
  super(name)
@@ -21,12 +21,10 @@ module Metatron
21
21
  @additional_pod_labels = {}
22
22
  @enable_service_links = true
23
23
  @service_name = name
24
- @termination_grace_period_seconds = 60
25
24
  end
26
25
 
27
26
  alias enableServiceLinks enable_service_links
28
27
  alias podManagementPolicy pod_management_policy
29
- alias terminationGracePeriodSeconds termination_grace_period_seconds
30
28
  alias serviceName service_name
31
29
 
32
30
  def formatted_pod_annotations
@@ -74,6 +72,7 @@ module Metatron
74
72
  ] + additional_containers
75
73
  }.merge(formatted_volumes)
76
74
  .merge(formatted_affinity)
75
+ .merge(formatted_tolerations)
77
76
  }
78
77
  }
79
78
  }
@@ -4,6 +4,6 @@ module Metatron
4
4
  VERSION = [
5
5
  0, # major
6
6
  1, # minor
7
- 2 # patch
7
+ 4 # patch
8
8
  ].join(".")
9
9
  end
data/lib/metatron.rb CHANGED
@@ -30,6 +30,7 @@ require "metatron/templates/concerns/pod_producer"
30
30
  require "metatron/templates/pod"
31
31
  require "metatron/templates/deployment"
32
32
  require "metatron/templates/ingress"
33
+ require "metatron/templates/replica_set"
33
34
  require "metatron/templates/secret"
34
35
  require "metatron/templates/service"
35
36
  require "metatron/templates/stateful_set"
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.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-14 00:00:00.000000000 Z
11
+ date: 2023-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -258,9 +258,11 @@ files:
258
258
  - lib/metatron/template.rb
259
259
  - lib/metatron/templates/concerns/annotated.rb
260
260
  - lib/metatron/templates/concerns/pod_producer.rb
261
+ - lib/metatron/templates/daemon_set.rb
261
262
  - lib/metatron/templates/deployment.rb
262
263
  - lib/metatron/templates/ingress.rb
263
264
  - lib/metatron/templates/pod.rb
265
+ - lib/metatron/templates/replica_set.rb
264
266
  - lib/metatron/templates/secret.rb
265
267
  - lib/metatron/templates/service.rb
266
268
  - lib/metatron/templates/stateful_set.rb