metatron 0.3.3 → 0.3.4

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: 9a957ab8c4406082d7cd4e20c055991e968ac629fbb2d0fd6b606ac0b4b00360
4
- data.tar.gz: '088237780d68ca7c7b867fd6073c6c40f2e01673eedf8de7e6a5f65cf9e7373d'
3
+ metadata.gz: 3f342d1873c69021096bb8c70ac712de9f2584c8e67898a62d42cd4336257ccb
4
+ data.tar.gz: c06caf4e8b626a1762ab872ab5b63b2c7a970fc62087e4df42c86bef051dc76d
5
5
  SHA512:
6
- metadata.gz: 07d460cf1cd5f67b90b41eb45814f27a0bee7ba9f195b4a5a35c6b107571138f4624850fcd8f0f8b4ab5d29974d13776a13efd481f3731ab9e67215c681c9e75
7
- data.tar.gz: eec628dbb12d330ba052687a5c0942feeb4ca6363bb1bf3c3f75168e0a6f5f991137b27d08860bd8b6e6a8037f932009274c8ff1a9be8a8464606abf030811a6
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.3)
4
+ metatron (0.3.4)
5
5
  json (~> 2.6)
6
6
  puma (~> 6.3)
7
7
  sinatra (~> 2.2)
@@ -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
- 3 # 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.3
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