Class: Kube::Cluster::Middleware::Annotations
- Inherits:
-
Kube::Cluster::Middleware
- Object
- Kube::Cluster::Middleware
- Kube::Cluster::Middleware::Annotations
- Defined in:
- lib/kube/cluster/middleware/annotations.rb
Overview
Merges annotations into metadata.annotations on every resource. Existing annotations are preserved; the supplied annotations act as defaults that can be overridden per-resource.
stack do
use Middleware::Annotations,
"prometheus.io/scrape": "true",
"prometheus.io/port": "9090"
end
Constant Summary
Constants inherited from Kube::Cluster::Middleware
Instance Method Summary collapse
Methods inherited from Kube::Cluster::Middleware
Constructor Details
This class inherits a constructor from Kube::Cluster::Middleware
Instance Method Details
#call(manifest) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kube/cluster/middleware/annotations.rb', line 20 def call(manifest) annotations = @opts.transform_keys(&:to_sym).transform_values(&:to_s) manifest.resources.map! do |resource| filter(resource) do h = resource.to_h h[:metadata] ||= {} h[:metadata][:annotations] = annotations.merge(h[:metadata][:annotations] || {}) resource.rebuild(h) end end end |