Class: BeamUp::Providers::SFTP
- Defined in:
- lib/beam_up/providers/sftp.rb
Defined Under Namespace
Classes: Config
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from BeamUp::Providers::Base
Instance Method Details
#deploy!(path) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/beam_up/providers/sftp.rb', line 29 def deploy!(path) @path = path require "net/ssh" require "net/sftp" = { password: @configuration.password, encryption: ["aes256-gcm@openssh.com", "aes256-ctr", "aes192-ctr", "aes128-ctr", "twofish256-ctr", "twofish192-ctr", "twofish128-ctr"] } [:keys] = [@configuration.key] if @configuration.key files = files_to_deploy BeamUp.progress&.start(type: :files, total: files.count) Net::SFTP.start(@configuration.host, @configuration.username, ) do |sftp| files.each do |file| upload sftp, file BeamUp.progress&.tick end end Result.new( provider: "SFTP", deploy_id: Time.now.to_i.to_s, url: "sftp://#{@configuration.host}#{@configuration.remote_path}" ) rescue LoadError raise ConfigurationError, "SFTP requires net-sftp gem. Install with: gem install net-sftp (or add to Gemfile)" rescue => error Result.new(provider: "SFTP", error: error.) ensure BeamUp.progress&.finish end |