mixlib-install 2.1.5 → 2.1.6
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/.travis.yml +9 -5
- data/CHANGELOG.md +5 -0
- data/Rakefile +17 -22
- data/acceptance/Gemfile +2 -0
- data/acceptance/powershell_install_ps1/inspec/verify.rb +1 -1
- data/ci/before-script.sh +0 -17
- data/ci/run-acceptance-tests.sh +13 -0
- data/lib/mixlib/install/backend/package_router.rb +2 -11
- data/lib/mixlib/install/cli.rb +8 -7
- data/lib/mixlib/install/generator/base.rb +2 -0
- data/lib/mixlib/install/generator/bourne.rb +2 -2
- data/lib/mixlib/install/generator/bourne/scripts/{helpers.sh → helpers.sh.erb} +4 -4
- data/lib/mixlib/install/generator/powershell.rb +2 -2
- data/lib/mixlib/install/generator/powershell/scripts/{helpers.ps1 → helpers.ps1.erb} +2 -0
- data/lib/mixlib/install/options.rb +28 -2
- data/lib/mixlib/install/util.rb +11 -0
- data/lib/mixlib/install/version.rb +1 -1
- metadata +6 -8
- data/ci/script.sh +0 -14
- data/functional/cli_spec.rb +0 -192
- data/functional/spec_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f03663421a576ba891fc10027bb6c121ac2b145
|
4
|
+
data.tar.gz: d79251c618528630ffcfe1e7423d0ef8e9b5b8dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a64cceb274f80740dd2a6200e7fff526ec070dc9cb4c5763ad8d623d364890b128e7be7bb68ae2acd19ee63415aee5e6fe5d5c2da88adc6809fc7247e12f82
|
7
|
+
data.tar.gz: 173618c2e2edf623300c6d7020c7eb365cb0bde55659f7cd5120c89bfd162f55b4c599d3cd38f9d36df0c9d83b05cdc881e75271130a2c0fffdd60cd08bb6aff
|
data/.travis.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
language: ruby
|
2
2
|
sudo: false
|
3
|
+
|
3
4
|
addons:
|
4
5
|
apt:
|
5
6
|
sources:
|
@@ -10,18 +11,21 @@ addons:
|
|
10
11
|
- unzip
|
11
12
|
- ssh
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
matrix:
|
15
|
+
include:
|
16
|
+
- rvm: 2.2.5
|
17
|
+
env: CHEF_ACCEPTANCE=false
|
18
|
+
- rvm: 2.3.0
|
19
|
+
env: CHEF_ACCEPTANCE=true
|
15
20
|
|
16
21
|
before_script:
|
17
22
|
- ci/before-script.sh
|
18
|
-
# set chefdk as default environment
|
19
|
-
- eval "$(/opt/chefdk/bin/chef shell-init bash)"
|
20
23
|
# put terraform on PATH
|
21
24
|
- export PATH="$PWD/bin:$PATH"
|
22
25
|
|
23
26
|
script:
|
24
|
-
- ci
|
27
|
+
- bundle exec rake travis:ci
|
28
|
+
- ci/run-acceptance-tests.sh
|
25
29
|
|
26
30
|
env:
|
27
31
|
global:
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -1,32 +1,25 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
begin
|
12
|
-
require "chefstyle"
|
13
|
-
require "rubocop/rake_task"
|
14
|
-
RuboCop::RakeTask.new(:style) do |task|
|
15
|
-
task.options += ["--display-cop-names", "--no-color"]
|
4
|
+
[:unit, :functional].each do |type|
|
5
|
+
RSpec::Core::RakeTask.new(type) do |t|
|
6
|
+
t.pattern = "spec/#{type}/**/*_spec.rb"
|
7
|
+
t.rspec_opts = [].tap do |a|
|
8
|
+
a.push("--color")
|
9
|
+
a.push("--format progress")
|
10
|
+
end.join(" ")
|
16
11
|
end
|
17
|
-
rescue LoadError
|
18
|
-
puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking."
|
19
12
|
end
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
require "chefstyle"
|
15
|
+
require "rubocop/rake_task"
|
16
|
+
RuboCop::RakeTask.new(:chefstyle) do |task|
|
17
|
+
task.options << "--display-cop-names"
|
18
|
+
end
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
namespace :travis do
|
21
|
+
desc "Run tests on Travis CI"
|
22
|
+
task ci: %w{chefstyle unit functional}
|
30
23
|
end
|
31
24
|
|
32
25
|
desc "Render product matrix documentation"
|
@@ -55,3 +48,5 @@ task :console do
|
|
55
48
|
ARGV.clear
|
56
49
|
IRB.start
|
57
50
|
end
|
51
|
+
|
52
|
+
task default: %w{travis:ci}
|
data/acceptance/Gemfile
CHANGED
data/ci/before-script.sh
CHANGED
@@ -2,23 +2,6 @@
|
|
2
2
|
|
3
3
|
set -evx
|
4
4
|
|
5
|
-
# undo travis gem and bundler config
|
6
|
-
for ruby_env_var in _ORIGINAL_GEM_PATH \
|
7
|
-
BUNDLE_BIN_PATH \
|
8
|
-
BUNDLE_GEMFILE \
|
9
|
-
GEM_HOME \
|
10
|
-
GEM_PATH \
|
11
|
-
GEM_ROOT \
|
12
|
-
RUBYLIB \
|
13
|
-
RUBYOPT \
|
14
|
-
RUBY_ENGINE \
|
15
|
-
RUBY_ROOT \
|
16
|
-
RUBY_VERSION
|
17
|
-
|
18
|
-
do
|
19
|
-
unset $ruby_env_var
|
20
|
-
done
|
21
|
-
|
22
5
|
# Don't run acceptance tests on forks. The decryption keys are not available.
|
23
6
|
if [ "${TRAVIS_REPO_SLUG}" = "chef/mixlib-install" ]; then
|
24
7
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -evx
|
4
|
+
|
5
|
+
# Don't run acceptance tests on forks. The decryption keys are not available.
|
6
|
+
if [ "${CHEF_ACCEPTANCE}" = "true" ] && [ "${TRAVIS_REPO_SLUG}" = "chef/mixlib-install" ]; then
|
7
|
+
# setup acceptance tests
|
8
|
+
cd acceptance
|
9
|
+
export BUNDLE_GEMFILE=$PWD/Gemfile
|
10
|
+
bundle install
|
11
|
+
# run acceptances tests and force cleanup
|
12
|
+
bundle exec chef-acceptance test --force-destroy
|
13
|
+
fi
|
@@ -20,6 +20,7 @@ require "json"
|
|
20
20
|
require "mixlib/install/artifact_info"
|
21
21
|
require "mixlib/install/backend/base"
|
22
22
|
require "mixlib/install/product"
|
23
|
+
require "mixlib/install/util"
|
23
24
|
require "net/http"
|
24
25
|
|
25
26
|
module Mixlib
|
@@ -156,19 +157,9 @@ Can not find any builds for #{options.product_name} in #{endpoint}.
|
|
156
157
|
end
|
157
158
|
|
158
159
|
def create_http_request(full_path)
|
159
|
-
require "mixlib/install/version"
|
160
|
-
|
161
160
|
request = Net::HTTP::Get.new(full_path)
|
162
161
|
|
163
|
-
|
164
|
-
|
165
|
-
if options.user_agent_headers
|
166
|
-
options.user_agent_headers.each do |header|
|
167
|
-
user_agents << header
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
request.add_field("User-Agent", user_agents.join(" "))
|
162
|
+
request.add_field("User-Agent", Util.user_agent_string(options.user_agent_headers))
|
172
163
|
|
173
164
|
request
|
174
165
|
end
|
data/lib/mixlib/install/cli.rb
CHANGED
@@ -20,7 +20,8 @@ module Mixlib
|
|
20
20
|
desc "download PRODUCT_NAME", "download an artifact"
|
21
21
|
option :channel,
|
22
22
|
default: :stable,
|
23
|
-
aliases: ["-c"]
|
23
|
+
aliases: ["-c"],
|
24
|
+
enum: Mixlib::Install::Options::SUPPORTED_CHANNELS.map(&:to_s)
|
24
25
|
option :version,
|
25
26
|
default: :latest,
|
26
27
|
aliases: ["-v"]
|
@@ -32,7 +33,9 @@ module Mixlib
|
|
32
33
|
option :platform_version,
|
33
34
|
aliases: ["-l"]
|
34
35
|
option :architecture,
|
35
|
-
|
36
|
+
default: "x86_64",
|
37
|
+
aliases: ["-a"],
|
38
|
+
enum: Mixlib::Install::Options::SUPPORTED_ARCHITECTURES.map(&:to_s)
|
36
39
|
option :url,
|
37
40
|
desc: "Print download URL without downloading the file",
|
38
41
|
type: :boolean
|
@@ -96,13 +99,11 @@ module Mixlib
|
|
96
99
|
desc: "Write script to file",
|
97
100
|
aliases: ["-o"]
|
98
101
|
option :type,
|
99
|
-
desc: "Install script type
|
102
|
+
desc: "Install script type",
|
100
103
|
aliases: ["-t"],
|
101
|
-
default: "sh"
|
104
|
+
default: "sh",
|
105
|
+
enum: Mixlib::Install::Options::SUPPORTED_SHELL_TYPES.map(&:to_s)
|
102
106
|
def install_script
|
103
|
-
if !Mixlib::Install::Options::SUPPORTED_SHELL_TYPES.include? options[:type].to_sym
|
104
|
-
abort "type must be one of: #{Mixlib::Install::Options::SUPPORTED_SHELL_TYPES.join(", ")}"
|
105
|
-
end
|
106
107
|
context = {}
|
107
108
|
context[:base_url] = options[:endpoint] if options[:endpoint]
|
108
109
|
script = eval("Mixlib::Install.install_#{options[:type]}(context)")
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
require "erb"
|
19
19
|
require "ostruct"
|
20
|
+
require "mixlib/install/util"
|
20
21
|
|
21
22
|
module Mixlib
|
22
23
|
class Install
|
@@ -47,6 +48,7 @@ module Mixlib
|
|
47
48
|
if File.exist? "#{script_path}.erb"
|
48
49
|
# Default values to use incase they are not set in the context
|
49
50
|
context[:base_url] ||= "https://omnitruck.chef.io"
|
51
|
+
context[:user_agent_string] = Util.user_agent_string(context[:user_agent_headers])
|
50
52
|
|
51
53
|
context_object = OpenStruct.new(context).instance_eval { binding }
|
52
54
|
ERB.new(File.read("#{script_path}.erb")).result(context_object)
|
@@ -23,7 +23,7 @@ module Mixlib
|
|
23
23
|
class Bourne < Base
|
24
24
|
def self.install_sh(context)
|
25
25
|
install_command = []
|
26
|
-
install_command << get_script("helpers.sh")
|
26
|
+
install_command << get_script("helpers.sh", context)
|
27
27
|
install_command << get_script("script_cli_parameters.sh")
|
28
28
|
install_command << get_script("platform_detection.sh")
|
29
29
|
install_command << get_script("fetch_metadata.sh", context)
|
@@ -42,7 +42,7 @@ module Mixlib
|
|
42
42
|
|
43
43
|
def install_command
|
44
44
|
install_command = []
|
45
|
-
install_command << get_script("helpers.sh")
|
45
|
+
install_command << get_script("helpers.sh", user_agent_headers: options.user_agent_headers)
|
46
46
|
install_command << render_variables
|
47
47
|
install_command << get_script("platform_detection.sh")
|
48
48
|
install_command << get_script("fetch_metadata.sh")
|
@@ -115,7 +115,7 @@ capture_tmp_stderr() {
|
|
115
115
|
# do_wget URL FILENAME
|
116
116
|
do_wget() {
|
117
117
|
echo "trying wget..."
|
118
|
-
wget -O "$2" "$1" 2>$tmp_dir/stderr
|
118
|
+
wget --user-agent="User-Agent: <%= user_agent_string %>" -O "$2" "$1" 2>$tmp_dir/stderr
|
119
119
|
rc=$?
|
120
120
|
# check for 404
|
121
121
|
grep "ERROR 404" $tmp_dir/stderr 2>&1 >/dev/null
|
@@ -136,7 +136,7 @@ do_wget() {
|
|
136
136
|
# do_curl URL FILENAME
|
137
137
|
do_curl() {
|
138
138
|
echo "trying curl..."
|
139
|
-
curl --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2"
|
139
|
+
curl -A "User-Agent: <%= user_agent_string %>" --retry 5 -sL -D $tmp_dir/stderr "$1" > "$2"
|
140
140
|
rc=$?
|
141
141
|
# check for 404
|
142
142
|
grep "404 Not Found" $tmp_dir/stderr 2>&1 >/dev/null
|
@@ -157,7 +157,7 @@ do_curl() {
|
|
157
157
|
# do_fetch URL FILENAME
|
158
158
|
do_fetch() {
|
159
159
|
echo "trying fetch..."
|
160
|
-
fetch -o "$2" "$1" 2>$tmp_dir/stderr
|
160
|
+
fetch --user-agent="User-Agent: <%= user_agent_string %>" -o "$2" "$1" 2>$tmp_dir/stderr
|
161
161
|
# check for bad return status
|
162
162
|
test $? -ne 0 && return 1
|
163
163
|
return 0
|
@@ -187,7 +187,7 @@ do_perl() {
|
|
187
187
|
# do_python URL FILENAME
|
188
188
|
do_python() {
|
189
189
|
echo "trying python..."
|
190
|
-
python -c "import sys,urllib2
|
190
|
+
python -c "import sys,urllib2; sys.stdout.write(urllib2.urlopen(urllib2.Request(sys.argv[1], headers={ 'User-Agent': '<%= user_agent_string %>' })).read())" "$1" > "$2" 2>$tmp_dir/stderr
|
191
191
|
rc=$?
|
192
192
|
# check for 404
|
193
193
|
grep "HTTP Error 404" $tmp_dir/stderr 2>&1 >/dev/null
|
@@ -23,7 +23,7 @@ module Mixlib
|
|
23
23
|
class PowerShell < Base
|
24
24
|
def self.install_ps1(context)
|
25
25
|
install_project_module = []
|
26
|
-
install_project_module << get_script("helpers.ps1")
|
26
|
+
install_project_module << get_script("helpers.ps1", context)
|
27
27
|
install_project_module << get_script("get_project_metadata.ps1", context)
|
28
28
|
install_project_module << get_script("install_project.ps1")
|
29
29
|
|
@@ -45,7 +45,7 @@ module Mixlib
|
|
45
45
|
|
46
46
|
def install_command
|
47
47
|
install_project_module = []
|
48
|
-
install_project_module << get_script("helpers.ps1")
|
48
|
+
install_project_module << get_script("helpers.ps1", user_agent_headers: options.user_agent_headers)
|
49
49
|
install_project_module << get_script("get_project_metadata.ps1")
|
50
50
|
install_project_module << get_script("install_project.ps1")
|
51
51
|
install_command = []
|
@@ -64,6 +64,7 @@ function Get-WebContentOnFullNet {
|
|
64
64
|
|
65
65
|
$proxy = New-Object -TypeName System.Net.WebProxy
|
66
66
|
$wc = new-object System.Net.WebClient
|
67
|
+
$wc.Headers.Add("user-agent", "<%= user_agent_string %>")
|
67
68
|
$proxy.Address = $env:http_proxy
|
68
69
|
$wc.Proxy = $proxy
|
69
70
|
|
@@ -80,6 +81,7 @@ function Get-WebContentOnCore {
|
|
80
81
|
|
81
82
|
$handler = New-Object System.Net.Http.HttpClientHandler
|
82
83
|
$client = New-Object System.Net.Http.HttpClient($handler)
|
84
|
+
$client.DefaultRequestHeaders.UserAgent.ParseAdd("<%= user_agent_string %>")
|
83
85
|
$client.Timeout = New-Object System.TimeSpan(0, 30, 0)
|
84
86
|
$cancelTokenSource = [System.Threading.CancellationTokenSource]::new()
|
85
87
|
$responseMsg = $client.GetAsync([System.Uri]::new($uri), $cancelTokenSource.Token)
|
@@ -26,9 +26,25 @@ module Mixlib
|
|
26
26
|
|
27
27
|
attr_reader :options
|
28
28
|
|
29
|
-
|
29
|
+
SUPPORTED_ARCHITECTURES = %w{
|
30
|
+
i386
|
31
|
+
powerpc
|
32
|
+
ppc64
|
33
|
+
ppc64le
|
34
|
+
s390x
|
35
|
+
sparc
|
36
|
+
x86_64
|
37
|
+
}
|
38
|
+
SUPPORTED_CHANNELS = [
|
39
|
+
:stable,
|
40
|
+
:current,
|
41
|
+
:unstable,
|
42
|
+
]
|
30
43
|
SUPPORTED_PRODUCT_NAMES = PRODUCT_MATRIX.products
|
31
|
-
SUPPORTED_SHELL_TYPES = [
|
44
|
+
SUPPORTED_SHELL_TYPES = [
|
45
|
+
:ps1,
|
46
|
+
:sh,
|
47
|
+
]
|
32
48
|
SUPPORTED_OPTIONS = [
|
33
49
|
:architecture,
|
34
50
|
:channel,
|
@@ -55,6 +71,7 @@ module Mixlib
|
|
55
71
|
def validate_options!
|
56
72
|
errors = []
|
57
73
|
|
74
|
+
errors << validate_architecture
|
58
75
|
errors << validate_product_names
|
59
76
|
errors << validate_channels
|
60
77
|
errors << validate_shell_type
|
@@ -107,6 +124,15 @@ module Mixlib
|
|
107
124
|
}
|
108
125
|
end
|
109
126
|
|
127
|
+
def validate_architecture
|
128
|
+
unless architecture.nil? || SUPPORTED_ARCHITECTURES.include?(architecture)
|
129
|
+
<<-EOS
|
130
|
+
Unknown architecture #{architecture}.
|
131
|
+
Must be one of: #{SUPPORTED_ARCHITECTURES.join(", ")}
|
132
|
+
EOS
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
110
136
|
def validate_product_names
|
111
137
|
unless SUPPORTED_PRODUCT_NAMES.include? product_name
|
112
138
|
<<-EOS
|
data/lib/mixlib/install/util.rb
CHANGED
@@ -118,6 +118,17 @@ module Mixlib
|
|
118
118
|
"sh -c '\n#{cmd}\n'"
|
119
119
|
end
|
120
120
|
|
121
|
+
# Build the user-agent string
|
122
|
+
#
|
123
|
+
# @param name [Array] headers
|
124
|
+
# @return [String] generated user-agent string
|
125
|
+
def user_agent_string(headers)
|
126
|
+
require "mixlib/install/version"
|
127
|
+
user_agents = %W{mixlib-install/#{Mixlib::Install::VERSION}}
|
128
|
+
user_agents << headers
|
129
|
+
# Ensure that if the default user agent is aleady set it doesn't get duplicated
|
130
|
+
user_agents.flatten.compact.uniq.join(" ")
|
131
|
+
end
|
121
132
|
end
|
122
133
|
end
|
123
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-install
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: artifactory
|
@@ -260,9 +260,7 @@ files:
|
|
260
260
|
- bin/mixlib-install
|
261
261
|
- ci/before-script.sh
|
262
262
|
- ci/es-infrastructure.pem.enc
|
263
|
-
- ci/
|
264
|
-
- functional/cli_spec.rb
|
265
|
-
- functional/spec_helper.rb
|
263
|
+
- ci/run-acceptance-tests.sh
|
266
264
|
- lib/mixlib/install.rb
|
267
265
|
- lib/mixlib/install/artifact_info.rb
|
268
266
|
- lib/mixlib/install/backend.rb
|
@@ -274,13 +272,13 @@ files:
|
|
274
272
|
- lib/mixlib/install/generator/bourne.rb
|
275
273
|
- lib/mixlib/install/generator/bourne/scripts/fetch_metadata.sh.erb
|
276
274
|
- lib/mixlib/install/generator/bourne/scripts/fetch_package.sh
|
277
|
-
- lib/mixlib/install/generator/bourne/scripts/helpers.sh
|
275
|
+
- lib/mixlib/install/generator/bourne/scripts/helpers.sh.erb
|
278
276
|
- lib/mixlib/install/generator/bourne/scripts/install_package.sh
|
279
277
|
- lib/mixlib/install/generator/bourne/scripts/platform_detection.sh
|
280
278
|
- lib/mixlib/install/generator/bourne/scripts/script_cli_parameters.sh
|
281
279
|
- lib/mixlib/install/generator/powershell.rb
|
282
280
|
- lib/mixlib/install/generator/powershell/scripts/get_project_metadata.ps1.erb
|
283
|
-
- lib/mixlib/install/generator/powershell/scripts/helpers.ps1
|
281
|
+
- lib/mixlib/install/generator/powershell/scripts/helpers.ps1.erb
|
284
282
|
- lib/mixlib/install/generator/powershell/scripts/install_project.ps1
|
285
283
|
- lib/mixlib/install/generator/powershell/scripts/platform_detection.ps1
|
286
284
|
- lib/mixlib/install/options.rb
|
@@ -311,7 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
309
|
version: '0'
|
312
310
|
requirements: []
|
313
311
|
rubyforge_project:
|
314
|
-
rubygems_version: 2.
|
312
|
+
rubygems_version: 2.4.5.1
|
315
313
|
signing_key:
|
316
314
|
specification_version: 4
|
317
315
|
summary: A mixin to help with omnitruck installs
|
data/ci/script.sh
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
set -evx
|
4
|
-
|
5
|
-
# run unit tests
|
6
|
-
/opt/chefdk/embedded/bin/bundle install && /opt/chefdk/bin/chef exec rake ci
|
7
|
-
|
8
|
-
# Don't run acceptance tests on forks. The decryption keys are not available.
|
9
|
-
if [ "${TRAVIS_REPO_SLUG}" = "chef/mixlib-install" ]; then
|
10
|
-
# setup acceptance tests
|
11
|
-
cd acceptance && export BUNDLE_GEMFILE=$PWD/Gemfile && /opt/chefdk/embedded/bin/bundle install && export APPBUNDLER_ALLOW_RVM=true
|
12
|
-
# run acceptances tests and force cleanup
|
13
|
-
/opt/chefdk/embedded/bin/bundle exec chef-acceptance test --force-destroy
|
14
|
-
fi
|
data/functional/cli_spec.rb
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2016 Chef, Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require_relative "./spec_helper"
|
19
|
-
require "mixlib/install/cli"
|
20
|
-
|
21
|
-
describe "mixlib-install executable", :type => :aruba do
|
22
|
-
let(:args) { nil }
|
23
|
-
|
24
|
-
before(:all) do
|
25
|
-
puts "
|
26
|
-
****************************************
|
27
|
-
TESTS ARE SLOW - DOWNLOADS PACKAGES.
|
28
|
-
****************************************
|
29
|
-
|
30
|
-
"
|
31
|
-
end
|
32
|
-
|
33
|
-
before(:each) { run("bin/mixlib-install #{command} #{args}") }
|
34
|
-
|
35
|
-
describe "version command" do
|
36
|
-
let(:command) { "version" }
|
37
|
-
|
38
|
-
it "prints the mixlib-install version" do
|
39
|
-
require "mixlib/install/version"
|
40
|
-
expect(last_command_started).to have_output Mixlib::Install::VERSION
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "list-versions command" do
|
45
|
-
let(:command) { "list-versions" }
|
46
|
-
|
47
|
-
context "with valid args" do
|
48
|
-
let(:args) { "chef stable" }
|
49
|
-
|
50
|
-
it "prints the versions" do
|
51
|
-
expect(last_command_started).to have_output /12.0.3/
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "with invalid args" do
|
56
|
-
let(:args) { "foo bar" }
|
57
|
-
|
58
|
-
it "returns error message" do
|
59
|
-
expect(last_command_started).to have_output /Unknown product name foo/
|
60
|
-
expect(last_command_started).to have_output /Unknown channel bar/
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe "install-script command" do
|
66
|
-
let(:command) { "install-script" }
|
67
|
-
|
68
|
-
context "with no args" do
|
69
|
-
it "returns shell script to stdout" do
|
70
|
-
expect(last_command_started).to have_output /end of install_package.sh/
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context "with ps1 type" do
|
75
|
-
let(:args) { "-t ps1" }
|
76
|
-
|
77
|
-
it "returns powershell script to stdout" do
|
78
|
-
expect(last_command_started).to have_output /export-modulemember -function 'Install-Project','Get-ProjectMetadata' -alias 'install'/
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context "with invalid type" do
|
83
|
-
let(:args) { "-t foo" }
|
84
|
-
|
85
|
-
it "errors an error" do
|
86
|
-
expect(last_command_started).to have_output /type must be one of/
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context "with alternate endpoint" do
|
91
|
-
let(:args) { "--endpoint https://omnitruck-custom.chef.io" }
|
92
|
-
|
93
|
-
it "contains the new endpoint" do
|
94
|
-
expect(last_command_started).to have_output /https:\/\/omnitruck-custom.chef.io/
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context "with output option" do
|
99
|
-
let(:args) { "-o script.sh" }
|
100
|
-
|
101
|
-
it "writes to a file" do
|
102
|
-
expect("script.sh").to be_an_existing_file
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "download command" do
|
108
|
-
let(:command) { "download" }
|
109
|
-
|
110
|
-
context "without args" do
|
111
|
-
it "exits with required args error" do
|
112
|
-
expect(last_command_started).to have_output /"mixlib-install #{command}" was called with no arguments/
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
context "with chef product" do
|
117
|
-
let(:args) { "chef" }
|
118
|
-
|
119
|
-
it "downloads a chef artifact" do
|
120
|
-
expect(last_command_started).to have_output /Download saved to/
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "with url flag" do
|
125
|
-
let(:args) { "chef --url" }
|
126
|
-
|
127
|
-
it "outputs the url" do
|
128
|
-
expect(last_command_started).to have_output /https:\/\/packages.chef.io\/files\/stable\/chef/
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
context "with attributes arg" do
|
133
|
-
let(:args) { "chef --url --attributes" }
|
134
|
-
|
135
|
-
it "outputs the attributes" do
|
136
|
-
expect(last_command_started).to have_output /"license": "Apache-2.0"/
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
context "with platform arg" do
|
141
|
-
let(:args) { "chef -p ubuntu" }
|
142
|
-
|
143
|
-
it "fails with missing args error" do
|
144
|
-
expect(last_command_started).to have_output /Must provide platform version and architecture when specifying a platform/
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "with valid platform version and architecture" do
|
149
|
-
let(:args) { "chef -p ubuntu -l 14.04 -a x86_64 --attributes" }
|
150
|
-
let(:latest_version) { Mixlib::Install.available_versions("chef", "stable").last }
|
151
|
-
let(:filename) { "chef_#{latest_version}-1_amd64.deb" }
|
152
|
-
|
153
|
-
it "has the correct artifact" do
|
154
|
-
require "digest"
|
155
|
-
sha256 = Digest::SHA256.hexdigest("./tmp/aruba/#{filename}")
|
156
|
-
expect(last_command_started).to have_output /sha256/
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
context "with invalid platform version and architecture" do
|
161
|
-
let(:args) { "chef -p ubuntu -l 99.99 -a x86_64" }
|
162
|
-
|
163
|
-
it "returns no results" do
|
164
|
-
expect(last_command_started).to have_output /No results found./
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
context "with specified version" do
|
169
|
-
let(:args) { "chef -v 12.0.3 " }
|
170
|
-
|
171
|
-
it "returns the correct artifact" do
|
172
|
-
expect(last_command_started).to have_output /chef[-_]12.0.3-1/
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
context "with specified channel" do
|
177
|
-
let(:args) { "chef -c current " }
|
178
|
-
|
179
|
-
it "returns the correct artifact" do
|
180
|
-
expect(last_command_started).to have_output /files\/current\/chef/
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
context "with specified directory" do
|
185
|
-
let(:args) { "chef -d mydir " }
|
186
|
-
|
187
|
-
it "downloads to dir" do
|
188
|
-
expect(last_command_started).to have_output /Download saved to .*mydir\/chef/
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
data/functional/spec_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "aruba/rspec"
|
2
|
-
|
3
|
-
Aruba.configure do |config|
|
4
|
-
config.exit_timeout = 120
|
5
|
-
config.io_wait_timeout = 2
|
6
|
-
config.activate_announcer_on_command_failure = [:stderr, :stdout, :command]
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.filter_run focus: true
|
11
|
-
config.run_all_when_everything_filtered = true
|
12
|
-
|
13
|
-
config.expect_with :rspec do |c|
|
14
|
-
c.syntax = :expect
|
15
|
-
end
|
16
|
-
end
|