Module: Kontena::Plugin::Shell::StacksCommonExt

Defined in:
lib/kontena/plugin/shell/stacks_common_ext.rb

Instance Method Summary collapse

Instance Method Details

#reader_from_yaml(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/kontena/plugin/shell/stacks_common_ext.rb', line 7

def reader_from_yaml(*args)
  if args.first == 'kontena.yml' && !File.exist?('kontena.yml')
    tempfile = Tempfile.new('kontena.yml')
    tempfile.write(Kontena.prompt.multiline("Enter or paste a stack YAML").join)
    tempfile.close
    args[0] = tempfile.path
  end
  reader = super(*args)
  File.unlink(args[0]) if File.exist?(args[0])
  reader
end