Class: Kube::Cluster::Middleware::SetNamespace
- Inherits:
-
Kube::Cluster::Middleware
- Object
- Kube::Cluster::Middleware
- Kube::Cluster::Middleware::SetNamespace
- Defined in:
- lib/kube/cluster/middleware/set_namespace.rb
Overview
Sets metadata.namespace on all namespace-scoped resources, skipping HelmCharts and resources that already have a non-default namespace set.
use SetNamespace, 'authelia'
Constant Summary
Constants inherited from Kube::Cluster::Middleware
Instance Method Summary collapse
- #call(manifest) ⇒ Object
-
#initialize(namespace) ⇒ SetNamespace
constructor
A new instance of SetNamespace.
Methods inherited from Kube::Cluster::Middleware
Constructor Details
#initialize(namespace) ⇒ SetNamespace
Returns a new instance of SetNamespace.
16 17 18 19 |
# File 'lib/kube/cluster/middleware/set_namespace.rb', line 16 def initialize(namespace) super(filter: ->(r) { r.kind != 'HelmChart' }) @namespace = namespace end |
Instance Method Details
#call(manifest) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kube/cluster/middleware/set_namespace.rb', line 21 def call(manifest) manifest.resources.map! { |resource| filter(resource) { next resource if resource.cluster_scoped? h = resource.to_h h[:metadata] ||= {} next resource if h[:metadata][:namespace] && h[:metadata][:namespace] != 'default' h[:metadata][:namespace] = @namespace resource.rebuild(h) } } end |