From 40e1d0065cf2cde027b53a0efef3273d6c0fafa1 Mon Sep 17 00:00:00 2001 From: Julian Tabel Date: Fri, 7 Dec 2018 16:02:10 +0100 Subject: [PATCH] Allow to set temp directory for downloads --- lib/fpm/fry/command.rb | 5 ++++- lib/fpm/fry/ui.rb | 2 +- spec/command/cook_spec.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/fpm/fry/command.rb b/lib/fpm/fry/command.rb index 0e6b1eb..b03865c 100644 --- a/lib/fpm/fry/command.rb +++ b/lib/fpm/fry/command.rb @@ -13,6 +13,9 @@ class Command < Clamp::Command option '--debug', :flag, 'Turns on debugging' option '--[no-]tls', :flag, 'Turns on tls ( default is false for schema unix, tcp and http and true for https )' option '--[no-]tlsverify', :flag, 'Turns off tls peer verification', default:true, environment_variable: 'DOCKER_TLS_VERIFY' + option ["-t", "--tmpdir"], "PATH", 'Write tmp data to PATH', default: '/tmp/fpm-fry', attribute_name: :dir do |s| + String(s) + end subcommand 'fpm', 'Works like fpm but with docker support', FPM::Command @@ -22,7 +25,7 @@ class Command < Clamp::Command def initialize(invocation_path, ctx = {}, parent_attribute_values = {}) super - @ui = ctx.fetch(:ui){ UI.new } + @ui = ctx.fetch(:ui){ UI.new(tmpdir: dir) } @client = ctx[:client] end diff --git a/lib/fpm/fry/ui.rb b/lib/fpm/fry/ui.rb index 3c1643f..b27889e 100644 --- a/lib/fpm/fry/ui.rb +++ b/lib/fpm/fry/ui.rb @@ -3,7 +3,7 @@ module FPM; module Fry class UI < Struct.new(:out, :err, :logger, :tmpdir) - def initialize( out = STDOUT, err = STDERR, logger = nil , tmpdir = '/tmp/fpm-fry' ) + def initialize( out: STDOUT, err: STDERR, logger: nil , tmpdir: '/tmp/fpm-fry' ) logger ||= Channel.new.tap{|chan| chan.subscribe(Cabin::NiceOutput.new(out)) } FileUtils.mkdir_p( tmpdir ) super( out, err, logger, tmpdir ) diff --git a/spec/command/cook_spec.rb b/spec/command/cook_spec.rb index 103a7e2..00dd061 100644 --- a/spec/command/cook_spec.rb +++ b/spec/command/cook_spec.rb @@ -12,7 +12,7 @@ end let(:ui) do - FPM::Fry::UI.new(StringIO.new,StringIO.new,nil,tmpdir) + FPM::Fry::UI.new(out: StringIO.new, err: StringIO.new, logger: nil, tmpdir: tmpdir) end after(:each) do