metatron 0.9.0 → 0.10.1

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: 384d0a3e91cc449b09e5e1ccd514e966e0bea42603da9f01a8498ac25ce943aa
4
- data.tar.gz: f50cf239982f715745308a39ce3027b413ca105b4e41ffc33c097c3489c5f5e4
3
+ metadata.gz: bfe544a98c67ba6ae97f9e09fac9a58483c169fd067f89484b2d454f2d290d43
4
+ data.tar.gz: b40a06690c8eaf0f226e82ebe17a24916724e178bd8b63765dfed4a9ee9f8762
5
5
  SHA512:
6
- metadata.gz: abb52677bdcf1dd2ed1365af61d02861edbed89b04235db5f4c5fb980c2bb44cfca95a868805f1b84f495b4a5650977c8ca4bb44dc3fd384f0235391decfcf18
7
- data.tar.gz: f058f18da99307cac67532bba657fa470f934c83cdf27e2d97cb589d8aa6a1601989c32bb107686ed940ce4189769ea7816fd1c187575915c8bedb4e216c49f6
6
+ metadata.gz: cfe09b2799cef530b00ce400f56d880236ef7c263806f81300a97139da739c57358a3ea5708f69c230c14d554a341b4d7f10c88536f112a85a18d52799d7f892
7
+ data.tar.gz: 2d6aa1b21ead7c64f227d9c819164fa07a06c0a7ac312981b73a5d0c4c83915d01d72258507285ed1468287471eadda77d697dca340a4c4c9b7aedb9fde0af16
@@ -2,13 +2,6 @@ name: CI
2
2
 
3
3
  on:
4
4
  pull_request:
5
- push:
6
- branches: [ "main" ]
7
-
8
- permissions:
9
- contents: write
10
- pull-requests: write
11
- id-token: write
12
5
 
13
6
  jobs:
14
7
  lint:
@@ -59,27 +52,3 @@ jobs:
59
52
 
60
53
  - name: Run tests
61
54
  run: bundle exec rake spec
62
-
63
- release:
64
- runs-on: ubuntu-latest
65
- needs: [ lint, yard, test ]
66
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
67
- steps:
68
- - uses: googleapis/release-please-action@v4
69
- id: release
70
- with:
71
- # The token to use for authentication
72
- token: ${{ secrets.AUTO_RELEASE_TOKEN }}
73
-
74
- - uses: actions/checkout@v4
75
- if: ${{ steps.release.outputs.release_created }}
76
- - name: Set up Ruby
77
- uses: ruby/setup-ruby@v1
78
- if: ${{ steps.release.outputs.release_created }}
79
- with:
80
- bundler-cache: true
81
- ruby-version: .ruby-version
82
-
83
- # Release
84
- - uses: rubygems/release-gem@v1
85
- if: ${{ steps.release.outputs.release_created }}
@@ -0,0 +1,33 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+ pull-requests: write
11
+
12
+ jobs:
13
+ release:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+
17
+ - uses: actions/checkout@v4
18
+
19
+ ## Here's the new step for release-please
20
+ - uses: googleapis/release-please-action@v4
21
+ id: release
22
+ with:
23
+ token: ${{ secrets.AUTO_RELEASE_TOKEN }}
24
+
25
+ - name: Set up Ruby
26
+ uses: ruby/setup-ruby@v1
27
+ if: ${{ steps.release.outputs.release_created }}
28
+ with:
29
+ bundler-cache: true
30
+ ruby-version: .ruby-version
31
+
32
+ - uses: rubygems/release-gem@v1
33
+ if: ${{ steps.release.outputs.release_created }}
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.9.0"
2
+ ".": "0.10.1"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.1](https://github.com/jgnagy/metatron/compare/metatron/v0.10.0...metatron/v0.10.1) (2025-03-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * **misc:** allow ping controller usage as class ([60048f3](https://github.com/jgnagy/metatron/commit/60048f3905959bf4193254e9e3f3800298cbc494))
9
+
10
+ ## [0.10.0](https://github.com/jgnagy/metatron/compare/metatron/v0.9.0...metatron/v0.10.0) (2025-03-19)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * **templates:** pod match labels are distinct
16
+ * **templates:** allow overriding base labels
17
+
18
+ ### Features
19
+
20
+ * **templates:** allow overriding base labels ([ba3d4c2](https://github.com/jgnagy/metatron/commit/ba3d4c2813518a5b9bb845700656b2ce67321369))
21
+ * **templates:** pod match labels are distinct ([82b59d0](https://github.com/jgnagy/metatron/commit/82b59d0d93cbf1c4423895f20351e2b73d6057e0))
22
+
3
23
  ## [0.9.0](https://github.com/jgnagy/metatron/compare/metatron-v0.8.8...metatron/v0.9.0) (2025-02-17)
4
24
 
5
25
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- metatron (0.9.0)
4
+ metatron (0.10.1)
5
5
  json (~> 2.6)
6
6
  rack (>= 2.2.8, < 4)
7
7
 
@@ -15,7 +15,7 @@ GEM
15
15
  diff-lcs (1.6.0)
16
16
  docile (1.4.1)
17
17
  jaro_winkler (1.6.0)
18
- json (2.10.1)
18
+ json (2.10.2)
19
19
  kramdown (2.5.1)
20
20
  rexml (>= 3.3.9)
21
21
  kramdown-parser-gfm (1.1.0)
@@ -23,9 +23,9 @@ GEM
23
23
  language_server-protocol (3.17.0.4)
24
24
  lint_roller (1.1.0)
25
25
  logger (1.6.6)
26
- nokogiri (1.18.2-arm64-darwin)
26
+ nokogiri (1.18.3-arm64-darwin)
27
27
  racc (~> 1.4)
28
- nokogiri (1.18.2-x86_64-linux-gnu)
28
+ nokogiri (1.18.3-x86_64-linux-gnu)
29
29
  racc (~> 1.4)
30
30
  observer (0.1.2)
31
31
  ostruct (0.6.1)
@@ -34,7 +34,7 @@ GEM
34
34
  ast (~> 2.4.1)
35
35
  racc
36
36
  racc (1.8.1)
37
- rack (3.1.10)
37
+ rack (3.1.12)
38
38
  rack-test (2.2.0)
39
39
  rack (>= 1.3)
40
40
  rainbow (3.1.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
 
@@ -4,7 +4,8 @@ module Metatron
4
4
  # Base class for templating Kubernetes resources
5
5
  class Template
6
6
  attr_accessor :api_version, :name, :additional_labels
7
- attr_reader :kind, :label_namespace
7
+ attr_reader :kind
8
+ attr_writer :base_labels
8
9
 
9
10
  class << self
10
11
  attr_writer :label_namespace
@@ -38,7 +39,6 @@ module Metatron
38
39
 
39
40
  def initialize(name)
40
41
  @name = name
41
- @label_namespace = self.class.label_namespace
42
42
  @api_version = "v1"
43
43
  @kind = find_kind
44
44
  @additional_labels = {}
@@ -47,10 +47,15 @@ module Metatron
47
47
 
48
48
  alias apiVersion api_version
49
49
 
50
- def base_labels = { "#{label_namespace}/name": name }
50
+ def base_labels
51
+ @base_labels || { "#{label_namespace}/name": name }
52
+ end
51
53
 
52
54
  private
53
55
 
56
+ # defers to the nearest metatron ancestor to determine the label namespace
57
+ def label_namespace = self.class.label_namespace
58
+
54
59
  def run_initializers
55
60
  self.class.nearest_metatron_ancestor.initializers.each { send(_1.to_sym) }
56
61
  end
@@ -9,10 +9,10 @@ module Metatron
9
9
  # base.extend ClassMethods
10
10
  base.class_eval do
11
11
  attr_accessor :active_deadline_seconds, :additional_pod_labels,
12
- :affinity, :automount_service_account_token, :containers,
13
- :dns_policy, :enable_service_links, :hostname, :host_ipc, :host_network,
14
- :host_pid, :image_pull_secrets, :init_containers, :node_selector,
15
- :node_name, :persistent_volume_claims, :pod_annotations,
12
+ :additional_pod_match_labels, :affinity, :automount_service_account_token,
13
+ :containers, :dns_policy, :enable_service_links, :hostname, :host_ipc,
14
+ :host_network, :host_pid, :image_pull_secrets, :init_containers,
15
+ :node_selector, :node_name, :persistent_volume_claims, :pod_annotations,
16
16
  :priority_class_name, :restart_policy, :scheduler_name, :security_context,
17
17
  :service_account, :service_account_name, :share_process_namespace,
18
18
  :subdomain, :termination_grace_period_seconds, :tolerations, :volumes
@@ -41,6 +41,7 @@ module Metatron
41
41
 
42
42
  def pod_producer_initialize
43
43
  @additional_pod_labels = {}
44
+ @additional_pod_match_labels = {}
44
45
  @affinity = {}
45
46
  @containers = []
46
47
  @enable_service_links = nil
@@ -25,7 +25,7 @@ module Metatron
25
25
  }.merge(formatted_annotations).merge(formatted_namespace),
26
26
  spec: {
27
27
  selector: {
28
- matchLabels: base_labels.merge(additional_pod_labels)
28
+ matchLabels: base_labels.merge(additional_pod_match_labels)
29
29
  }
30
30
  }.merge(pod_template)
31
31
  }
@@ -28,7 +28,7 @@ module Metatron
28
28
  replicas:,
29
29
  strategy:,
30
30
  selector: {
31
- matchLabels: base_labels.merge(additional_pod_labels)
31
+ matchLabels: base_labels.merge(additional_pod_match_labels)
32
32
  }
33
33
  }.merge(pod_template).compact
34
34
  }
@@ -27,7 +27,7 @@ module Metatron
27
27
  spec: {
28
28
  replicas:,
29
29
  selector: {
30
- matchLabels: base_labels.merge(additional_pod_labels)
30
+ matchLabels: base_labels.merge(additional_pod_match_labels)
31
31
  }
32
32
  }.merge(pod_template)
33
33
  }
@@ -38,7 +38,7 @@ module Metatron
38
38
  serviceName:,
39
39
  updateStrategy:,
40
40
  selector: {
41
- matchLabels: base_labels.merge(additional_pod_labels)
41
+ matchLabels: base_labels.merge(additional_pod_match_labels)
42
42
  }
43
43
  }.merge(pod_template).merge(volume_claim_templates).compact
44
44
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Metatron
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.1"
5
5
  end
@@ -6,8 +6,8 @@
6
6
  "package-name": "metatron",
7
7
  "changelog-path": "CHANGELOG.md",
8
8
  "release-type": "ruby",
9
- "bump-minor-pre-major": false,
10
- "bump-patch-for-minor-pre-major": false,
9
+ "bump-minor-pre-major": true,
10
+ "bump-patch-for-minor-pre-major": true,
11
11
  "draft": false,
12
12
  "prerelease": false,
13
13
  "version-file": "lib/metatron/version.rb"
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.9.0
4
+ version: 0.10.1
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-02-17 00:00:00.000000000 Z
11
+ date: 2025-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -220,6 +220,7 @@ extensions: []
220
220
  extra_rdoc_files: []
221
221
  files:
222
222
  - ".github/workflows/ci.yml"
223
+ - ".github/workflows/release.yml"
223
224
  - ".gitignore"
224
225
  - ".release-please-manifest.json"
225
226
  - ".rspec"