› kube_cluster › Source › Kube › Cluster › Manifest

class Manifest

A pure collection; middleware applies separately.

Example.

manifest = Kube::Cluster::Manifest.new
manifest << Kube::Cluster["Deployment"].new { ... }
stack = Kube::Cluster::Middleware::Stack.new do
  use Middleware::SetNamespace, "production"
  use Middleware::Labels, app: "web-app"
end
stack.call(manifest)
manifest.to_yaml

Signature

Definitions

def <<(item)

Upgrades a Kube::Schema::Resource to a Kube::Cluster::Resource.

Signature

parameter item Resource, Manifest, Array

what to append.

returns self

appended; gains cluster_scoped?, pod_bearing?, etc.

Implementation

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