metatron 0.6.0 → 0.7.0

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: 4dee81a42c5ec6246f3d6a8e9399040dadd9d129b38f1b8b807671f89952fbc9
4
- data.tar.gz: 1eb701979a19633f39251635b34aaefc6355ddc6174671e68bab40c6ad7216a3
3
+ metadata.gz: ce0057cd5b89a1b677248f3401987bafe4fb33bba5c5fe0b89dfd22272c1b559
4
+ data.tar.gz: 520b31ebea42dca62172db9f30884eb648a015ece3498f26bacfbe408a1d114b
5
5
  SHA512:
6
- metadata.gz: 70ae144a7cc7ed33b0c623cc93045439f3b78c4d4e95ee85da2c6bef23aa41c3cb7c0bde2fb4ef51becf7a794b7e8e2899919c9817e54f3f83027a5b51b5e020
7
- data.tar.gz: 627ccee22056a72d03f04e1150d3f3d315350942e5b6f44d07861e17afd051782444922fd04ac9d71c55fe75472794c45cddc2b12144daf4285713d79b91d916
6
+ metadata.gz: f3265a4f7dfa3e3d318063a08455a62a12aaab8fb07c122884af4ebe9705d23741537438324904ab7dfe71fa37388e420913205daf1d0816884cde439a4888bb
7
+ data.tar.gz: 46c81f307d87486f1fadaf2a929032b70b0803cd13b08118410b2a9ca6c8ccdb64903c3e2cc45a73777fcd5f6463a188dd412cf885b7eccc901d7bc0363f1f2a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.6.0)
4
+ metatron (0.7.0)
5
5
  json (~> 2.6)
6
6
  rack (>= 2.2.8, < 4)
7
7
 
data/Rakefile CHANGED
@@ -23,6 +23,7 @@ task :bump, [:type] do |_t, args|
23
23
  new_version = calculate_new_version(type)
24
24
  puts "Bumping gem version from #{current_version} to #{new_version}"
25
25
  update_version(new_version)
26
+ update_gem_lock
26
27
  end
27
28
 
28
29
  task default: %i[spec rubocop yard]
@@ -44,6 +45,10 @@ def calculate_new_version(type)
44
45
  version.join(".")
45
46
  end
46
47
 
48
+ def update_gem_lock
49
+ system("bundle lock --update")
50
+ end
51
+
47
52
  def update_version(new_version)
48
53
  file = File.read("lib/metatron/version.rb")
49
54
  new_contents = file.gsub(/VERSION = "(.+)"/, %(VERSION = "#{new_version}"))
@@ -12,6 +12,28 @@ module Metatron
12
12
  def label_namespace
13
13
  @label_namespace ||= "metatron.therubyist.org"
14
14
  end
15
+
16
+ def initializer(*args)
17
+ @initializers ||= []
18
+ @initializers += args
19
+ end
20
+
21
+ def initializers
22
+ @initializers ||= []
23
+ end
24
+
25
+ def nearest_metatron_ancestor
26
+ return self if metatron_template_class?
27
+
28
+ ancestors.find { _1.respond_to?(:metatron_template_class?) && _1.metatron_template_class? }
29
+ end
30
+
31
+ def metatron_template_class?
32
+ return true if name == "Metatron::Template"
33
+ return false if name.start_with?("Metatron::Templates::Concerns")
34
+
35
+ name.start_with?("Metatron::Templates::")
36
+ end
15
37
  end
16
38
 
17
39
  def initialize(name)
@@ -25,27 +47,7 @@ module Metatron
25
47
 
26
48
  alias apiVersion api_version
27
49
 
28
- def self.initializer(*args)
29
- @initializers ||= []
30
- @initializers += args
31
- end
32
-
33
- def self.initializers
34
- @initializers ||= []
35
- end
36
-
37
- def self.nearest_metatron_ancestor
38
- return self if metatron_template_class?
39
-
40
- ancestors.find { _1.respond_to?(:metatron_template_class?) && _1.metatron_template_class? }
41
- end
42
-
43
- def self.metatron_template_class?
44
- return true if name == "Metatron::Template"
45
- return false if name.start_with?("Metatron::Templates::Concerns")
46
-
47
- name.start_with?("Metatron::Templates::")
48
- end
50
+ def base_labels = { "#{label_namespace}/name": name }
49
51
 
50
52
  private
51
53
 
@@ -22,7 +22,7 @@ module Metatron
22
22
  kind:,
23
23
  metadata: {
24
24
  name:,
25
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
+ labels: base_labels.merge(additional_labels)
26
26
  }.merge(formatted_annotations).compact,
27
27
  aggregationRule:,
28
28
  rules: formatted_rules
@@ -28,7 +28,7 @@ module Metatron
28
28
  kind:,
29
29
  metadata: {
30
30
  name:,
31
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
31
+ labels: base_labels.merge(additional_labels)
32
32
  }.merge(formatted_annotations).compact,
33
33
  roleRef:,
34
34
  subjects:
@@ -104,7 +104,7 @@ module Metatron
104
104
  def pod_metadata
105
105
  {
106
106
  metadata: {
107
- labels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
107
+ labels: base_labels.merge(additional_pod_labels)
108
108
  }.merge(formatted_pod_annotations)
109
109
  }
110
110
  end
@@ -23,7 +23,7 @@ module Metatron
23
23
  kind:,
24
24
  metadata: {
25
25
  name:,
26
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
26
+ labels: base_labels.merge(additional_labels)
27
27
  }.merge(formatted_annotations).merge(formatted_namespace).compact,
28
28
  data:,
29
29
  immutable:
@@ -30,7 +30,7 @@ module Metatron
30
30
  apiVersion:,
31
31
  kind:,
32
32
  metadata: {
33
- labels: { "#{label_namespace}/name": name }.merge(additional_labels),
33
+ labels: base_labels.merge(additional_labels),
34
34
  name:
35
35
  }.merge(formatted_annotations).merge(formatted_namespace),
36
36
  spec: {
@@ -21,11 +21,11 @@ module Metatron
21
21
  kind:,
22
22
  metadata: {
23
23
  name:,
24
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
24
+ labels: base_labels.merge(additional_labels)
25
25
  }.merge(formatted_annotations).merge(formatted_namespace),
26
26
  spec: {
27
27
  selector: {
28
- matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
28
+ matchLabels: base_labels.merge(additional_pod_labels)
29
29
  }
30
30
  }.merge(pod_template)
31
31
  }
@@ -22,13 +22,13 @@ module Metatron
22
22
  kind:,
23
23
  metadata: {
24
24
  name:,
25
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
+ labels: base_labels.merge(additional_labels)
26
26
  }.merge(formatted_annotations).merge(formatted_namespace),
27
27
  spec: {
28
28
  replicas:,
29
29
  strategy:,
30
30
  selector: {
31
- matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
31
+ matchLabels: base_labels.merge(additional_pod_labels)
32
32
  }
33
33
  }.merge(pod_template).compact
34
34
  }
@@ -77,7 +77,7 @@ module Metatron
77
77
  kind:,
78
78
  metadata: {
79
79
  name:,
80
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
80
+ labels: base_labels.merge(additional_labels)
81
81
  }.merge(formatted_annotations).merge(formatted_namespace),
82
82
  spec: formatted_rules.merge(formatted_tls)
83
83
  }
@@ -28,7 +28,7 @@ module Metatron
28
28
  apiVersion:,
29
29
  kind:,
30
30
  metadata: {
31
- labels: { "#{label_namespace}/name": name }.merge(additional_labels),
31
+ labels: base_labels.merge(additional_labels),
32
32
  name:
33
33
  }.merge(formatted_annotations).merge(formatted_namespace),
34
34
  spec: {
@@ -19,7 +19,7 @@ module Metatron
19
19
  kind:,
20
20
  metadata: {
21
21
  name:,
22
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
22
+ labels: base_labels.merge(additional_labels)
23
23
  }.merge(formatted_annotations)
24
24
  }
25
25
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # https://kubernetes.io/docs/concepts/services-networking/network-policies/
6
+ class NetworkPolicy < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :pod_selector, :ingress, :egress
11
+
12
+ alias podSelector pod_selector
13
+
14
+ def initialize(name)
15
+ super(name)
16
+ @pod_selector = pod_selector
17
+ @ingress = ingress
18
+ @egress = egress
19
+ end
20
+
21
+ def render
22
+ {
23
+ apiVersion:,
24
+ kind:,
25
+ metadata: {
26
+ labels: base_labels.merge(additional_labels),
27
+ name:
28
+ }.merge(formatted_annotations).merge(formatted_namespace),
29
+ spec: {
30
+ podSelector:
31
+ }.merge(ingress ? { ingress: } : {}).merge(egress ? { egress: } : {})
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -31,7 +31,7 @@ module Metatron
31
31
  kind:,
32
32
  metadata: {
33
33
  name:,
34
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
34
+ labels: base_labels.merge(additional_labels)
35
35
  }.merge(formatted_annotations).merge(formatted_namespace),
36
36
  spec: {
37
37
  accessModes:,
@@ -13,7 +13,7 @@ module Metatron
13
13
  apiVersion:,
14
14
  kind:,
15
15
  metadata: {
16
- labels: { "#{label_namespace}/name": name }.merge(additional_labels),
16
+ labels: base_labels.merge(additional_labels),
17
17
  name:
18
18
  }.merge(formatted_annotations).merge(formatted_namespace)
19
19
  }.merge(pod_spec)
@@ -22,12 +22,12 @@ module Metatron
22
22
  kind:,
23
23
  metadata: {
24
24
  name:,
25
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
+ labels: base_labels.merge(additional_labels)
26
26
  }.merge(formatted_annotations).merge(formatted_namespace),
27
27
  spec: {
28
28
  replicas:,
29
29
  selector: {
30
- matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
30
+ matchLabels: base_labels.merge(additional_pod_labels)
31
31
  }
32
32
  }.merge(pod_template)
33
33
  }
@@ -21,7 +21,7 @@ module Metatron
21
21
  kind:,
22
22
  metadata: {
23
23
  name:,
24
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
24
+ labels: base_labels.merge(additional_labels)
25
25
  }.merge(formatted_annotations).merge(formatted_namespace).compact,
26
26
  rules: formatted_rules
27
27
  }.compact
@@ -29,7 +29,7 @@ module Metatron
29
29
  kind:,
30
30
  metadata: {
31
31
  name:,
32
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
32
+ labels: base_labels.merge(additional_labels)
33
33
  }.merge(formatted_annotations).merge(formatted_namespace).compact,
34
34
  roleRef:,
35
35
  subjects:
@@ -22,7 +22,7 @@ module Metatron
22
22
  kind:,
23
23
  metadata: {
24
24
  name:,
25
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
+ labels: base_labels.merge(additional_labels)
26
26
  }.merge(formatted_annotations).merge(formatted_namespace).compact,
27
27
  type:,
28
28
  stringData: data
@@ -13,7 +13,7 @@ module Metatron
13
13
  def initialize(name, port = nil)
14
14
  super(name)
15
15
  @type = "ClusterIP"
16
- @selector = { "#{label_namespace}/name": name }
16
+ @selector = base_labels
17
17
  @additional_labels = {}
18
18
  @additional_selector_labels = {}
19
19
  @publish_not_ready_addresses = false
@@ -41,7 +41,7 @@ module Metatron
41
41
  kind:,
42
42
  metadata: {
43
43
  name:,
44
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
44
+ labels: base_labels.merge(additional_labels)
45
45
  }.merge(formatted_annotations).merge(formatted_namespace),
46
46
  spec: {
47
47
  type:,
@@ -18,7 +18,7 @@ module Metatron
18
18
  automountServiceAccountToken:,
19
19
  metadata: {
20
20
  name:,
21
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
21
+ labels: base_labels.merge(additional_labels)
22
22
  }.merge(formatted_annotations).merge(formatted_namespace).compact
23
23
  }.compact
24
24
  end
@@ -25,20 +25,20 @@ module Metatron
25
25
  alias strategy= update_strategy=
26
26
  alias updateStrategy update_strategy
27
27
 
28
- def render # rubocop:disable Metrics/AbcSize
28
+ def render
29
29
  {
30
30
  apiVersion:,
31
31
  kind:,
32
32
  metadata: {
33
33
  name:,
34
- labels: { "#{label_namespace}/name": name }.merge(additional_labels)
34
+ labels: base_labels.merge(additional_labels)
35
35
  }.merge(formatted_annotations).merge(formatted_namespace),
36
36
  spec: {
37
37
  replicas:,
38
38
  serviceName:,
39
39
  updateStrategy:,
40
40
  selector: {
41
- matchLabels: { "#{label_namespace}/name": name }.merge(additional_pod_labels)
41
+ matchLabels: base_labels.merge(additional_pod_labels)
42
42
  }
43
43
  }.merge(pod_template).merge(volume_claim_templates).compact
44
44
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metatron
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/metatron.rb CHANGED
@@ -32,6 +32,7 @@ require "metatron/templates/daemon_set"
32
32
  require "metatron/templates/deployment"
33
33
  require "metatron/templates/ingress"
34
34
  require "metatron/templates/namespace"
35
+ require "metatron/templates/network_policy"
35
36
  require "metatron/templates/persistent_volume_claim"
36
37
  require "metatron/templates/replica_set"
37
38
  require "metatron/templates/role"
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.6.0
4
+ version: 0.7.0
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-11-22 00:00:00.000000000 Z
11
+ date: 2023-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -251,6 +251,7 @@ files:
251
251
  - lib/metatron/templates/ingress.rb
252
252
  - lib/metatron/templates/job.rb
253
253
  - lib/metatron/templates/namespace.rb
254
+ - lib/metatron/templates/network_policy.rb
254
255
  - lib/metatron/templates/persistent_volume_claim.rb
255
256
  - lib/metatron/templates/pod.rb
256
257
  - lib/metatron/templates/replica_set.rb