Class: Kube::Cluster::Manifest
- Inherits:
-
Schema::Manifest
- Object
- Schema::Manifest
- Kube::Cluster::Manifest
- Defined in:
- lib/kube/cluster/manifest.rb
Overview
A flat, ordered collection of Kubernetes resources.
Manifest is a pure resource collection. Middleware is applied separately via Kube::Cluster::Middleware::Stack.
manifest = Kube::Cluster::Manifest.new
manifest << Kube::Cluster["Deployment"].new { ... }
stack = Kube::Cluster::Middleware::Stack.new do
use Middleware::Namespace, "production"
use Middleware::Labels, app: "web-app"
end
stack.call(manifest)
manifest.to_yaml
Instance Attribute Summary collapse
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
Instance Method Summary collapse
-
#<<(item) ⇒ Object
Override << to automatically upgrade Kube::Schema::Resource instances into Kube::Cluster::Resource instances.
Instance Attribute Details
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
25 26 27 |
# File 'lib/kube/cluster/manifest.rb', line 25 def resources @resources end |
Instance Method Details
#<<(item) ⇒ Object
Override << to automatically upgrade Kube::Schema::Resource instances into Kube::Cluster::Resource instances. This ensures resources parsed via Kube::Schema::Manifest (e.g. from Helm charts or downloaded YAML) gain cluster-level methods like cluster_scoped?, pod_bearing?, and rebuild when composed into a cluster manifest.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kube/cluster/manifest.rb', line 33 def <<(item) case item when Kube::Cluster::Resource @resources << item when Kube::Schema::Resource @resources << Kube::Cluster[item.kind].new(item.to_h) when Kube::Schema::Manifest item.each { |r| self << r } when Array item.each { |r| self << r } else raise ArgumentError, "Expected a Kube::Schema::Resource or Manifest, got #{item.class}. " \ "Use Kube::Schema.parse(hash) to convert hashes." end self end |