metatron 0.8.6 → 0.8.8

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: 75b1820be1a5acfc0dbcbb3e0d307edbedcbff8797ccae1ab80a2cdc46e3f035
4
- data.tar.gz: 627d05e8f91bdc41ca047fe454778f58f96e402965f434636002b03ef1f29c10
3
+ metadata.gz: 391fa61dd0511b360cf7a0327d6b5de19d9094908349feb79804ef2695db0950
4
+ data.tar.gz: 1db1d4a4590db27056933cb052445f2fecb4a856d024e0df8322e7379e3414ba
5
5
  SHA512:
6
- metadata.gz: 505e005541ceb62d1e196599149e6a95b5aad312b3ed5bbf1556a0801212290536d23ed5e4248288ac749bbefd16b818b20d32c32329ad6d8049a14116ac6d72
7
- data.tar.gz: 3c7df31247195f277d1150ba8c2cfa2ea2f72f57a5472458a0dbe7deccb5f5aeb2a9c0736897c8839893aded7939fd33195bd492c82645a065c300dbfcd039c2
6
+ metadata.gz: 305f8fd71865860a6f85e21c79f0f6426bcb0cf260e63483d09c192a326de713db53f1da8a64728c336627ea239d6cb55c25272f56ca44785ed48d1c7300a6d9
7
+ data.tar.gz: effcc2c4603ead394a4a816412cf0460ff9c52a21621987492b17433e239fb8f695e014b252a463f32cecd41d76f5d6cb112bbbd32417ab93aaad5e7c971a148
data/.rubocop.yml CHANGED
@@ -35,6 +35,9 @@ Metrics/ClassLength:
35
35
  Exclude:
36
36
  - 'spec/**/*_spec.rb'
37
37
 
38
+ Metrics/ParameterLists:
39
+ Max: 6
40
+
38
41
  Gemspec/RequireMFA:
39
42
  Enabled: false
40
43
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.8.6)
4
+ metatron (0.8.8)
5
5
  json (~> 2.6)
6
6
  rack (>= 2.2.8, < 4)
7
7
 
@@ -14,38 +14,41 @@ GEM
14
14
  byebug (11.1.3)
15
15
  diff-lcs (1.5.1)
16
16
  docile (1.4.1)
17
- e2mmap (0.1.0)
18
17
  jaro_winkler (1.6.0)
19
- json (2.9.1)
18
+ json (2.10.1)
20
19
  kramdown (2.5.1)
21
20
  rexml (>= 3.3.9)
22
21
  kramdown-parser-gfm (1.1.0)
23
22
  kramdown (~> 2.0)
24
- language_server-protocol (3.17.0.3)
25
- nokogiri (1.18.1-arm64-darwin)
23
+ language_server-protocol (3.17.0.4)
24
+ logger (1.6.5)
25
+ nokogiri (1.18.2-arm64-darwin)
26
26
  racc (~> 1.4)
27
- nokogiri (1.18.1-x86_64-linux-gnu)
27
+ nokogiri (1.18.2-x86_64-linux-gnu)
28
28
  racc (~> 1.4)
29
+ observer (0.1.2)
30
+ ostruct (0.6.1)
29
31
  parallel (1.26.3)
30
- parser (3.3.7.0)
32
+ parser (3.3.7.1)
31
33
  ast (~> 2.4.1)
32
34
  racc
33
35
  racc (1.8.1)
34
- rack (3.1.8)
36
+ rack (3.1.10)
35
37
  rack-test (2.2.0)
36
38
  rack (>= 1.3)
37
39
  rainbow (3.1.1)
38
40
  rake (12.3.3)
39
- rbs (2.8.4)
41
+ rbs (3.8.1)
42
+ logger
40
43
  regexp_parser (2.10.0)
41
- reverse_markdown (2.1.1)
44
+ reverse_markdown (3.0.0)
42
45
  nokogiri
43
46
  rexml (3.4.0)
44
47
  rspec (3.13.0)
45
48
  rspec-core (~> 3.13.0)
46
49
  rspec-expectations (~> 3.13.0)
47
50
  rspec-mocks (~> 3.13.0)
48
- rspec-core (3.13.2)
51
+ rspec-core (3.13.3)
49
52
  rspec-support (~> 3.13.0)
50
53
  rspec-expectations (3.13.3)
51
54
  diff-lcs (>= 1.2.0, < 2.0)
@@ -54,17 +57,17 @@ GEM
54
57
  diff-lcs (>= 1.2.0, < 2.0)
55
58
  rspec-support (~> 3.13.0)
56
59
  rspec-support (3.13.2)
57
- rubocop (1.70.0)
60
+ rubocop (1.71.2)
58
61
  json (~> 2.3)
59
62
  language_server-protocol (>= 3.17.0)
60
63
  parallel (~> 1.10)
61
64
  parser (>= 3.3.0.2)
62
65
  rainbow (>= 2.2.2, < 4.0)
63
66
  regexp_parser (>= 2.9.3, < 3.0)
64
- rubocop-ast (>= 1.36.2, < 2.0)
67
+ rubocop-ast (>= 1.38.0, < 2.0)
65
68
  ruby-progressbar (~> 1.7)
66
69
  unicode-display_width (>= 2.4.0, < 4.0)
67
- rubocop-ast (1.37.0)
70
+ rubocop-ast (1.38.0)
68
71
  parser (>= 3.3.1.0)
69
72
  rubocop-capybara (2.21.0)
70
73
  rubocop (~> 1.41)
@@ -89,18 +92,20 @@ GEM
89
92
  simplecov (~> 0.19)
90
93
  simplecov-html (0.13.1)
91
94
  simplecov_json_formatter (0.1.4)
92
- solargraph (0.50.0)
95
+ solargraph (0.51.2)
93
96
  backport (~> 1.2)
94
97
  benchmark
95
98
  bundler (~> 2.0)
96
99
  diff-lcs (~> 1.4)
97
- e2mmap
98
- jaro_winkler (~> 1.5)
100
+ jaro_winkler (~> 1.6)
99
101
  kramdown (~> 2.3)
100
102
  kramdown-parser-gfm (~> 1.1)
103
+ logger (~> 1.6)
104
+ observer (~> 0.1)
105
+ ostruct (~> 0.6)
101
106
  parser (~> 3.0)
102
- rbs (~> 2.0)
103
- reverse_markdown (~> 2.0)
107
+ rbs (~> 3.0)
108
+ reverse_markdown (>= 2.0, < 4)
104
109
  rubocop (~> 1.38)
105
110
  thor (~> 1.0)
106
111
  tilt (~> 2.0)
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json" unless defined? JSON # allow for JSON to be loaded elsewhere
4
+
3
5
  module Metatron
4
6
  # Base class for API services
5
7
  class Controller
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metatron
4
+ module Templates
5
+ # The LimitRange Kubernetes resource
6
+ class LimitRange < Template
7
+ # Limit is an internal class used to represent the limits in a LimitRange resource,
8
+ # and to provide a consistent interface for rendering them. It is not intended to be
9
+ # used outside of this class. Eventually, it may be used to provide validation for
10
+ # the limits.
11
+ class Limit
12
+ attr_accessor :type, :default, :default_request, :max, :max_limit_request_ratio, :min
13
+
14
+ alias defaultRequest default_request
15
+ alias maxLimitRequestRatio max_limit_request_ratio
16
+
17
+ class << self
18
+ def to_limit(limit)
19
+ limit.is_a?(Limit) ? limit : new(**limit)
20
+ end
21
+ end
22
+
23
+ def initialize(type:, default: nil, default_request: nil, max: nil,
24
+ max_limit_request_ratio: nil, min: nil)
25
+ @type = type
26
+ @default = default
27
+ @default_request = default_request
28
+ @max = max
29
+ @max_limit_request_ratio = max_limit_request_ratio
30
+ @min = min
31
+ end
32
+
33
+ def render
34
+ {
35
+ type:,
36
+ default:,
37
+ defaultRequest:,
38
+ max:,
39
+ maxLimitRequestRatio:,
40
+ min:
41
+ }.compact
42
+ end
43
+ end
44
+
45
+ include Concerns::Annotated
46
+ include Concerns::Namespaced
47
+
48
+ attr_accessor :limits
49
+
50
+ def initialize(name, limits = [])
51
+ super(name)
52
+ @limits = limits
53
+ end
54
+
55
+ def render
56
+ {
57
+ apiVersion:,
58
+ kind:,
59
+ metadata: {
60
+ name:,
61
+ labels: base_labels.merge(additional_labels)
62
+ }.merge(formatted_annotations).merge(formatted_namespace),
63
+ spec: formatted_limits
64
+ }.compact
65
+ end
66
+
67
+ private
68
+
69
+ def formatted_limits
70
+ return {} if limits.empty?
71
+
72
+ { limits: limits.map { Limit.to_limit(_1).render } }
73
+ end
74
+ end
75
+ end
76
+ end
@@ -7,10 +7,13 @@ module Metatron
7
7
  include Concerns::Annotated
8
8
  include Concerns::Namespaced
9
9
 
10
- attr_accessor :additional_labels, :storage_class, :access_modes, :storage
10
+ attr_accessor :additional_labels, :data_source, :data_source_ref, :storage_class,
11
+ :access_modes, :storage
11
12
 
12
13
  alias storageClassName storage_class
13
14
  alias accessModes access_modes
15
+ alias dataSource data_source
16
+ alias dataSourceRef data_source_ref
14
17
 
15
18
  def initialize(
16
19
  name,
@@ -22,6 +25,7 @@ module Metatron
22
25
  @storage_class = storage_class
23
26
  @access_modes = access_modes
24
27
  @storage = storage
28
+ @data_source = {}
25
29
  @additional_labels = {}
26
30
  end
27
31
 
@@ -41,9 +45,33 @@ module Metatron
41
45
  storage:
42
46
  }
43
47
  }
44
- }
48
+ }.merge(formatted_data_source).merge(formatted_data_source_ref)
45
49
  }
46
50
  end
51
+
52
+ def formatted_data_source
53
+ return {} unless data_source && !data_source.empty?
54
+ raise "dataSource must be a Hash" unless data_source.is_a?(Hash)
55
+
56
+ valid_keys = %i[apiGroup kind name]
57
+ unless data_source.keys.all? { valid_keys.include?(_1.to_sym) }
58
+ raise "dataSource may contain only the keys: #{valid_keys.join(", ")}"
59
+ end
60
+
61
+ { dataSource: data_source.transform_keys(&:to_sym) }
62
+ end
63
+
64
+ def formatted_data_source_ref
65
+ return {} unless data_source_ref && !data_source_ref.empty?
66
+ raise "dataSourceRef must be a Hash" unless data_source_ref.is_a?(Hash)
67
+
68
+ valid_keys = %i[apiGroup kind name namespace]
69
+ unless data_source_ref.keys.all? { valid_keys.include?(_1.to_sym) }
70
+ raise "dataSourceRef may contain only the keys: #{valid_keys.join(", ")}"
71
+ end
72
+
73
+ { dataSourceRef: data_source_ref.transform_keys(&:to_sym) }
74
+ end
47
75
  end
48
76
  end
49
77
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metatron
4
- VERSION = "0.8.6"
4
+ VERSION = "0.8.8"
5
5
  end
data/lib/metatron.rb CHANGED
@@ -31,6 +31,7 @@ require "metatron/templates/cron_job"
31
31
  require "metatron/templates/daemon_set"
32
32
  require "metatron/templates/deployment"
33
33
  require "metatron/templates/ingress"
34
+ require "metatron/templates/limit_range"
34
35
  require "metatron/templates/namespace"
35
36
  require "metatron/templates/network_policy"
36
37
  require "metatron/templates/persistent_volume_claim"
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.8.6
4
+ version: 0.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Gnagy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-18 00:00:00.000000000 Z
11
+ date: 2025-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -250,6 +250,7 @@ files:
250
250
  - lib/metatron/templates/deployment.rb
251
251
  - lib/metatron/templates/ingress.rb
252
252
  - lib/metatron/templates/job.rb
253
+ - lib/metatron/templates/limit_range.rb
253
254
  - lib/metatron/templates/namespace.rb
254
255
  - lib/metatron/templates/network_policy.rb
255
256
  - lib/metatron/templates/persistent_volume_claim.rb