metatron 0.2.5 → 0.2.7

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: ef9aac429ebb8074709e762051f6b5b54b58fa509c05c221383275ede14b1250
4
- data.tar.gz: b367fcc93d32010eb00f9b642b8e8651b329b4f0e15f44d0c25b0fe6b13f305c
3
+ metadata.gz: 36e8e6c44406c821d01c13c564acf765719ac6ac2572053afa5d4bd5b33df33f
4
+ data.tar.gz: 3378c577112bdc28cfbdf4e33c6a5a739434ba4e38312a4147f574ca09b29139
5
5
  SHA512:
6
- metadata.gz: 38531090c45a8417780e07118c7f52d579e074d718e781651a61e2c894cdfee23ab900f33b3f6ac5d2ab578ee1d03b6fdde40a785a3eb7533c473330ef7af17f
7
- data.tar.gz: 2a4f9d9ec0926f510cc5f2033d47f1514dafa4b828d7ecec07b776131132ffcc7e88b3802fa75e06d427c56402569edf5d669318aa7d50c9921dd5a37d358bdc
6
+ metadata.gz: a3857663d6044c885a46e1ff3bf5017281f4202273516bacb7a38e1aaa9cd84d689221c700fb4d4f55316f3b55eec379134eae12ba9d7727e233f051b9da9bb7
7
+ data.tar.gz: dddb6a6dda8d5a54b44c14cc2579f570e099033e22b085a560827ca60344b2d8d3ef331cd9660526c358e3c80ed2c9f2dba309b8707b44f29f75e1b365854809
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.2.5)
4
+ metatron (0.2.7)
5
5
  json (~> 2.6)
6
6
  puma (~> 6.3)
7
7
  sinatra (~> 2.2)
@@ -39,7 +39,7 @@ GEM
39
39
  puma (6.3.0)
40
40
  nio4r (~> 2.0)
41
41
  racc (1.7.1)
42
- rack (2.2.7)
42
+ rack (2.2.8)
43
43
  rack-protection (2.2.4)
44
44
  rack
45
45
  rack-test (2.1.0)
@@ -64,7 +64,7 @@ GEM
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.12.0)
66
66
  rspec-support (3.12.1)
67
- rubocop (1.55.0)
67
+ rubocop (1.55.1)
68
68
  json (~> 2.3)
69
69
  language_server-protocol (>= 3.17.0)
70
70
  parallel (~> 1.10)
@@ -83,7 +83,7 @@ GEM
83
83
  rubocop (~> 1.33)
84
84
  rubocop-rake (0.6.0)
85
85
  rubocop (~> 1.0)
86
- rubocop-rspec (2.22.0)
86
+ rubocop-rspec (2.23.0)
87
87
  rubocop (~> 1.33)
88
88
  rubocop-capybara (~> 2.17)
89
89
  rubocop-factory_bot (~> 2.22)
@@ -3,7 +3,7 @@
3
3
  module Metatron
4
4
  # Base class for templating Kubernetes resources
5
5
  class Template
6
- attr_accessor :api_version, :name
6
+ attr_accessor :api_version, :name, :additional_labels
7
7
  attr_reader :kind, :label_namespace
8
8
 
9
9
  class << self
@@ -19,6 +19,7 @@ module Metatron
19
19
  @label_namespace = self.class.label_namespace
20
20
  @api_version = "v1"
21
21
  @kind = find_kind
22
+ @additional_labels = {}
22
23
  run_initializers
23
24
  end
24
25
 
@@ -8,7 +8,7 @@ module Metatron
8
8
  def self.included(base) # rubocop:disable Metrics/MethodLength
9
9
  # base.extend ClassMethods
10
10
  base.class_eval do
11
- attr_accessor :active_deadline_seconds, :additional_labels, :additional_pod_labels,
11
+ attr_accessor :active_deadline_seconds, :additional_pod_labels,
12
12
  :affinity, :automount_service_account_token, :containers,
13
13
  :dns_policy, :enable_service_links, :hostname, :host_ipc, :host_network,
14
14
  :host_pid, :image_pull_secrets, :init_containers, :node_selector,
@@ -39,7 +39,6 @@ module Metatron
39
39
  end
40
40
 
41
41
  def pod_producer_initialize
42
- @additional_labels = {}
43
42
  @additional_pod_labels = {}
44
43
  @affinity = {}
45
44
  @containers = []
@@ -5,7 +5,7 @@ module Metatron
5
5
  # Template for containers used by k8s resources (not an actual resource)
6
6
  class Container
7
7
  attr_accessor :name, :image, :command, :args, :env, :envfrom, :resources, :volume_mounts,
8
- :image_pull_policy, :life_cycle, :probes, :security_context, :ports,
8
+ :image_pull_policy, :lifecycle, :probes, :security_context, :ports,
9
9
  :stdin, :tty
10
10
 
11
11
  alias imagePullPolicy image_pull_policy
@@ -23,15 +23,16 @@ module Metatron
23
23
  @resources = {}
24
24
  @volume_mounts = []
25
25
  @image_pull_policy = "IfNotPresent"
26
- @life_cycle = {}
26
+ @lifecycle = {}
27
27
  @probes = {}
28
28
  @stdin = true
29
29
  @tty = true
30
30
  end
31
31
 
32
- def render
32
+ def render # rubocop:disable Metrics/AbcSize
33
33
  {
34
34
  name:,
35
+ command:,
35
36
  image:,
36
37
  imagePullPolicy:,
37
38
  stdin:,
@@ -43,9 +44,23 @@ module Metatron
43
44
  .merge(formatted_ports)
44
45
  .merge(formatted_volume_mounts)
45
46
  .merge(formatted_security_context)
47
+ .merge(formatted_args)
48
+ .merge(formatted_lifecycle)
46
49
  .compact
47
50
  end
48
51
 
52
+ def formatted_args
53
+ return {} unless args && !args.empty?
54
+
55
+ { args: }
56
+ end
57
+
58
+ def formatted_lifecycle
59
+ return {} unless lifecycle && !lifecycle.empty?
60
+
61
+ { lifecycle: }
62
+ end
63
+
49
64
  def formatted_environment # rubocop:disable Metrics/PerceivedComplexity
50
65
  return {} unless env && !env.empty?
51
66
 
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The ServiceAccount Kubernetes resource
6
+ class ServiceAccount < Template
7
+ include Concerns::Annotated
8
+ include Concerns::Namespaced
9
+
10
+ attr_accessor :automount_service_account_token
11
+
12
+ alias automountServiceAccountToken automount_service_account_token
13
+
14
+ def render
15
+ {
16
+ apiVersion:,
17
+ kind:,
18
+ automountServiceAccountToken:,
19
+ metadata: {
20
+ name:,
21
+ labels: { "#{label_namespace}/name": name }.merge(additional_labels)
22
+ }.merge(formatted_annotations).merge(formatted_namespace).compact
23
+ }.compact
24
+ end
25
+ end
26
+ end
27
+ end
@@ -4,6 +4,6 @@ module Metatron
4
4
  VERSION = [
5
5
  0, # major
6
6
  2, # minor
7
- 5 # patch
7
+ 7 # patch
8
8
  ].join(".")
9
9
  end
data/lib/metatron.rb CHANGED
@@ -40,6 +40,7 @@ require "metatron/templates/replica_set"
40
40
  require "metatron/templates/config_map"
41
41
  require "metatron/templates/secret"
42
42
  require "metatron/templates/service"
43
+ require "metatron/templates/service_account"
43
44
  require "metatron/templates/stateful_set"
44
45
  require "metatron/controller"
45
46
  require "metatron/sync_controller"
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.2.5
4
+ version: 0.2.7
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-01 00:00:00.000000000 Z
11
+ date: 2023-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -272,6 +272,7 @@ files:
272
272
  - lib/metatron/templates/replica_set.rb
273
273
  - lib/metatron/templates/secret.rb
274
274
  - lib/metatron/templates/service.rb
275
+ - lib/metatron/templates/service_account.rb
275
276
  - lib/metatron/templates/stateful_set.rb
276
277
  - lib/metatron/version.rb
277
278
  - metatron.gemspec