Add preliminary File pusher (incomplete)
This commit is contained in:
parent
a93fff103f
commit
8a7e546972
|
@ -0,0 +1,26 @@
|
|||
module VagrantPlugins
|
||||
module FileDeploy
|
||||
class Config < Vagrant.plugin("2", :config)
|
||||
attr_accessor :destination
|
||||
|
||||
def initialize
|
||||
@destination = UNSET_VALUE
|
||||
end
|
||||
|
||||
def finalize!
|
||||
@destination = nil if @destination == UNSET_VALUE
|
||||
end
|
||||
|
||||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
|
||||
# Validate that a destination was provided
|
||||
if !destination
|
||||
errors << I18n.t("vagrant.pushes.file.no_destination")
|
||||
end
|
||||
|
||||
{ "File push" => errors }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module FileDeploy
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "file"
|
||||
description <<-DESC
|
||||
Deploy by pushing to a filepath on your local system or a remote share
|
||||
attached to this system
|
||||
DESC
|
||||
|
||||
config(:file, :push) do
|
||||
require File.expand_path("../config", __FILE__)
|
||||
Config
|
||||
end
|
||||
|
||||
push(:file) do
|
||||
require File.expand_path("../push", __FILE__)
|
||||
Push
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
module VagrantPlugins
|
||||
module FileDeploy
|
||||
class Push < Vagrant.plugin("2", :push)
|
||||
def push
|
||||
@machine.communicate.tap do |comm|
|
||||
destination = expand_guest_path(config.destination)
|
||||
|
||||
# Make sure the remote path exists
|
||||
command = "mkdir -p %s" % File.dirname(destination)
|
||||
comm.execute(command)
|
||||
|
||||
# Now push the deploy...
|
||||
# ???
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Expand the guest path if the guest has the capability
|
||||
def expand_guest_path(destination)
|
||||
if machine.guest.capability?(:shell_expand_guest_path)
|
||||
machine.guest.capability(:shell_expand_guest_path, destination)
|
||||
else
|
||||
destination
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1892,3 +1892,7 @@ en:
|
|||
You must include both public and private keys.
|
||||
must_accept_keys: |-
|
||||
You must accept keys when running highstate with master!
|
||||
|
||||
pushes:
|
||||
file:
|
||||
no_destination: "File destination must be specified."
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
require_relative "../../../base"
|
||||
|
||||
require Vagrant.source_root.join("plugins/pushes/file/config")
|
||||
|
||||
describe VagrantPlugins::FileDeploy::Config do
|
||||
include_context "unit"
|
||||
|
||||
subject { described_class.new }
|
||||
|
||||
let(:machine) { double("machine") }
|
||||
|
||||
describe "#validate" do
|
||||
it "returns an error if destination is not specified" do
|
||||
subject.finalize!
|
||||
|
||||
result = subject.validate(machine)
|
||||
|
||||
expect(result["File push"]).to eql([
|
||||
I18n.t("vagrant.pushes.file.no_destination")
|
||||
])
|
||||
end
|
||||
|
||||
it "returns no errors when the config is valid" do
|
||||
existing_file = File.expand_path(__FILE__)
|
||||
|
||||
subject.destination = existing_file
|
||||
subject.finalize!
|
||||
|
||||
result = subject.validate(machine)
|
||||
|
||||
expect(result["File push"]).to be_empty
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue