metatron 0.3.2 → 0.3.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: 6ccfd1e08895f074e8acfb5f5f5d5bea896b3bc2b721cf554bf63331fd678653
4
- data.tar.gz: 2d51b181787cdd3c68d83cd69dbf7475e973cdd85edafd458a59a324328a6d9a
3
+ metadata.gz: 3f342d1873c69021096bb8c70ac712de9f2584c8e67898a62d42cd4336257ccb
4
+ data.tar.gz: c06caf4e8b626a1762ab872ab5b63b2c7a970fc62087e4df42c86bef051dc76d
5
5
  SHA512:
6
- metadata.gz: 68e7e4f205727a2224b1c3475a083a0f0977fe4f55bebb13791492e1fdf314f8ac4201296acccd0d3c02043d19bf496b90054df11d20938f519fcc7c843d52e9
7
- data.tar.gz: 855ef7826fdd9e9a8a1fd3cc657acec1978dde48d8172b352cf8664953edd1b4c769c106f1e0dc22c2378a2c47b2fb6a3440a0078a253f03e0d1983495d9e278
6
+ metadata.gz: ab60f4188c7c8c58990f3f275813763343b5c56e123885537732f64d66183005a25194f68034fe7f1c2f85ff51f4d42c6a9766557adda875d5ecdbe5f290137f
7
+ data.tar.gz: '08c3dfea5cb6ea36a31a7a848ff95e3dfc282ea0cee946fc4646d034bdfad696a2b5910a883ce425fa8bd2b52a65e09cb65fa3f7c3545e3db14783a6898ed9b2'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.3.2)
4
+ metatron (0.3.4)
5
5
  json (~> 2.6)
6
6
  puma (~> 6.3)
7
7
  sinatra (~> 2.2)
@@ -12,6 +12,7 @@ GEM
12
12
  specs:
13
13
  ast (2.4.2)
14
14
  backport (1.2.0)
15
+ base64 (0.1.1)
15
16
  benchmark (0.2.1)
16
17
  byebug (11.1.3)
17
18
  diff-lcs (1.5.0)
@@ -28,15 +29,15 @@ GEM
28
29
  mustermann (2.0.2)
29
30
  ruby2_keywords (~> 0.0.1)
30
31
  nio4r (2.5.9)
31
- nokogiri (1.15.3-arm64-darwin)
32
+ nokogiri (1.15.4-arm64-darwin)
32
33
  racc (~> 1.4)
33
- nokogiri (1.15.3-x86_64-linux)
34
+ nokogiri (1.15.4-x86_64-linux)
34
35
  racc (~> 1.4)
35
36
  parallel (1.23.0)
36
37
  parser (3.2.2.3)
37
38
  ast (~> 2.4.1)
38
39
  racc
39
- puma (6.3.0)
40
+ puma (6.3.1)
40
41
  nio4r (~> 2.0)
41
42
  racc (1.7.1)
42
43
  rack (2.2.8)
@@ -64,7 +65,8 @@ GEM
64
65
  diff-lcs (>= 1.2.0, < 2.0)
65
66
  rspec-support (~> 3.12.0)
66
67
  rspec-support (3.12.1)
67
- rubocop (1.55.1)
68
+ rubocop (1.56.1)
69
+ base64 (~> 0.1.1)
68
70
  json (~> 2.3)
69
71
  language_server-protocol (>= 3.17.0)
70
72
  parallel (~> 1.10)
@@ -83,7 +85,7 @@ GEM
83
85
  rubocop (~> 1.33)
84
86
  rubocop-rake (0.6.0)
85
87
  rubocop (~> 1.0)
86
- rubocop-rspec (2.23.0)
88
+ rubocop-rspec (2.23.2)
87
89
  rubocop (~> 1.33)
88
90
  rubocop-capybara (~> 2.17)
89
91
  rubocop-factory_bot (~> 2.22)
@@ -25,9 +25,11 @@ module Metatron
25
25
  labels: { "#{label_namespace}/name": name }.merge(additional_labels)
26
26
  }.merge(formatted_annotations).compact,
27
27
  aggregationRule:,
28
- rules:
28
+ rules: formatted_rules
29
29
  }.compact
30
30
  end
31
+
32
+ def formatted_rules = rules.map { _1.respond_to?(:render) ? _1.render : _1 }
31
33
  end
32
34
  end
33
35
  end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # Template for basic Role k8s resource
6
+ class Role < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :rules
11
+
12
+ def initialize(name)
13
+ super(name)
14
+ @api_version = "rbac.authorization.k8s.io/v1"
15
+ @rules = []
16
+ end
17
+
18
+ def render
19
+ {
20
+ apiVersion:,
21
+ kind:,
22
+ metadata: {
23
+ name:,
24
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
25
+ }.merge(formatted_annotations).merge(formatted_namespace).compact,
26
+ rules: formatted_rules
27
+ }.compact
28
+ end
29
+
30
+ def formatted_rules = rules.map { _1.respond_to?(:render) ? _1.render : _1 }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # Template for basic RoleBinding k8s resource
6
+ class RoleBinding < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :role_ref, :subjects, :role
11
+
12
+ alias roleRef role_ref
13
+
14
+ def initialize(name, role)
15
+ super(name)
16
+ @api_version = "rbac.authorization.k8s.io/v1"
17
+ @role = role
18
+ @role_ref = {
19
+ kind: "Role",
20
+ name: role.respond_to?(:name) ? role.name : role,
21
+ apiGroup: "rbac.authorization.k8s.io"
22
+ }
23
+ @subjects = []
24
+ end
25
+
26
+ def render
27
+ {
28
+ apiVersion:,
29
+ kind:,
30
+ metadata: {
31
+ name:,
32
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
33
+ }.merge(formatted_annotations).merge(formatted_namespace).compact,
34
+ roleRef:,
35
+ subjects:
36
+ }.compact
37
+ end
38
+ end
39
+ end
40
+ end
@@ -4,6 +4,6 @@ module Metatron
4
4
  VERSION = [
5
5
  0, # major
6
6
  3, # minor
7
- 2 # patch
7
+ 4 # patch
8
8
  ].join(".")
9
9
  end
data/lib/metatron.rb CHANGED
@@ -41,6 +41,8 @@ require "metatron/templates/ingress"
41
41
  require "metatron/templates/namespace"
42
42
  require "metatron/templates/persistent_volume_claim"
43
43
  require "metatron/templates/replica_set"
44
+ require "metatron/templates/role"
45
+ require "metatron/templates/role_binding"
44
46
  require "metatron/templates/secret"
45
47
  require "metatron/templates/service"
46
48
  require "metatron/templates/service_account"
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.3.2
4
+ version: 0.3.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-08-23 00:00:00.000000000 Z
11
+ date: 2023-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -272,6 +272,8 @@ files:
272
272
  - lib/metatron/templates/persistent_volume_claim.rb
273
273
  - lib/metatron/templates/pod.rb
274
274
  - lib/metatron/templates/replica_set.rb
275
+ - lib/metatron/templates/role.rb
276
+ - lib/metatron/templates/role_binding.rb
275
277
  - lib/metatron/templates/secret.rb
276
278
  - lib/metatron/templates/service.rb
277
279
  - lib/metatron/templates/service_account.rb