Class: Kube::Cluster::Middleware::Namespace
- Inherits:
-
Kube::Cluster::Middleware
- Object
- Kube::Cluster::Middleware
- Kube::Cluster::Middleware::Namespace
- Defined in:
- lib/kube/cluster/middleware/namespace.rb
Overview
Sets metadata.namespace on all namespace-scoped resources. Cluster-scoped kinds (Namespace, ClusterRole, etc.) are skipped.
stack do
use Middleware::Namespace, "production"
end
Instance Method Summary collapse
- #call(manifest) ⇒ Object
-
#initialize(namespace) ⇒ Namespace
constructor
A new instance of Namespace.
Constructor Details
#initialize(namespace) ⇒ Namespace
Returns a new instance of Namespace.
14 15 16 |
# File 'lib/kube/cluster/middleware/namespace.rb', line 14 def initialize(namespace) @namespace = namespace end |
Instance Method Details
#call(manifest) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kube/cluster/middleware/namespace.rb', line 18 def call(manifest) manifest.resources.map! do |resource| next resource if resource.cluster_scoped? h = resource.to_h h[:metadata] ||= {} h[:metadata][:namespace] = @namespace resource.rebuild(h) end end |