metatron 0.10.0 → 0.11.0

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: d7a6131869b316def00f00a41810b2aa467b4767d1fc360eb74105ce534568e8
4
- data.tar.gz: f2d924bbc2240d5c04cde9942fb4907b585fce9434f6185b896dcf86afb3323a
3
+ metadata.gz: 3e624bf8ef1365843b3a1af54bdb89b377776358f84693d7f1a2dad737494393
4
+ data.tar.gz: e6c7576f3b2a6d3ca1d81aa1a6ee3295ae7d19811854173eb3e850343d34b19f
5
5
  SHA512:
6
- metadata.gz: fe29d9fc841799ce4805cd31d002c9fa86e0cea5f91e4d8a9544165eb26563a4ec10d6a131434fe3ad54fd4bb1df3625fe6e19ccd1e5e73c66114b38a46209f9
7
- data.tar.gz: d0835ea094c3fe4c990d96d711cbc55fcab15b2314008a80a6aec16d76675754425738bbd73744999a304cb7077af424e3d1a024ffadbe818a4f0397a854e535
6
+ metadata.gz: 3c1002350e83eb88f492b81930bde8636dd7de7ff7b21abb28b1f1d719ebc8f07e334495270d5440bcf92f8af5493add44a6d9e852e42eda6cde4efa52e734c4
7
+ data.tar.gz: 3628be437221e7d0608afd2944510bc05f65a5d388feb01fd044d3f0c24f6d84e7788360b04286525a4bddc90697246f9611f4ab693c39544062cac21d1245c5
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.10.0"
2
+ ".": "0.11.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.0](https://github.com/jgnagy/metatron/compare/metatron/v0.10.1...metatron/v0.11.0) (2025-03-28)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * **templates:** secret now base64 encodes
9
+ * **templates:** omit attribute when default
10
+
11
+ ### Code Refactoring
12
+
13
+ * **templates:** omit attribute when default ([0add60c](https://github.com/jgnagy/metatron/commit/0add60c5ef9faca5e1c7be050415ef3a1f15227b))
14
+ * **templates:** secret now base64 encodes ([3d263ec](https://github.com/jgnagy/metatron/commit/3d263ec85b9d7e87b987c2fcf4c6fc9664eb84d6))
15
+
16
+ ## [0.10.1](https://github.com/jgnagy/metatron/compare/metatron/v0.10.0...metatron/v0.10.1) (2025-03-21)
17
+
18
+
19
+ ### Features
20
+
21
+ * **misc:** allow ping controller usage as class ([60048f3](https://github.com/jgnagy/metatron/commit/60048f3905959bf4193254e9e3f3800298cbc494))
22
+
3
23
  ## [0.10.0](https://github.com/jgnagy/metatron/compare/metatron/v0.9.0...metatron/v0.10.0) (2025-03-19)
4
24
 
5
25
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.10.0)
4
+ metatron (0.11.0)
5
+ base64
5
6
  json (~> 2.6)
6
7
  rack (>= 2.2.8, < 4)
7
8
 
@@ -10,6 +11,7 @@ GEM
10
11
  specs:
11
12
  ast (2.4.2)
12
13
  backport (1.2.0)
14
+ base64 (0.2.0)
13
15
  benchmark (0.4.0)
14
16
  byebug (11.1.3)
15
17
  diff-lcs (1.6.0)
@@ -23,9 +25,9 @@ GEM
23
25
  language_server-protocol (3.17.0.4)
24
26
  lint_roller (1.1.0)
25
27
  logger (1.6.6)
26
- nokogiri (1.18.3-arm64-darwin)
28
+ nokogiri (1.18.4-arm64-darwin)
27
29
  racc (~> 1.4)
28
- nokogiri (1.18.3-x86_64-linux-gnu)
30
+ nokogiri (1.18.4-x86_64-linux-gnu)
29
31
  racc (~> 1.4)
30
32
  observer (0.1.2)
31
33
  ostruct (0.6.1)
data/README.md CHANGED
@@ -2,8 +2,12 @@
2
2
 
3
3
  Metatron is a Ruby library for creating [Metacontroller](https://metacontroller.github.io/metacontroller/)-based custom Kubernetes controllers.
4
4
 
5
- The intention is to make it as easy as possible to use Ruby to manage [custom resources](https://kubernetes.io/docs/concepts/api-extension/custom-resources/) within your Kubernetes infrastructure. No Golang required!
5
+ The intention is to make it as easy as possible to use Ruby to manage [custom resources](https://kubernetes.io/docs/concepts/api-extension/custom-resources/) within your Kubernetes infrastructure. No Golang required! Use simple, Rack-based controllers to provide the logic for your custom resources. Metatron templates provide a most Kubernetes boilerplate code for you, so you can focus on the logic that enables your custom resources to do what you need them to do.
6
6
 
7
7
  For more information, see the [Metatron Wiki on GitHub](https://github.com/jgnagy/metatron/wiki)!
8
8
 
9
9
  For help on how to get started, take a look at the [User Guide](https://github.com/jgnagy/metatron/wiki/User-Guide) in the Wiki!
10
+
11
+ ## Contributing
12
+
13
+ If you're interested in contributing to Metatron, please see the [Contributing Guide](CONTRIBUTING.md) in the repository! Be sure to check out the [Code of Conduct](CODE_OF_CONDUCT.md) as well!
@@ -6,6 +6,10 @@ module Metatron
6
6
  class Ping
7
7
  RESPONSE = { status: "up" }.to_json
8
8
 
9
+ class << self
10
+ def call(env) = new.call(env)
11
+ end
12
+
9
13
  def call(env)
10
14
  req = Rack::Request.new(env)
11
15
 
@@ -7,15 +7,38 @@ module Metatron
7
7
  include Concerns::Annotated
8
8
  include Concerns::Namespaced
9
9
 
10
- attr_accessor :additional_labels, :type, :data
10
+ attr_accessor :additional_labels, :type, :data, :string_data
11
11
 
12
- def initialize(name, data = {})
12
+ alias stringData string_data
13
+
14
+ def initialize(name, provided_string_data = nil, string_data: nil, data: nil)
13
15
  super(name)
16
+ @string_data = string_data || provided_string_data
14
17
  @data = data
15
18
  @additional_labels = {}
16
19
  @type = "Opaque"
17
20
  end
18
21
 
22
+ def formatted_data
23
+ data_hash = {}
24
+
25
+ # Only include one of data or string_data, preferring data if both are present
26
+ return data_hash unless data || string_data
27
+
28
+ # If string_data is provided, it should be a hash of string values
29
+ # and will be base64 encoded
30
+ if string_data
31
+ data_hash[:data] = string_data.transform_values do |value|
32
+ Base64.strict_encode64(value.to_s).gsub("\n", "")
33
+ end
34
+ end
35
+
36
+ # If data is provided, it should be a hash of base64 encoded values
37
+ data_hash[:data] = data if data
38
+
39
+ data_hash
40
+ end
41
+
19
42
  def render
20
43
  {
21
44
  apiVersion:,
@@ -24,9 +47,8 @@ module Metatron
24
47
  name:,
25
48
  labels: base_labels.merge(additional_labels)
26
49
  }.merge(formatted_annotations).merge(formatted_namespace).compact,
27
- type:,
28
- stringData: data
29
- }.compact
50
+ type:
51
+ }.compact.merge(formatted_data).compact
30
52
  end
31
53
  end
32
54
  end
@@ -40,6 +40,10 @@ module Metatron
40
40
  ports&.any? ? { ports: } : {}
41
41
  end
42
42
 
43
+ def formatted_publish_not_ready_addresses
44
+ publish_not_ready_addresses ? { publishNotReadyAddresses: } : {}
45
+ end
46
+
43
47
  def render
44
48
  {
45
49
  apiVersion:,
@@ -51,9 +55,8 @@ module Metatron
51
55
  spec: {
52
56
  type:,
53
57
  selector: selector.merge(additional_selector_labels),
54
- publishNotReadyAddresses:,
55
58
  clusterIP:
56
- }.compact.merge(formatted_ports)
59
+ }.compact.merge(formatted_ports).merge(formatted_publish_not_ready_addresses)
57
60
  }
58
61
  end
59
62
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metatron
4
- VERSION = "0.10.0"
4
+ VERSION = "0.11.0"
5
5
  end
data/lib/metatron.rb CHANGED
@@ -6,6 +6,9 @@ require "securerandom"
6
6
  require "time"
7
7
  require "logger"
8
8
 
9
+ # external requirements
10
+ require "base64"
11
+
9
12
  # The top-level module for Metatron
10
13
  module Metatron
11
14
  class Error < StandardError; end
data/metatron.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.required_ruby_version = "~> 3.1"
29
29
 
30
+ spec.add_dependency "base64"
30
31
  spec.add_dependency "json", "~> 2.6"
31
32
  spec.add_dependency "rack", ">= 2.2.8", "< 4"
32
33
 
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.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: 2025-03-19 00:00:00.000000000 Z
11
+ date: 2025-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: json
15
29
  requirement: !ruby/object:Gem::Requirement