vagrant-winrm-file-download 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +12 -0
- data/README.md +62 -0
- data/Rakefile +13 -0
- data/lib/vagrant-winrm-file-download/config.rb +22 -0
- data/lib/vagrant-winrm-file-download/plugin.rb +23 -0
- data/lib/vagrant-winrm-file-download/provisioner.rb +43 -0
- data/lib/vagrant-winrm-file-download/version.rb +5 -0
- data/lib/vagrant-winrm-file-download.rb +11 -0
- data/vagrant-winrm-file-download.gemspec +20 -0
- data/vagrantfile +48 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 533c81cb90827c3e2c7e88b5923cbfb4ea306d96b93722cebb12fc3616c8f8ef
|
4
|
+
data.tar.gz: 899ba3dd911a750f5e92509f0faa4dcd5173e343cc31ffd3d5fadd546afd5abe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1e58b2c50ba7e44965a0a820a0ecd3fca50915c4cc63f6ba7ce76fb350b84efc4f13984fb1030b00ff2a629d52d776e6704863e961484e5eabc710afdcac1fd3
|
7
|
+
data.tar.gz: 66a386946c3f66ff8ddfc7403517ba5b1b566ef1a1ce3b7608fd34efdea43f0d311c5e4dfd3e11b3febaa50b0bde1ac89b2e60c9611d4c28364deb1a8b90f58c
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.vagrant
|
24
|
+
.idea
|
25
|
+
bin/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Copyright (c) Octopus Deploy and contributors. All rights reserved.
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
4
|
+
these files except in compliance with the License. You may obtain a copy of the
|
5
|
+
License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
10
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
11
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
12
|
+
specific language governing permissions and limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Vagrant WinRM File Downloader Plugin
|
2
|
+
|
3
|
+
This is a super simple vagrant provisioner plugin that allows you to download files from the guest to the host.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```vagrant plugin install vagrant-winrm-file-download```
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In your Vagrantfile, add the following plugin and configure to your needs:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
config.vm.provision "winrm-file-download" do |file|
|
15
|
+
file.source = 'c:\temp\foo.txt'
|
16
|
+
file.destination = 'c:\temp\foo-downloaded.txt'
|
17
|
+
end
|
18
|
+
```
|
19
|
+
|
20
|
+
## Uninstallation
|
21
|
+
|
22
|
+
```vagrant plugin uninstall vagrant-dsc```
|
23
|
+
|
24
|
+
## Development
|
25
|
+
|
26
|
+
Before getting started, read the Vagrant plugin [development basics](https://docs.vagrantup.com/v2/plugins/development-basics.html) and [packaging](https://docs.vagrantup.com/v2/plugins/packaging.html) documentation.
|
27
|
+
|
28
|
+
Development was done against:
|
29
|
+
* Ruby 2.6.4
|
30
|
+
* Bundler 1.17.2, and
|
31
|
+
* vagrant [master@9eac6ae62d6a](https://github.com/hashicorp/vagrant/commit/9eac6ae62d6ad7acdd173fabe558ba75156245b6), which is likely to be 2.2.6
|
32
|
+
|
33
|
+
```
|
34
|
+
git clone git@github.com:OcotpusDeploy/vagrant-winrm-file-download.git
|
35
|
+
cd vagrant-winrm-file-download
|
36
|
+
bundle install
|
37
|
+
```
|
38
|
+
|
39
|
+
Run tests:
|
40
|
+
```
|
41
|
+
# tests are... not yet there
|
42
|
+
bundle exec rake spec
|
43
|
+
```
|
44
|
+
|
45
|
+
Run Vagrant in context of current vagrant-dsc plugin:
|
46
|
+
```
|
47
|
+
cd <directory>
|
48
|
+
bundle exec vagrant up
|
49
|
+
```
|
50
|
+
|
51
|
+
### Building a new version
|
52
|
+
1. update the version number in the `lib/vagrant-winrm-file-download.rb`
|
53
|
+
1. run `gem build .\vagrant-winrm-file-download.gemspec`
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Create a github issue to discuss your idea
|
58
|
+
1. Fork it ( https://github.com/[your-github-username]/vagrant-winrm-file-download/fork )
|
59
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
1. Commit your changes, including relevant tests (`git commit -am 'Add some feature'`)
|
61
|
+
1. Squash commits & push to the branch (`git push origin my-new-feature`)
|
62
|
+
1. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
task :default => [:test]
|
4
|
+
# Remove 'install' task as the gem is installed to Vagrant, not to system
|
5
|
+
Rake::Task[:install].clear
|
6
|
+
namespace :test do
|
7
|
+
RSpec::Core::RakeTask.new('unit') do |task|
|
8
|
+
task.pattern = 'spec/**/*_spec.rb'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
desc "Run all tests"
|
12
|
+
task :test => ['test:unit']
|
13
|
+
task :spec => :test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module WinRmFileDownload
|
5
|
+
class Config < Vagrant.plugin("2", :config)
|
6
|
+
attr_accessor :source
|
7
|
+
attr_accessor :destination
|
8
|
+
|
9
|
+
def validate(machine)
|
10
|
+
errors = _detected_errors
|
11
|
+
|
12
|
+
if !source
|
13
|
+
errors << "No source file specified"
|
14
|
+
end
|
15
|
+
if !destination
|
16
|
+
errors << "No destination path specified"
|
17
|
+
end
|
18
|
+
{ "WinRm file download provisioner" => errors }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module WinRmFileDownload
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "winrm-file-download"
|
7
|
+
description <<-DESC
|
8
|
+
Provides support for downloading a file from the guest
|
9
|
+
to the host via WinRM.
|
10
|
+
DESC
|
11
|
+
|
12
|
+
config("winrm-file-download", :provisioner) do
|
13
|
+
require File.expand_path("../config", __FILE__)
|
14
|
+
Config
|
15
|
+
end
|
16
|
+
|
17
|
+
provisioner("winrm-file-download") do
|
18
|
+
require File.expand_path("../provisioner", __FILE__)
|
19
|
+
Provisioner
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module WinRmFileDownload
|
3
|
+
class Provisioner < Vagrant.plugin("2", :provisioner)
|
4
|
+
def provision
|
5
|
+
# this is pratically identical to https://github.com/hashicorp/vagrant/blob/9eac6ae62d6ad7acdd173fabe558ba75156245b6/plugins/provisioners/file/provisioner.rb
|
6
|
+
@machine.communicate.tap do |comm|
|
7
|
+
source = expand_guest_path(config.source)
|
8
|
+
destination = File.expand_path(config.destination)
|
9
|
+
|
10
|
+
# If the source is a directory determine if any path modifications
|
11
|
+
# need to be applied to the source for upload behavior. If the original
|
12
|
+
# source value ends with a "." or if the original source does not end
|
13
|
+
# with a "." but the original destination ends with a file separator
|
14
|
+
# then append a "." character to the new source. This ensures that
|
15
|
+
# the contents of the directory are uploaded to the destination and
|
16
|
+
# not folder itself.
|
17
|
+
if File.directory?(source)
|
18
|
+
if config.source.end_with?(".") ||
|
19
|
+
(!config.destination.end_with?(File::SEPARATOR) &&
|
20
|
+
!config.source.end_with?("#{File::SEPARATOR}."))
|
21
|
+
source = File.join(source, ".")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
@machine.ui.detail("Downloading from #{source} on guest to #{destination} on host.")
|
26
|
+
# now download the file
|
27
|
+
comm.download(source, destination)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# Expand the guest path if the guest has the capability
|
34
|
+
def expand_guest_path(destination)
|
35
|
+
if machine.guest.capability?(:shell_expand_guest_path)
|
36
|
+
machine.guest.capability(:shell_expand_guest_path, destination)
|
37
|
+
else
|
38
|
+
destination
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-winrm-file-download/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module WinRmFileDownload
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-winrm-file-download", __FILE__))
|
8
|
+
autoload :Action, lib_path.join("action")
|
9
|
+
autoload :Errors, lib_path.join("errors")
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant-winrm-file-download/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-winrm-file-download"
|
8
|
+
spec.version = Vagrant::WinRmFileDownload::VERSION
|
9
|
+
spec.authors = ["Matt Richardson"]
|
10
|
+
spec.email = ["matt.richardson@octopus.com"]
|
11
|
+
spec.summary = "WinRM file download Provisioner for Vagrant"
|
12
|
+
spec.description = "Provisioner plugin that downloads files from guest to host with Vagrant."
|
13
|
+
spec.homepage = "https://github.com/OctopusDeploy/vagrant-winrm-file-download"
|
14
|
+
spec.license = "Apache-2.0"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
end
|
data/vagrantfile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
|
3
|
+
# this is a sample file for using & testing the plugin
|
4
|
+
|
5
|
+
VAGRANT_FILE_API_VERSION = "2"
|
6
|
+
|
7
|
+
Vagrant.configure(VAGRANT_FILE_API_VERSION) do |config|
|
8
|
+
|
9
|
+
hostname = "vagrantdsc.local"
|
10
|
+
config.vm.guest = :windows
|
11
|
+
config.vm.communicator = :winrm
|
12
|
+
|
13
|
+
config.vm.allowed_synced_folder_types = [:winrm]
|
14
|
+
config.vm.synced_folder ".", "/vagrant", disabled: true
|
15
|
+
|
16
|
+
config.vm.provider "virtualbox" do |v, override|
|
17
|
+
v.gui = true
|
18
|
+
v.linked_clone = true
|
19
|
+
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
20
|
+
v.customize ["modifyvm", :id, "--audio", "none"]
|
21
|
+
v.customize ["modifyvm", :id, "--vram", "32"]
|
22
|
+
override.vm.box = "OctopusDeploy/dsc-test-server-windows-server-1803"
|
23
|
+
override.vm.box_url = "https://s3-ap-southeast-2.amazonaws.com/octopus-vagrant-boxes/vagrant/json/OctopusDeploy/virtualbox/dsc-test-server-windows-server-1803.json"
|
24
|
+
override.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
|
25
|
+
end
|
26
|
+
|
27
|
+
if Vagrant::Util::Platform.windows? then
|
28
|
+
config.vm.provider "hyperv" do |v, override|
|
29
|
+
override.vm.box = "OctopusDeploy/dsc-test-server-windows-server-1803"
|
30
|
+
override.vm.box_url = "https://s3-ap-southeast-2.amazonaws.com/octopus-vagrant-boxes/vagrant/json/OctopusDeploy/hyperv/dsc-test-server-windows-server-1803.json"
|
31
|
+
config.vm.network "public_network", bridge: "Default Switch"
|
32
|
+
v.memory = 2048
|
33
|
+
v.maxmemory = 2048
|
34
|
+
v.cpus = 2
|
35
|
+
override.vm.network :forwarded_port, guest: 5985, host: 5985, id: "winrm", auto_correct: true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# create a temp file
|
40
|
+
config.vm.provision "shell", inline: "get-date | set-content -path 'c:\\temp\\foo.txt'"
|
41
|
+
|
42
|
+
# download it
|
43
|
+
config.vm.provision "winrm-file-download" do |winrm|
|
44
|
+
winrm.source = 'c:\temp\foo.txt'
|
45
|
+
winrm.destination = 'c:\temp\foo-downloaded.txt'
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-winrm-file-download
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Richardson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provisioner plugin that downloads files from guest to host with Vagrant.
|
14
|
+
email:
|
15
|
+
- matt.richardson@octopus.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/vagrant-winrm-file-download.rb
|
26
|
+
- lib/vagrant-winrm-file-download/config.rb
|
27
|
+
- lib/vagrant-winrm-file-download/plugin.rb
|
28
|
+
- lib/vagrant-winrm-file-download/provisioner.rb
|
29
|
+
- lib/vagrant-winrm-file-download/version.rb
|
30
|
+
- vagrant-winrm-file-download.gemspec
|
31
|
+
- vagrantfile
|
32
|
+
homepage: https://github.com/OctopusDeploy/vagrant-winrm-file-download
|
33
|
+
licenses:
|
34
|
+
- Apache-2.0
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.1.2
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: WinRM file download Provisioner for Vagrant
|
55
|
+
test_files: []
|