license-acceptance 2.0.0 → 2.1.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 +4 -4
- data/Gemfile +2 -2
- data/lib/license_acceptance/acceptor.rb +27 -13
- data/lib/license_acceptance/cli_flags/mixlib_cli.rb +1 -1
- data/lib/license_acceptance/cli_flags/thor.rb +1 -1
- data/lib/license_acceptance/product_reader.rb +1 -1
- data/lib/license_acceptance/strategy/argument.rb +15 -15
- data/lib/license_acceptance/strategy/environment.rb +10 -10
- data/lib/license_acceptance/strategy/file.rb +3 -3
- data/lib/license_acceptance/strategy/prompt.rb +2 -2
- data/lib/license_acceptance/strategy/provided_value.rb +4 -1
- data/lib/license_acceptance/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2e076dba9be610985535dca130a348b58d6beb27efba823d97fd86077d8d60
|
4
|
+
data.tar.gz: 6370bf24f3c58e13194975b9e0dbb06a2dc577cd5b632def8aa6b92acbaeeae4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93edc97194f0dc6556867113a1faf12ff559c28ab4b5ad41b1eeeca6a8a84305db55d2be10f251b6f0cf760630867b08912eef9a33757fa51ad69fbec4b66996
|
7
|
+
data.tar.gz: 767e584dc945ff8e324a965a574cd174905089b2918c2a99ca28221edba28616a9a23fa9dea624f66c3d67d688583719ccb648fc7fa1e5d871737eb7875f6662
|
data/Gemfile
CHANGED
@@ -6,9 +6,9 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
group :development do
|
9
|
-
gem "chefstyle", "1.2
|
9
|
+
gem "chefstyle", "1.3.2"
|
10
10
|
gem "climate_control", "~> 0.2"
|
11
|
-
gem "mixlib-cli", "~> 1
|
11
|
+
gem "mixlib-cli", "~> 2.1"
|
12
12
|
gem "rake", ">= 10.1.0"
|
13
13
|
gem "rspec", "~> 3.0"
|
14
14
|
gem "thor", ">= 0.20", "< 2.0" # validate 2.0 when it ships
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "forwardable"
|
1
|
+
require "forwardable" unless defined?(Forwardable)
|
2
2
|
require "license_acceptance/config"
|
3
3
|
require "license_acceptance/logger"
|
4
4
|
require "license_acceptance/product_reader"
|
@@ -74,21 +74,18 @@ module LicenseAcceptance
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
@acceptance_value = accepted_silent? ? ACCEPT_SILENT : ACCEPT
|
77
|
-
true
|
78
|
-
elsif config.output.isatty && prompt_strategy.request(missing_licenses) do
|
79
|
-
# We have to infer the acceptance value if they use the prompt to accept
|
80
|
-
if config.persist
|
81
|
-
@acceptance_value = ACCEPT # rubocop: disable Lint/AssignmentInCondition
|
82
|
-
file_strategy.persist(product_relationship, missing_licenses)
|
83
|
-
else
|
84
|
-
@acceptance_value = ACCEPT_NO_PERSIST # rubocop: disable Lint/AssignmentInCondition
|
85
|
-
[]
|
86
|
-
end
|
77
|
+
return true
|
87
78
|
end
|
88
|
-
|
89
|
-
|
79
|
+
|
80
|
+
if acceptance_value_provided?
|
81
|
+
value = provided_strategy.value || env_strategy.value || arg_strategy.value
|
82
|
+
output.puts("Unrecognized license acceptance value '#{value}', expected one of: '#{ACCEPT}', '#{ACCEPT_SILENT}', '#{ACCEPT_NO_PERSIST}'")
|
90
83
|
raise LicenseNotAcceptedError.new(product_relationship.parent, missing_licenses)
|
91
84
|
end
|
85
|
+
|
86
|
+
return true if output.isatty && accepted_license_prompt?(product_relationship, missing_licenses)
|
87
|
+
|
88
|
+
raise LicenseNotAcceptedError.new(product_relationship.parent, missing_licenses)
|
92
89
|
end
|
93
90
|
|
94
91
|
def self.check_and_persist!(product_id, version, opts = {})
|
@@ -99,6 +96,19 @@ module LicenseAcceptance
|
|
99
96
|
new(opts).check_and_persist(product_id, version)
|
100
97
|
end
|
101
98
|
|
99
|
+
def accepted_license_prompt?(product_relationship, missing_licenses)
|
100
|
+
prompt_strategy.request(missing_licenses) do
|
101
|
+
# We have to infer the acceptance value if they use the prompt to accept
|
102
|
+
if config.persist
|
103
|
+
@acceptance_value = ACCEPT
|
104
|
+
file_strategy.persist(product_relationship, missing_licenses)
|
105
|
+
else
|
106
|
+
@acceptance_value = ACCEPT_NO_PERSIST
|
107
|
+
[]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
102
112
|
# Check whether the specified product requires license acceptance for the given version.
|
103
113
|
def license_required?(mixlib_name, version)
|
104
114
|
product = product_reader.lookup_by_mixlib(mixlib_name)
|
@@ -140,6 +150,10 @@ module LicenseAcceptance
|
|
140
150
|
provided_strategy.silent? || env_strategy.silent? || arg_strategy.silent?
|
141
151
|
end
|
142
152
|
|
153
|
+
def acceptance_value_provided?
|
154
|
+
provided_strategy.value? || env_strategy.value? || arg_strategy.value?
|
155
|
+
end
|
156
|
+
|
143
157
|
# In the case where users accept with a command line argument or environment variable
|
144
158
|
# we still want to output the fact that the filesystem was changed.
|
145
159
|
def output_num_persisted(count)
|
@@ -6,6 +6,8 @@ module LicenseAcceptance
|
|
6
6
|
# Look for acceptance values in the ARGV
|
7
7
|
class Argument < Base
|
8
8
|
|
9
|
+
FLAG = "--chef-license".freeze
|
10
|
+
|
9
11
|
attr_reader :argv
|
10
12
|
|
11
13
|
def initialize(argv)
|
@@ -13,32 +15,30 @@ module LicenseAcceptance
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def accepted?
|
16
|
-
|
18
|
+
String(value).downcase == ACCEPT
|
17
19
|
end
|
18
20
|
|
19
21
|
def silent?
|
20
|
-
|
22
|
+
String(value).downcase == ACCEPT_SILENT
|
21
23
|
end
|
22
24
|
|
23
25
|
def no_persist?
|
24
|
-
|
26
|
+
String(value).downcase == ACCEPT_NO_PERSIST
|
27
|
+
end
|
28
|
+
|
29
|
+
def value?
|
30
|
+
argv.any? { |s| s == FLAG || s.start_with?("#{FLAG}=") }
|
25
31
|
end
|
26
32
|
|
27
|
-
|
33
|
+
def value
|
34
|
+
match = argv.detect { |s| s.start_with?("#{FLAG}=") }
|
35
|
+
return match.split("=").last if match
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
return true
|
37
|
+
argv.each_cons(2) do |arg, value|
|
38
|
+
return value if arg == FLAG
|
32
39
|
end
|
33
40
|
|
34
|
-
|
35
|
-
unless i.nil?
|
36
|
-
val = argv[i + 1]
|
37
|
-
if !val.nil? && val.downcase == sought
|
38
|
-
return true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
false
|
41
|
+
nil
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -6,6 +6,8 @@ module LicenseAcceptance
|
|
6
6
|
# Look for acceptance values in the environment
|
7
7
|
class Environment < Base
|
8
8
|
|
9
|
+
ENV_KEY = "CHEF_LICENSE".freeze
|
10
|
+
|
9
11
|
attr_reader :env
|
10
12
|
|
11
13
|
def initialize(env)
|
@@ -13,25 +15,23 @@ module LicenseAcceptance
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def accepted?
|
16
|
-
|
18
|
+
String(value).downcase == ACCEPT
|
17
19
|
end
|
18
20
|
|
19
21
|
def silent?
|
20
|
-
|
22
|
+
String(value).downcase == ACCEPT_SILENT
|
21
23
|
end
|
22
24
|
|
23
25
|
def no_persist?
|
24
|
-
|
26
|
+
String(value).downcase == ACCEPT_NO_PERSIST
|
25
27
|
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if env["CHEF_LICENSE"] && env["CHEF_LICENSE"].downcase == sought
|
31
|
-
return true
|
32
|
-
end
|
29
|
+
def value?
|
30
|
+
env.key?(ENV_KEY)
|
31
|
+
end
|
33
32
|
|
34
|
-
|
33
|
+
def value
|
34
|
+
env[ENV_KEY]
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "date"
|
2
|
-
|
3
|
-
require "fileutils"
|
4
|
-
require "etc"
|
2
|
+
autoload :YAML, "yaml"
|
3
|
+
require "fileutils" unless defined?(FileUtils)
|
4
|
+
require "etc" unless defined?(Etc)
|
5
5
|
require "license_acceptance/logger"
|
6
6
|
require "license_acceptance/strategy/base"
|
7
7
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
autoload :TTY, "tty-prompt"
|
2
2
|
require "pastel"
|
3
3
|
require "license_acceptance/logger"
|
4
4
|
require "license_acceptance/strategy/base"
|
5
|
-
require "timeout"
|
5
|
+
require "timeout" unless defined?(Timeout)
|
6
6
|
|
7
7
|
module LicenseAcceptance
|
8
8
|
module Strategy
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: license-acceptance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tyler-ball
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pastel
|