poise-archive 1.2.1 → 1.3.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +20 -9
- data/lib/poise_archive/archive_providers/base.rb +30 -3
- data/lib/poise_archive/archive_providers/gnu_tar.rb +7 -7
- data/lib/poise_archive/archive_providers/tar.rb +2 -2
- data/lib/poise_archive/archive_providers/zip.rb +1 -1
- data/lib/poise_archive/resources/poise_archive.rb +71 -7
- data/lib/poise_archive/version.rb +1 -1
- data/test/cookbook/recipes/default.rb +23 -0
- data/test/integration/default/serverspec/default_spec.rb +6 -0
- data/test/spec/resources/poise_archive_spec.rb +64 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4242f7231038390f4f5fe3cbbffc7fc396ac5192
|
4
|
+
data.tar.gz: 52c718b6e9bef94592ca87e0eca89b5dd9d42929
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 986c52a2da5d576ecde9094a7362443a9ddb4bd2f50f05f7a58ef39d8a4e597c00c6e9a1f0dbd6805d27ce9c66fd9e82f1955f10e425edced02343d83009ef74
|
7
|
+
data.tar.gz: a35ad89c3af875f794553c898266a0a6e5f7676d486e1796b47ed0b240d43f379fe897e9cc9fd817c32de5693af245cd50e8818141bc485f0bc1c34d0193e515
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -16,15 +16,9 @@ It supports `.tar`, `.tar.gz`, `.tar.bz2`, and `.zip` archive files.
|
|
16
16
|
To download an unpack and archive:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
poise_archive 'myapp.tgz' do
|
20
|
-
action :nothing
|
19
|
+
poise_archive 'https://example.com/myapp.tgz' do
|
21
20
|
destination '/opt/myapp'
|
22
21
|
end
|
23
|
-
|
24
|
-
remote_file "#{Chef::Config[:file_cache_path]}/myapp.tgz" do
|
25
|
-
source 'https://example.com/myapp.tgz'
|
26
|
-
notifies :unpack, 'poise_archive[myapp.tgz]', :immediately
|
27
|
-
end
|
28
22
|
```
|
29
23
|
|
30
24
|
## Platforms
|
@@ -45,6 +39,19 @@ poise_archive '/tmp/myapp-1.2.0.tar' do
|
|
45
39
|
end
|
46
40
|
```
|
47
41
|
|
42
|
+
A URL can also be passed as the source path, optionally with extra properties to
|
43
|
+
be merged with `source_properties`.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
poise_archive 'http://example.com/myapp-1.2.0.zip' do
|
47
|
+
destination '/srv/myapp-1.2.0'
|
48
|
+
end
|
49
|
+
|
50
|
+
poise_archive ['http://example.com/myapp-1.2.0.zip', {headers: {'Authentication' => '...'}}] do
|
51
|
+
destination '/srv/myapp-1.2.0'
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
48
55
|
#### Actions
|
49
56
|
|
50
57
|
* `:unpack` – Unpack the archive. *(default)*
|
@@ -52,12 +59,16 @@ end
|
|
52
59
|
#### Properties
|
53
60
|
|
54
61
|
* `path` – Path to the archive. If relative, it is taken as a file inside
|
55
|
-
`Chef::Config[:file_cache_path]`.
|
62
|
+
`Chef::Config[:file_cache_path]`. If a URL, it is downloaded to a cache file
|
63
|
+
first. *(name attribute)*
|
56
64
|
* `destination` – Path to unpack the archive to. If not specified, the path of
|
57
|
-
the archive without the file extension is used.
|
65
|
+
the archive without the file extension is used. Required when unpacking from
|
66
|
+
a URL. *(default: auto)*
|
58
67
|
* `group` – Group to run the unpack as.
|
59
68
|
* `keep_existing` – Keep existing files in the destination directory when
|
60
69
|
unpacking. *(default: false)*
|
70
|
+
* `source_properties` – Property key/value pairs to be applied to the
|
71
|
+
`remote_file` file resource when downloading a URL. *(default: {retries: 5})*
|
61
72
|
* `strip_components` – Number of intermediary directories to skip when
|
62
73
|
unpacking. Works like GNU tar's `--strip-components`. *(default: 1)*
|
63
74
|
* `user` – User to run the unpack as.
|
@@ -55,7 +55,14 @@ module PoiseArchive
|
|
55
55
|
#
|
56
56
|
# @return [void]
|
57
57
|
def action_unpack
|
58
|
-
|
58
|
+
if new_resource.is_url?
|
59
|
+
download_resource = download_file
|
60
|
+
# Check if the download resource updated, if not don't run the rest
|
61
|
+
# of the unpack for idempotence. I could also check
|
62
|
+
# new_resource.updated? but this seems more future proof.
|
63
|
+
return if !download_resource.updated_by_last_action?
|
64
|
+
end
|
65
|
+
converge_by("unpack archive #{new_resource.path} to #{new_resource.destination}") do
|
59
66
|
notifying_block do
|
60
67
|
create_directory
|
61
68
|
end
|
@@ -66,11 +73,31 @@ module PoiseArchive
|
|
66
73
|
|
67
74
|
private
|
68
75
|
|
76
|
+
# Download the source file to a cache path.
|
77
|
+
#
|
78
|
+
# @return [Chef::Resource]
|
79
|
+
def download_file
|
80
|
+
# resource_state used for closure breaking on the notifying block.
|
81
|
+
resource_state = []
|
82
|
+
notifying_block do
|
83
|
+
# TODO handle cookbook:// for cookbook_file "downloads".
|
84
|
+
resource_state << remote_file(new_resource.absolute_path) do
|
85
|
+
source new_resource.path
|
86
|
+
retries 5 # As a default, could be overridden by source_properties.
|
87
|
+
new_resource.merged_source_properties.each do |key, value|
|
88
|
+
send(key, value)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
# Return the download resource for state tracking.
|
93
|
+
resource_state.first
|
94
|
+
end
|
95
|
+
|
69
96
|
# Make sure the destination directory exists.
|
70
97
|
#
|
71
98
|
# @return [void]
|
72
99
|
def create_directory
|
73
|
-
directory new_resource.
|
100
|
+
directory new_resource.destination do
|
74
101
|
group new_resource.group if new_resource.group
|
75
102
|
owner new_resource.user if new_resource.user
|
76
103
|
# There is explicitly no mode being set here. If a non-default mode
|
@@ -85,7 +112,7 @@ module PoiseArchive
|
|
85
112
|
def empty_directory
|
86
113
|
# If you want to keep it, not my problem.
|
87
114
|
return if new_resource.keep_existing
|
88
|
-
dest = new_resource.
|
115
|
+
dest = new_resource.destination
|
89
116
|
Dir.entries(dest).each do |entry|
|
90
117
|
next if entry == '.' || entry == '..'
|
91
118
|
FileUtils.remove_entry_secure(::File.join(dest, entry))
|
@@ -51,8 +51,8 @@ module PoiseArchive
|
|
51
51
|
# @return [void]
|
52
52
|
def install_prereqs
|
53
53
|
utils = ['tar']
|
54
|
-
utils << 'bzip2' if new_resource.
|
55
|
-
utils << 'xz-utils' if new_resource.
|
54
|
+
utils << 'bzip2' if new_resource.absolute_path =~ /\.t?bz/
|
55
|
+
utils << 'xz-utils' if new_resource.absolute_path =~ /\.t?xz/
|
56
56
|
# This is a resource.
|
57
57
|
package utils
|
58
58
|
end
|
@@ -64,17 +64,17 @@ module PoiseArchive
|
|
64
64
|
# Build the tar command.
|
65
65
|
cmd = %w{tar}
|
66
66
|
cmd << "--strip-components=#{new_resource.strip_components}" if new_resource.strip_components && new_resource.strip_components > 0
|
67
|
-
cmd << if new_resource.
|
67
|
+
cmd << if new_resource.absolute_path =~ /\.t?gz/
|
68
68
|
'-xzvf'
|
69
|
-
elsif new_resource.
|
69
|
+
elsif new_resource.absolute_path =~ /\.t?bz/
|
70
70
|
'-xjvf'
|
71
|
-
elsif new_resource.
|
71
|
+
elsif new_resource.absolute_path =~ /\.t?xz/
|
72
72
|
'-xJvf'
|
73
73
|
else
|
74
74
|
'-xvf'
|
75
75
|
end
|
76
|
-
cmd << new_resource.
|
77
|
-
poise_shell_out!(cmd, cwd: new_resource.
|
76
|
+
cmd << new_resource.absolute_path
|
77
|
+
poise_shell_out!(cmd, cwd: new_resource.destination, group: new_resource.group, user: new_resource.user)
|
78
78
|
end
|
79
79
|
|
80
80
|
end
|
@@ -108,8 +108,8 @@ module PoiseArchive
|
|
108
108
|
#
|
109
109
|
# @return [void]
|
110
110
|
def open_file!
|
111
|
-
@raw_file = ::File.open(new_resource.
|
112
|
-
@file = case new_resource.
|
111
|
+
@raw_file = ::File.open(new_resource.absolute_path, 'rb')
|
112
|
+
@file = case new_resource.absolute_path
|
113
113
|
when /\.tar$/
|
114
114
|
nil # So it uses @raw_file instead.
|
115
115
|
when /\.t?gz/
|
@@ -49,7 +49,7 @@ module PoiseArchive
|
|
49
49
|
|
50
50
|
def unpack_zip
|
51
51
|
@zip_entry_paths = []
|
52
|
-
::Zip::File.open(new_resource.
|
52
|
+
::Zip::File.open(new_resource.absolute_path) do |zip_file|
|
53
53
|
zip_file.each do |entry|
|
54
54
|
entry_name = entry.name.split(/\//).drop(new_resource.strip_components).join('/')
|
55
55
|
# If strip_components wiped out the name, don't process this entry.
|
@@ -14,6 +14,9 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
+
require 'base64'
|
18
|
+
require 'uri'
|
19
|
+
|
17
20
|
require 'chef/resource'
|
18
21
|
require 'poise'
|
19
22
|
|
@@ -29,6 +32,10 @@ module PoiseArchive
|
|
29
32
|
# @action unpack
|
30
33
|
# @example
|
31
34
|
# poise_archive '/opt/myapp.tgz'
|
35
|
+
# @example Downloading from a URL with options
|
36
|
+
# poise_archive ['http://example.com/myapp.zip', {headers: {'Authentication' => '...'}}] do
|
37
|
+
# destination '/opt/myapp'
|
38
|
+
# end
|
32
39
|
class Resource < Chef::Resource
|
33
40
|
include Poise
|
34
41
|
provides(:poise_archive)
|
@@ -36,14 +43,15 @@ module PoiseArchive
|
|
36
43
|
|
37
44
|
# @!attribute path
|
38
45
|
# Path to the archive. If relative, it is taken as a file inside
|
39
|
-
# `Chef::Config[:file_cache_path]`.
|
40
|
-
#
|
41
|
-
|
46
|
+
# `Chef::Config[:file_cache_path]`. Can also be a URL to download the
|
47
|
+
# archive from.
|
48
|
+
# @return [String, Array]
|
49
|
+
attribute(:path, kind_of: String, default: lazy { @raw_name.is_a?(Array) ? @raw_name[0] : name }, required: true)
|
42
50
|
# @!attribute destination
|
43
51
|
# Path to unpack the archive to. If not specified, the path of the
|
44
52
|
# archive without the file extension is used.
|
45
53
|
# @return [String, nil, false]
|
46
|
-
attribute(:destination, kind_of: [String, NilClass, FalseClass])
|
54
|
+
attribute(:destination, kind_of: [String, NilClass, FalseClass], default: lazy { default_destination })
|
47
55
|
# @!attribute group
|
48
56
|
# Group to run the unpack as.
|
49
57
|
# @return [String, Integer, nil, false]
|
@@ -52,6 +60,11 @@ module PoiseArchive
|
|
52
60
|
# Keep existing files in the destination directory when unpacking.
|
53
61
|
# @return [Boolean]
|
54
62
|
attribute(:keep_existing, equal_to: [true, false], default: false)
|
63
|
+
# @!attribute source_properties
|
64
|
+
# Properties to pass through to the underlying download resource if
|
65
|
+
# using one. Merged with the array form of {#name}.
|
66
|
+
# @return [Hash]
|
67
|
+
attribute(:source_properties, option_collector: true, forced_keys: %i{retries})
|
55
68
|
# @!attribute strip_components
|
56
69
|
# Number of intermediary directories to skip when unpacking. Works
|
57
70
|
# like GNU tar's --strip-components.
|
@@ -66,16 +79,67 @@ module PoiseArchive
|
|
66
79
|
# @api private
|
67
80
|
alias_method :owner, :user
|
68
81
|
|
82
|
+
def initialize(name, run_context)
|
83
|
+
@raw_name = name # Capture this before it gets coerced to a string.
|
84
|
+
super
|
85
|
+
end
|
86
|
+
|
87
|
+
# Regexp for URL-like paths.
|
88
|
+
# @api private
|
89
|
+
URL_PATHS = %r{^(\w+:)?//}
|
90
|
+
|
91
|
+
# Check if the source path is a URL.
|
92
|
+
#
|
93
|
+
# @api private
|
94
|
+
# @return [Boolean]
|
95
|
+
def is_url?
|
96
|
+
path =~ URL_PATHS
|
97
|
+
end
|
98
|
+
|
99
|
+
# Expand a relative file path against `Chef::Config[:file_cache_path]`.
|
100
|
+
# For URLs it returns the cache file path.
|
101
|
+
#
|
102
|
+
# @api private
|
103
|
+
# @return [String]
|
69
104
|
def absolute_path
|
70
|
-
|
105
|
+
if is_url?
|
106
|
+
# Use the last path component without the query string plus the name
|
107
|
+
# of the resource in Base64. This should be both mildly readable and
|
108
|
+
# also unique per invocation.
|
109
|
+
url_part = URI(path).path.split(/\//).last
|
110
|
+
base64_name = Base64.strict_encode64(name).gsub(/\=/, '')
|
111
|
+
::File.join(Chef::Config[:file_cache_path], "#{base64_name}_#{url_part}")
|
112
|
+
else
|
113
|
+
::File.expand_path(path, Chef::Config[:file_cache_path])
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Merge the explicit source properties with the array form of the name.
|
118
|
+
#
|
119
|
+
# @api private
|
120
|
+
# @return [Hash]
|
121
|
+
def merged_source_properties
|
122
|
+
if @raw_name.is_a?(Array) && @raw_name[1]
|
123
|
+
source_properties.merge(@raw_name[1])
|
124
|
+
else
|
125
|
+
source_properties
|
126
|
+
end
|
71
127
|
end
|
72
128
|
|
129
|
+
private
|
130
|
+
|
73
131
|
# Filename components to ignore.
|
74
132
|
# @api private
|
75
133
|
BASENAME_IGNORE = /(\.(t?(ar|gz|bz2?|xz)|zip))+$/
|
76
134
|
|
77
|
-
|
78
|
-
|
135
|
+
# Default value for the {#destination} property
|
136
|
+
#
|
137
|
+
# @api private
|
138
|
+
# @return [String]
|
139
|
+
def default_destination
|
140
|
+
if is_url?
|
141
|
+
raise ValueError.new("Destination for URL-based archive #{self} must be specified explicitly")
|
142
|
+
else
|
79
143
|
::File.join(::File.dirname(absolute_path), ::File.basename(path).gsub(BASENAME_IGNORE, ''))
|
80
144
|
end
|
81
145
|
end
|
@@ -29,6 +29,23 @@ user 'poise' do
|
|
29
29
|
system true
|
30
30
|
end
|
31
31
|
|
32
|
+
# Directory for HTTP serving.
|
33
|
+
directory '/test_http' do
|
34
|
+
mode '777'
|
35
|
+
end
|
36
|
+
|
37
|
+
# Copy all fixture files for HTTP serving.
|
38
|
+
%w{tar tar.gz tar.bz2 zip}.each do |ext|
|
39
|
+
cookbook_file "/test_http/myapp-1.0.0.#{ext}" do
|
40
|
+
source "myapp-1.0.0.#{ext}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Start up a background web server.
|
45
|
+
require 'webrick'
|
46
|
+
server = WEBrick::HTTPServer.new(Port: 8000, DocumentRoot: '/test_http')
|
47
|
+
Thread.new { server.start }
|
48
|
+
|
32
49
|
# Tests for each fixture file.
|
33
50
|
[
|
34
51
|
{ext: 'tar', provider: nil},
|
@@ -78,6 +95,12 @@ end
|
|
78
95
|
provider test[:provider] if test[:provider]
|
79
96
|
user 'poise'
|
80
97
|
end
|
98
|
+
|
99
|
+
poise_archive "#{test_base}/myapp-1.0.0.#{test[:ext]}_http" do
|
100
|
+
path "http://localhost:8000/myapp-1.0.0.#{test[:ext]}"
|
101
|
+
destination "#{test_base}/#{test[:ext]}_http"
|
102
|
+
provider test[:provider] if test[:provider]
|
103
|
+
end
|
81
104
|
end
|
82
105
|
|
83
106
|
# Some general tests for core features.
|
@@ -60,6 +60,12 @@ RSpec.shared_examples 'a poise_archive test' do |ext|
|
|
60
60
|
it { is_expected.to be_owned_by 'poise' }
|
61
61
|
it { is_expected.to be_mode '755' } unless os[:family] == 'windows'
|
62
62
|
end
|
63
|
+
describe file("#{base}_http/README") do
|
64
|
+
its(:content) { is_expected.to eq "This is a project!\n\n" }
|
65
|
+
end
|
66
|
+
describe file("#{base}_http/src/main.c") do
|
67
|
+
it { is_expected.to be_a_file }
|
68
|
+
end
|
63
69
|
end
|
64
70
|
|
65
71
|
describe 'default provider' do
|
@@ -23,7 +23,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
23
23
|
poise_archive '/tmp/myapp.tar'
|
24
24
|
end
|
25
25
|
|
26
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar').with(absolute_path: '/tmp/myapp.tar',
|
26
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar').with(absolute_path: '/tmp/myapp.tar', destination: '/tmp/myapp') }
|
27
27
|
end # /context an implicit destination
|
28
28
|
|
29
29
|
context 'an explicit destination' do
|
@@ -33,7 +33,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar').with(absolute_path: '/tmp/myapp.tar',
|
36
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar').with(absolute_path: '/tmp/myapp.tar', destination: '/opt/myapp') }
|
37
37
|
end # /context an explicit destination
|
38
38
|
end # /context an absolute path
|
39
39
|
|
@@ -54,7 +54,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
54
54
|
poise_archive 'myapp.tar'
|
55
55
|
end
|
56
56
|
|
57
|
-
it { is_expected.to unpack_poise_archive('myapp.tar').with(absolute_path: '/var/chef/cache/myapp.tar',
|
57
|
+
it { is_expected.to unpack_poise_archive('myapp.tar').with(absolute_path: '/var/chef/cache/myapp.tar', destination: '/var/chef/cache/myapp') }
|
58
58
|
end # /context an implicit destination
|
59
59
|
|
60
60
|
context 'an explicit destination' do
|
@@ -65,7 +65,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
it { is_expected.to unpack_poise_archive('myapp.tar').with(absolute_path: '/var/chef/cache/myapp.tar',
|
68
|
+
it { is_expected.to unpack_poise_archive('myapp.tar').with(absolute_path: '/var/chef/cache/myapp.tar', destination: '/opt/myapp') }
|
69
69
|
end # /context an explicit destination
|
70
70
|
end # /context a relative path
|
71
71
|
|
@@ -74,7 +74,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
74
74
|
poise_archive '/tmp/myapp.tar.gz'
|
75
75
|
end
|
76
76
|
|
77
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.gz').with(absolute_path: '/tmp/myapp.tar.gz',
|
77
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.gz').with(absolute_path: '/tmp/myapp.tar.gz', destination: '/tmp/myapp') }
|
78
78
|
end # /context with .tar.gz
|
79
79
|
|
80
80
|
context 'with .tgz' do
|
@@ -82,7 +82,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
82
82
|
poise_archive '/tmp/myapp.tgz'
|
83
83
|
end
|
84
84
|
|
85
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tgz').with(absolute_path: '/tmp/myapp.tgz',
|
85
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tgz').with(absolute_path: '/tmp/myapp.tgz', destination: '/tmp/myapp') }
|
86
86
|
end # /context with .tgz
|
87
87
|
|
88
88
|
context 'with .tar.bz2' do
|
@@ -90,7 +90,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
90
90
|
poise_archive '/tmp/myapp.tar.bz2'
|
91
91
|
end
|
92
92
|
|
93
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.bz2').with(absolute_path: '/tmp/myapp.tar.bz2',
|
93
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.bz2').with(absolute_path: '/tmp/myapp.tar.bz2', destination: '/tmp/myapp') }
|
94
94
|
end # /context with .tar.bz2
|
95
95
|
|
96
96
|
context 'with .tbz2' do
|
@@ -98,7 +98,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
98
98
|
poise_archive '/tmp/myapp.tbz2'
|
99
99
|
end
|
100
100
|
|
101
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tbz2').with(absolute_path: '/tmp/myapp.tbz2',
|
101
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tbz2').with(absolute_path: '/tmp/myapp.tbz2', destination: '/tmp/myapp') }
|
102
102
|
end # /context with .tbz2
|
103
103
|
|
104
104
|
context 'with .tar.xz' do
|
@@ -106,7 +106,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
106
106
|
poise_archive '/tmp/myapp.tar.xz'
|
107
107
|
end
|
108
108
|
|
109
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.xz').with(absolute_path: '/tmp/myapp.tar.xz',
|
109
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.tar.xz').with(absolute_path: '/tmp/myapp.tar.xz', destination: '/tmp/myapp') }
|
110
110
|
end # /context with .tar.xz
|
111
111
|
|
112
112
|
context 'with .txz' do
|
@@ -114,7 +114,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
114
114
|
poise_archive '/tmp/myapp.txz'
|
115
115
|
end
|
116
116
|
|
117
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.txz').with(absolute_path: '/tmp/myapp.txz',
|
117
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.txz').with(absolute_path: '/tmp/myapp.txz', destination: '/tmp/myapp') }
|
118
118
|
end # /context with .txz
|
119
119
|
|
120
120
|
context 'with .zip' do
|
@@ -122,7 +122,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
122
122
|
poise_archive '/tmp/myapp.zip'
|
123
123
|
end
|
124
124
|
|
125
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp.zip').with(absolute_path: '/tmp/myapp.zip',
|
125
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp.zip').with(absolute_path: '/tmp/myapp.zip', destination: '/tmp/myapp') }
|
126
126
|
end # /context with .zip
|
127
127
|
|
128
128
|
context 'with a hidden file' do
|
@@ -130,7 +130,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
130
130
|
poise_archive '/tmp/.myapp.tar'
|
131
131
|
end
|
132
132
|
|
133
|
-
it { is_expected.to unpack_poise_archive('/tmp/.myapp.tar').with(absolute_path: '/tmp/.myapp.tar',
|
133
|
+
it { is_expected.to unpack_poise_archive('/tmp/.myapp.tar').with(absolute_path: '/tmp/.myapp.tar', destination: '/tmp/.myapp') }
|
134
134
|
end # /context with a hidden file
|
135
135
|
|
136
136
|
context 'with a version number' do
|
@@ -138,7 +138,7 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
138
138
|
poise_archive '/tmp/myapp-1.0.0.tar'
|
139
139
|
end
|
140
140
|
|
141
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp-1.0.0.tar').with(absolute_path: '/tmp/myapp-1.0.0.tar',
|
141
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp-1.0.0.tar').with(absolute_path: '/tmp/myapp-1.0.0.tar', destination: '/tmp/myapp-1.0.0') }
|
142
142
|
end # /context with a version number
|
143
143
|
|
144
144
|
context 'with a version number and .tar.gz' do
|
@@ -146,6 +146,56 @@ describe PoiseArchive::Resources::PoiseArchive do
|
|
146
146
|
poise_archive '/tmp/myapp-1.0.0.tar.gz'
|
147
147
|
end
|
148
148
|
|
149
|
-
it { is_expected.to unpack_poise_archive('/tmp/myapp-1.0.0.tar.gz').with(absolute_path: '/tmp/myapp-1.0.0.tar.gz',
|
149
|
+
it { is_expected.to unpack_poise_archive('/tmp/myapp-1.0.0.tar.gz').with(absolute_path: '/tmp/myapp-1.0.0.tar.gz', destination: '/tmp/myapp-1.0.0') }
|
150
150
|
end # /context with a version number and .tar.gz
|
151
|
+
|
152
|
+
context 'with a URL' do
|
153
|
+
recipe do
|
154
|
+
Chef::Config[:file_cache_path] = '/var/chef/cache'
|
155
|
+
poise_archive 'http://example.com/myapp-1.0.0.zip' do
|
156
|
+
destination '/tmp/myapp'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
it { is_expected.to unpack_poise_archive('http://example.com/myapp-1.0.0.zip').with(path: 'http://example.com/myapp-1.0.0.zip', absolute_path: '/var/chef/cache/aHR0cDovL2V4YW1wbGUuY29tL215YXBwLTEuMC4wLnppcA_myapp-1.0.0.zip', destination: '/tmp/myapp', merged_source_properties: {}) }
|
161
|
+
end # /context with a URL
|
162
|
+
|
163
|
+
context 'with a URL and name properties' do
|
164
|
+
recipe do
|
165
|
+
Chef::Config[:file_cache_path] = '/var/chef/cache'
|
166
|
+
poise_archive ['http://example.com/myapp-1.0.0.zip', {retries: 0}] do
|
167
|
+
destination '/tmp/myapp'
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
it { is_expected.to unpack_poise_archive('http://example.com/myapp-1.0.0.zip, {:retries=>0}').with(path: 'http://example.com/myapp-1.0.0.zip', absolute_path: '/var/chef/cache/aHR0cDovL2V4YW1wbGUuY29tL215YXBwLTEuMC4wLnppcCwgezpyZXRyaWVzPT4wfQ_myapp-1.0.0.zip', destination: '/tmp/myapp', merged_source_properties: {'retries' => 0}) }
|
172
|
+
end # /context with a URL and name properties
|
173
|
+
|
174
|
+
context 'with a URL and source properties' do
|
175
|
+
recipe do
|
176
|
+
Chef::Config[:file_cache_path] = '/var/chef/cache'
|
177
|
+
poise_archive 'http://example.com/myapp-1.0.0.zip' do
|
178
|
+
destination '/tmp/myapp'
|
179
|
+
source_properties do
|
180
|
+
retries 0
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
it { is_expected.to unpack_poise_archive('http://example.com/myapp-1.0.0.zip').with(path: 'http://example.com/myapp-1.0.0.zip', absolute_path: '/var/chef/cache/aHR0cDovL2V4YW1wbGUuY29tL215YXBwLTEuMC4wLnppcA_myapp-1.0.0.zip', destination: '/tmp/myapp', merged_source_properties: {'retries' => 0}) }
|
186
|
+
end # /context with a URL and source properties
|
187
|
+
|
188
|
+
context 'with a URL and both properties' do
|
189
|
+
recipe do
|
190
|
+
Chef::Config[:file_cache_path] = '/var/chef/cache'
|
191
|
+
poise_archive ['http://example.com/myapp-1.0.0.zip', {retries: 100}] do
|
192
|
+
destination '/tmp/myapp'
|
193
|
+
source_properties do
|
194
|
+
retries 0
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
it { is_expected.to unpack_poise_archive('http://example.com/myapp-1.0.0.zip, {:retries=>100}').with(path: 'http://example.com/myapp-1.0.0.zip', absolute_path: '/var/chef/cache/aHR0cDovL2V4YW1wbGUuY29tL215YXBwLTEuMC4wLnppcCwgezpyZXRyaWVzPT4xMDB9_myapp-1.0.0.zip', destination: '/tmp/myapp', merged_source_properties: {'retries' => 100}) }
|
200
|
+
end # /context with a URL and both properties
|
151
201
|
end
|