metatron 0.1.8 → 0.1.9

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: 6a89ce9a5fa862d8312310581e5a57b0094bf49bc2934043f9b5578de66e519c
4
- data.tar.gz: ebf94d54cce8d9dc11f439731bec655ed5d943f1f77e47a79a788616cffc02f9
3
+ metadata.gz: 9904b986356c64a1f895a522baf591911fdd4bdce61d47d94b8db3a05148b11f
4
+ data.tar.gz: e5230c29009ef2cbf5c9721fa13ddfc65dad02114dfd4c8fd24e9d6873ae0d47
5
5
  SHA512:
6
- metadata.gz: 0ec004038d5ffa21bf0eed37f67079bbfd613dc844b7916713b1855ae5e09f2b10e7e54e1d3bdc4fa03ec3520628719d086d0fdb5eee25a79191817d47f50480
7
- data.tar.gz: 91db8671698f68bd9e1e42e2a9baa536daafa12e545d7bc1744b420580f7247929d8a025aed9f7d22800264dd21ec173745e3b0ebfd5c174c448b5fa92ab43d2
6
+ metadata.gz: 3886638f6f20c362c519e1ddf5fa1a5067bc00d038d37586c9fc11c5ff887a7f1518b957ef334ffeabe02cae7938f75732f6ef1f68941c80fe70f66c9bbc5804
7
+ data.tar.gz: 71b9e8ec7e997d71c4369caef8a6f45d74ee6e9120a01a6d8d5723057dd8c76d954cd879df94365050ae2bcf2786f2415578c32ec8d70eebe23049b79cc3a0d9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.1.8)
4
+ metatron (0.1.9)
5
5
  json (~> 2.6)
6
6
  puma (~> 6.3)
7
7
  sinatra (~> 2.2)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ module Concerns
6
+ # Makes supporting namespaced resources easier
7
+ module Namespaced
8
+ def self.included(base)
9
+ # base.extend ClassMethods
10
+ base.class_eval do
11
+ attr_accessor :namespace
12
+
13
+ initializer :namespaced_initialize
14
+ end
15
+ end
16
+
17
+ def namespaced_initialize
18
+ @namespace = nil
19
+ end
20
+
21
+ def formatted_namespace
22
+ if namespace
23
+ { namespace: namespace.is_a?(Namespace) ? namespace.name : namespace }
24
+ else
25
+ {}
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The ConfigMap Kubernetes resource
6
6
  class ConfigMap < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
 
9
10
  attr_accessor :additional_labels, :type, :data
10
11
 
@@ -21,7 +22,7 @@ module Metatron
21
22
  metadata: {
22
23
  name:,
23
24
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
24
- }.merge(formatted_annotations),
25
+ }.merge(formatted_annotations).merge(formatted_namespace),
25
26
  data:
26
27
  }
27
28
  end
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The DaemonSet Kubernetes resource
6
6
  class DaemonSet < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
  include Concerns::PodProducer
9
10
 
10
11
  attr_accessor :replicas, :additional_labels
@@ -23,7 +24,7 @@ module Metatron
23
24
  metadata: {
24
25
  name:,
25
26
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
26
- }.merge(formatted_annotations),
27
+ }.merge(formatted_annotations).merge(formatted_namespace),
27
28
  spec: {
28
29
  selector: {
29
30
  matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The Deployment Kubernetes resource
6
6
  class Deployment < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
  include Concerns::PodProducer
9
10
 
10
11
  attr_accessor :replicas, :additional_labels
@@ -34,7 +35,7 @@ module Metatron
34
35
  template: {
35
36
  metadata: {
36
37
  labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
37
- }.merge(formatted_pod_annotations),
38
+ }.merge(formatted_pod_annotations).merge(formatted_namespace),
38
39
  spec: {
39
40
  terminationGracePeriodSeconds:,
40
41
  containers: [
@@ -4,6 +4,8 @@ module Metatron
4
4
  module Templates
5
5
  # Template for basic Ingress k8s resource
6
6
  class Ingress < Template
7
+ include Concerns::Namespaced
8
+
7
9
  attr_accessor :ingress_class, :additional_labels, :additional_annotations, :rules, :tls,
8
10
  :cert_manager_cluster_issuer, :cert_manager_issuer, :cert_manager_challenge_type
9
11
 
@@ -76,7 +78,7 @@ module Metatron
76
78
  metadata: {
77
79
  name:,
78
80
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
79
- }.merge(formatted_annotations),
81
+ }.merge(formatted_annotations).merge(formatted_namespace),
80
82
  spec: formatted_rules.merge(formatted_tls)
81
83
  }
82
84
  end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # Template for basic Namespace k8s resource
6
+ class Namespace < Template
7
+ attr_accessor :additional_labels
8
+
9
+ def initialize(name)
10
+ super(name)
11
+ @additional_labels = {}
12
+ end
13
+
14
+ def render
15
+ {
16
+ apiVersion:,
17
+ kind:,
18
+ metadata: {
19
+ name:,
20
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
21
+ }.merge(formatted_annotations)
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The PersistentVolumeClaim Kubernetes resource
6
6
  class PersistentVolumeClaim < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
 
9
10
  attr_accessor :additional_labels, :storage_class, :access_modes, :storage
10
11
 
@@ -28,7 +29,7 @@ module Metatron
28
29
  metadata: {
29
30
  name:,
30
31
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
31
- }.merge(formatted_annotations),
32
+ }.merge(formatted_annotations).merge(formatted_namespace),
32
33
  spec: {
33
34
  accessModes: access_modes,
34
35
  storageClassName: storage_class,
@@ -6,6 +6,7 @@ module Metatron
6
6
  class Pod < Template
7
7
  include Concerns::Annotated
8
8
  include Concerns::PodProducer
9
+ include Concerns::Namespaced
9
10
 
10
11
  # rubocop:disable Metrics/MethodLength
11
12
  # rubocop:disable Metrics/AbcSize
@@ -16,7 +17,7 @@ module Metatron
16
17
  metadata: {
17
18
  labels: { "#{label_namespace}/name": name }.merge(additional_labels),
18
19
  name:
19
- }.merge(formatted_annotations),
20
+ }.merge(formatted_annotations).merge(formatted_namespace),
20
21
  spec: {
21
22
  terminationGracePeriodSeconds:,
22
23
  containers: [
@@ -6,6 +6,7 @@ module Metatron
6
6
  class ReplicaSet < Template
7
7
  include Concerns::Annotated
8
8
  include Concerns::PodProducer
9
+ include Concerns::Namespaced
9
10
 
10
11
  attr_accessor :replicas, :additional_labels
11
12
 
@@ -24,7 +25,7 @@ module Metatron
24
25
  metadata: {
25
26
  name:,
26
27
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
27
- }.merge(formatted_annotations),
28
+ }.merge(formatted_annotations).merge(formatted_namespace),
28
29
  spec: {
29
30
  replicas:,
30
31
  selector: {
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The Secret Kubernetes resource
6
6
  class Secret < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
 
9
10
  attr_accessor :additional_labels, :type, :data
10
11
 
@@ -22,7 +23,7 @@ module Metatron
22
23
  metadata: {
23
24
  name:,
24
25
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
- }.merge(formatted_annotations),
26
+ }.merge(formatted_annotations).merge(formatted_namespace),
26
27
  type:,
27
28
  stringData: data
28
29
  }
@@ -5,6 +5,7 @@ module Metatron
5
5
  # The Service Kubernetes resource
6
6
  class Service < Template
7
7
  include Concerns::Annotated
8
+ include Concerns::Namespaced
8
9
 
9
10
  attr_accessor :type, :selector, :additional_labels, :ports,
10
11
  :additional_selector_labels, :publish_not_ready_addresses
@@ -41,7 +42,7 @@ module Metatron
41
42
  metadata: {
42
43
  name:,
43
44
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
44
- }.merge(formatted_annotations),
45
+ }.merge(formatted_annotations).merge(formatted_namespace),
45
46
  spec: {
46
47
  type:,
47
48
  selector: selector.merge(additional_selector_labels),
@@ -6,6 +6,7 @@ module Metatron
6
6
  class StatefulSet < Template
7
7
  include Concerns::Annotated
8
8
  include Concerns::PodProducer
9
+ include Concerns::Namespaced
9
10
 
10
11
  attr_accessor :replicas, :service_name, :pod_management_policy, :enable_service_links
11
12
 
@@ -31,7 +32,7 @@ module Metatron
31
32
  metadata: {
32
33
  name:,
33
34
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
34
- }.merge(formatted_annotations),
35
+ }.merge(formatted_annotations).merge(formatted_namespace),
35
36
  spec: {
36
37
  replicas:,
37
38
  serviceName:,
@@ -4,6 +4,6 @@ module Metatron
4
4
  VERSION = [
5
5
  0, # major
6
6
  1, # minor
7
- 8 # patch
7
+ 9 # patch
8
8
  ].join(".")
9
9
  end
data/lib/metatron.rb CHANGED
@@ -26,11 +26,13 @@ end
26
26
  require "metatron/version"
27
27
  require "metatron/template"
28
28
  require "metatron/templates/concerns/annotated"
29
+ require "metatron/templates/concerns/namespaced"
29
30
  require "metatron/templates/concerns/pod_producer"
30
31
  require "metatron/templates/pod"
31
32
  require "metatron/templates/persistent_volume_claim"
32
33
  require "metatron/templates/deployment"
33
34
  require "metatron/templates/ingress"
35
+ require "metatron/templates/namespace"
34
36
  require "metatron/templates/replica_set"
35
37
  require "metatron/templates/config_map"
36
38
  require "metatron/templates/secret"
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.8
4
+ version: 0.1.9
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-07-26 00:00:00.000000000 Z
11
+ date: 2023-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -257,11 +257,13 @@ files:
257
257
  - lib/metatron/sync_controller.rb
258
258
  - lib/metatron/template.rb
259
259
  - lib/metatron/templates/concerns/annotated.rb
260
+ - lib/metatron/templates/concerns/namespaced.rb
260
261
  - lib/metatron/templates/concerns/pod_producer.rb
261
262
  - lib/metatron/templates/config_map.rb
262
263
  - lib/metatron/templates/daemon_set.rb
263
264
  - lib/metatron/templates/deployment.rb
264
265
  - lib/metatron/templates/ingress.rb
266
+ - lib/metatron/templates/namespace.rb
265
267
  - lib/metatron/templates/persistent_volume_claim.rb
266
268
  - lib/metatron/templates/pod.rb
267
269
  - lib/metatron/templates/replica_set.rb