Rename file push to noop push

This commit is contained in:
Seth Vargo 2014-10-22 22:29:23 -04:00
parent 72affa0a10
commit 0e824cc471
7 changed files with 46 additions and 95 deletions

View File

@ -1,26 +0,0 @@
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

View File

@ -1,29 +0,0 @@
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

View File

@ -0,0 +1,16 @@
module VagrantPlugins
module NoopDeploy
class Config < Vagrant.plugin("2", :config)
def initialize
end
def finalize!
end
def validate(machine)
errors = _detected_errors
{ "Noop push" => errors }
end
end
end
end

View File

@ -1,20 +1,19 @@
require "vagrant"
module VagrantPlugins
module FileDeploy
module NoopDeploy
class Plugin < Vagrant.plugin("2")
name "file"
name "noop"
description <<-DESC
Deploy by pushing to a filepath on your local system or a remote share
attached to this system
Literally do nothing
DESC
config(:file, :push) do
config(:noop, :push) do
require File.expand_path("../config", __FILE__)
Config
end
push(:file) do
push(:noop) do
require File.expand_path("../push", __FILE__)
Push
end

View File

@ -0,0 +1,11 @@
module VagrantPlugins
module NoopDeploy
class Push < Vagrant.plugin("2", :push)
def push
@machine.communicate.tap do |comm|
puts "pushed"
end
end
end
end
end

View File

@ -1,34 +0,0 @@
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

View File

@ -0,0 +1,14 @@
require_relative "../../../base"
require Vagrant.source_root.join("plugins/pushes/noop/config")
describe VagrantPlugins::NoopDeploy::Config do
include_context "unit"
subject { described_class.new }
let(:machine) { double("machine") }
describe "#validate" do
end
end