Class: Kube::Ctl::QueryBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/ctl/query_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(command_data) ⇒ QueryBuilder

Returns a new instance of QueryBuilder.



8
9
10
11
12
13
# File 'lib/kube/ctl/query_builder.rb', line 8

def initialize(command_data)
  @commands = command_data[:commands] || []
  @resource = command_data[:resource]
  @args     = command_data[:args] || []
  @flags    = command_data[:flags] || {}
end

Instance Method Details

#to_aObject



19
20
21
22
# File 'lib/kube/ctl/query_builder.rb', line 19

def to_a
  stdout, _status = Open3.capture2('kubectl', *@commands, *resource_arg, *@args, *rendered_flags)
  stdout.lines.map(&:chomp)
end

#to_sObject



15
16
17
# File 'lib/kube/ctl/query_builder.rb', line 15

def to_s
  ['kubectl', *@commands, *resource_arg, *@args, *rendered_flags].join(' ')
end