Class: Kontena::Plugin::Shell::Callbacks::StackFile

Inherits:
Callback
  • Object
show all
Defined in:
lib/kontena/plugin/shell/callbacks/stack_file.rb

Instance Method Summary collapse

Instance Method Details

#afterObject



24
25
26
# File 'lib/kontena/plugin/shell/callbacks/stack_file.rb', line 24

def after
  @tempfile.unlink if @tempfile
end

#beforeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kontena/plugin/shell/callbacks/stack_file.rb', line 10

def before
  Kontena::Cli::Stacks::YAML::Reader.class_eval do
    def self.new(*args)
      if args.first == '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
      super *args
    end
  end
end