Class: Kuby::Kubernetes::Manifest

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/kuby/kubernetes/manifest.rb

Instance Method Summary collapse

Constructor Details

#initialize(resources) ⇒ Manifest

Returns a new instance of Manifest.



9
10
11
12
13
# File 'lib/kuby/kubernetes/manifest.rb', line 9

def initialize(resources)
  @resources = resources

  ensure_all_resources_unique!
end

Instance Method Details

#<<(resource) ⇒ Object



33
34
35
# File 'lib/kuby/kubernetes/manifest.rb', line 33

def <<(resource)
  @resources << resource
end

#delete(kind, name) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/kuby/kubernetes/manifest.rb', line 25

def delete(kind, name)
  idx = @resources.index do |resource|
    matches?(resource, kind, name)
  end

  resources.delete(idx) if idx
end

#each(&block) ⇒ Object



15
16
17
# File 'lib/kuby/kubernetes/manifest.rb', line 15

def each(&block)
  @resources.each(&block)
end

#find(kind, name) ⇒ Object



19
20
21
22
23
# File 'lib/kuby/kubernetes/manifest.rb', line 19

def find(kind, name)
  @resources.find do |resource|
    matches?(resource, kind, name)
  end
end