pdk 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +25 -0
- data/README.md +41 -0
- data/lib/pdk.rb +0 -13
- data/lib/pdk/analytics.rb +18 -2
- data/lib/pdk/analytics/client/google_analytics.rb +3 -0
- data/lib/pdk/answer_file.rb +4 -1
- data/lib/pdk/cli.rb +7 -2
- data/lib/pdk/cli/build.rb +2 -2
- data/lib/pdk/cli/bundle.rb +7 -1
- data/lib/pdk/cli/console.rb +148 -0
- data/lib/pdk/cli/convert.rb +2 -2
- data/lib/pdk/cli/exec.rb +14 -14
- data/lib/pdk/cli/exec/command.rb +16 -11
- data/lib/pdk/cli/exec/interactive_command.rb +4 -0
- data/lib/pdk/cli/exec_group.rb +5 -5
- data/lib/pdk/cli/module/build.rb +0 -2
- data/lib/pdk/cli/module/generate.rb +1 -2
- data/lib/pdk/cli/new.rb +1 -1
- data/lib/pdk/cli/new/defined_type.rb +2 -0
- data/lib/pdk/cli/new/provider.rb +2 -0
- data/lib/pdk/cli/new/task.rb +2 -0
- data/lib/pdk/cli/new/{unit_test.rb → test.rb} +16 -12
- data/lib/pdk/cli/new/transport.rb +2 -0
- data/lib/pdk/cli/test/unit.rb +5 -3
- data/lib/pdk/cli/update.rb +2 -3
- data/lib/pdk/cli/util.rb +45 -14
- data/lib/pdk/cli/util/spinner.rb +2 -2
- data/lib/pdk/cli/validate.rb +6 -2
- data/lib/pdk/config.rb +20 -8
- data/lib/pdk/config/analytics_schema.json +26 -0
- data/lib/pdk/config/json.rb +14 -3
- data/lib/pdk/config/json_schema_namespace.rb +143 -0
- data/lib/pdk/config/json_schema_setting.rb +53 -0
- data/lib/pdk/config/json_with_schema.rb +50 -0
- data/lib/pdk/config/namespace.rb +84 -76
- data/lib/pdk/config/setting.rb +132 -0
- data/lib/pdk/config/yaml.rb +15 -3
- data/lib/pdk/config/yaml_with_schema.rb +59 -0
- data/lib/pdk/generate.rb +0 -2
- data/lib/pdk/generate/module.rb +29 -16
- data/lib/pdk/generate/puppet_object.rb +31 -28
- data/lib/pdk/module.rb +2 -2
- data/lib/pdk/module/build.rb +21 -8
- data/lib/pdk/module/convert.rb +64 -7
- data/lib/pdk/module/metadata.rb +5 -1
- data/lib/pdk/module/templatedir.rb +24 -7
- data/lib/pdk/module/update.rb +5 -1
- data/lib/pdk/module/update_manager.rb +21 -13
- data/lib/pdk/report.rb +4 -3
- data/lib/pdk/report/event.rb +5 -3
- data/lib/pdk/tests/unit.rb +36 -7
- data/lib/pdk/util.rb +20 -8
- data/lib/pdk/util/bundler.rb +14 -6
- data/lib/pdk/util/filesystem.rb +5 -0
- data/lib/pdk/util/git.rb +6 -0
- data/lib/pdk/util/puppet_strings.rb +24 -2
- data/lib/pdk/util/puppet_version.rb +25 -10
- data/lib/pdk/util/ruby_version.rb +13 -1
- data/lib/pdk/util/template_uri.rb +23 -2
- data/lib/pdk/util/vendored_file.rb +28 -24
- data/lib/pdk/util/version.rb +5 -5
- data/lib/pdk/validate/base_validator.rb +5 -4
- data/lib/pdk/validate/metadata/metadata_json_lint.rb +0 -4
- data/lib/pdk/validate/metadata/metadata_syntax.rb +5 -3
- data/lib/pdk/validate/metadata_validator.rb +0 -2
- data/lib/pdk/validate/puppet/puppet_epp.rb +4 -4
- data/lib/pdk/validate/puppet/puppet_lint.rb +0 -3
- data/lib/pdk/validate/puppet/puppet_syntax.rb +4 -4
- data/lib/pdk/validate/puppet_validator.rb +0 -2
- data/lib/pdk/validate/ruby/rubocop.rb +0 -5
- data/lib/pdk/validate/ruby_validator.rb +0 -2
- data/lib/pdk/validate/tasks/metadata_lint.rb +9 -5
- data/lib/pdk/validate/tasks/name.rb +4 -2
- data/lib/pdk/validate/tasks_validator.rb +0 -2
- data/lib/pdk/validate/yaml/syntax.rb +4 -4
- data/lib/pdk/validate/yaml_validator.rb +0 -2
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +351 -311
- metadata +11 -7
- data/lib/pdk/config/validator.rb +0 -31
- data/lib/pdk/config/value.rb +0 -94
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'pdk/util'
|
2
|
-
|
3
1
|
module PDK
|
4
2
|
module Util
|
5
3
|
class TemplateURI
|
@@ -34,6 +32,8 @@ module PDK
|
|
34
32
|
# /c:/foo#master (internal use only)
|
35
33
|
#
|
36
34
|
def initialize(opts_or_uri)
|
35
|
+
require 'addressable'
|
36
|
+
|
37
37
|
# If a uri string is passed, skip the valid uri finding code.
|
38
38
|
@uri = if opts_or_uri.is_a?(self.class)
|
39
39
|
opts_or_uri.uri
|
@@ -81,6 +81,8 @@ module PDK
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def self.git_remote(uri)
|
84
|
+
require 'addressable'
|
85
|
+
|
84
86
|
if uri.is_a?(Addressable::URI) && uri.fragment
|
85
87
|
human_readable(uri.to_s.chomp('#' + uri.fragment))
|
86
88
|
else
|
@@ -105,6 +107,9 @@ module PDK
|
|
105
107
|
|
106
108
|
# @returns PDK::Util::TemplateURI
|
107
109
|
def self.default_template_uri(ref = nil)
|
110
|
+
require 'pdk/util'
|
111
|
+
require 'addressable'
|
112
|
+
|
108
113
|
if PDK::Util.package_install?
|
109
114
|
PDK::Util::TemplateURI.new(Addressable::URI.new(scheme: 'file', host: '', path: File.join(PDK::Util.package_cachedir, 'pdk-templates.git'), fragment: ref))
|
110
115
|
else
|
@@ -117,6 +122,8 @@ module PDK
|
|
117
122
|
end
|
118
123
|
|
119
124
|
def ref_is_tag?
|
125
|
+
require 'pdk/util/git'
|
126
|
+
|
120
127
|
PDK::Util::Git.git('ls-remote', '--tags', '--exit-code', git_remote, git_ref)[:exit_code].zero?
|
121
128
|
end
|
122
129
|
|
@@ -140,6 +147,9 @@ module PDK
|
|
140
147
|
end
|
141
148
|
|
142
149
|
def self.parse_scp_url(url)
|
150
|
+
require 'pathname'
|
151
|
+
require 'addressable'
|
152
|
+
|
143
153
|
# Valid URIs to avoid catching:
|
144
154
|
# - absolute local paths
|
145
155
|
# - have :'s in paths when preceeded by a slash
|
@@ -168,6 +178,10 @@ module PDK
|
|
168
178
|
# the template file is not in this template directory.
|
169
179
|
#
|
170
180
|
def self.templates(opts)
|
181
|
+
require 'pdk/answer_file'
|
182
|
+
require 'pdk/util'
|
183
|
+
require 'addressable'
|
184
|
+
|
171
185
|
explicit_url = opts.fetch(:'template-url', nil)
|
172
186
|
explicit_ref = opts.fetch(:'template-ref', nil)
|
173
187
|
|
@@ -208,6 +222,9 @@ module PDK
|
|
208
222
|
|
209
223
|
# @returns String
|
210
224
|
def self.default_template_ref(uri = nil)
|
225
|
+
require 'pdk/util'
|
226
|
+
require 'pdk/version'
|
227
|
+
|
211
228
|
return 'master' if PDK::Util.development_mode?
|
212
229
|
return PDK::TEMPLATE_REF if uri.nil?
|
213
230
|
|
@@ -228,6 +245,10 @@ module PDK
|
|
228
245
|
end
|
229
246
|
|
230
247
|
def self.valid_template?(template)
|
248
|
+
require 'addressable'
|
249
|
+
require 'pdk/util/git'
|
250
|
+
require 'pdk/module/templatedir'
|
251
|
+
|
231
252
|
return false if template.nil? || !template.is_a?(Hash)
|
232
253
|
return false if template[:uri].nil? || !template[:uri].is_a?(Addressable::URI)
|
233
254
|
|
@@ -1,51 +1,50 @@
|
|
1
|
-
require 'pdk/util'
|
2
|
-
require 'net/https'
|
3
|
-
require 'openssl'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'pdk/util/filesystem'
|
6
|
-
|
7
1
|
module PDK
|
8
2
|
module Util
|
9
3
|
class VendoredFile
|
10
4
|
class DownloadError < StandardError; end
|
11
5
|
|
12
|
-
HTTP_ERRORS = [
|
13
|
-
EOFError,
|
14
|
-
Errno::ECONNRESET,
|
15
|
-
Errno::EINVAL,
|
16
|
-
Errno::ECONNREFUSED,
|
17
|
-
Net::HTTPBadResponse,
|
18
|
-
Net::HTTPHeaderSyntaxError,
|
19
|
-
Net::ProtocolError,
|
20
|
-
Timeout::Error,
|
21
|
-
].freeze
|
22
|
-
|
23
6
|
attr_reader :file_name
|
24
7
|
attr_reader :url
|
25
8
|
|
26
|
-
include PDK::Util::Filesystem
|
27
|
-
|
28
9
|
def initialize(file_name, url)
|
29
10
|
@file_name = file_name
|
30
11
|
@url = url
|
31
12
|
end
|
32
13
|
|
33
14
|
def read
|
34
|
-
|
35
|
-
|
15
|
+
require 'pdk/util'
|
16
|
+
require 'pdk/util/filesystem'
|
17
|
+
|
18
|
+
return PDK::Util::Filesystem.read_file(package_vendored_path) if PDK::Util.package_install?
|
19
|
+
return PDK::Util::Filesystem.read_file(gem_vendored_path) if PDK::Util::Filesystem.file?(gem_vendored_path)
|
36
20
|
|
37
21
|
content = download_file
|
38
22
|
|
39
23
|
# TODO: should only write if it's valid JSON
|
40
24
|
# TODO: need a way to invalidate if out of date
|
41
|
-
|
42
|
-
write_file(gem_vendored_path, content)
|
25
|
+
PDK::Util::Filesystem.mkdir_p(File.dirname(gem_vendored_path))
|
26
|
+
PDK::Util::Filesystem.write_file(gem_vendored_path, content)
|
43
27
|
content
|
44
28
|
end
|
45
29
|
|
46
30
|
private
|
47
31
|
|
48
32
|
def download_file
|
33
|
+
require 'uri'
|
34
|
+
require 'net/https'
|
35
|
+
require 'openssl'
|
36
|
+
|
37
|
+
http_errors = [
|
38
|
+
EOFError,
|
39
|
+
Errno::ECONNRESET,
|
40
|
+
Errno::EINVAL,
|
41
|
+
Errno::ECONNREFUSED,
|
42
|
+
Net::HTTPBadResponse,
|
43
|
+
Net::HTTPHeaderSyntaxError,
|
44
|
+
Net::ProtocolError,
|
45
|
+
Timeout::Error,
|
46
|
+
]
|
47
|
+
|
49
48
|
PDK.logger.debug _('%{file_name} was not found in the cache, downloading it from %{url}.') % {
|
50
49
|
file_name: file_name,
|
51
50
|
url: url,
|
@@ -69,7 +68,7 @@ module PDK
|
|
69
68
|
end
|
70
69
|
|
71
70
|
response.body
|
72
|
-
rescue *
|
71
|
+
rescue *http_errors => e
|
73
72
|
raise DownloadError, _('Unable to download %{url}. Check internet connectivity and try again. %{error}') % {
|
74
73
|
url: url,
|
75
74
|
error: e,
|
@@ -77,10 +76,15 @@ module PDK
|
|
77
76
|
end
|
78
77
|
|
79
78
|
def package_vendored_path
|
79
|
+
require 'pdk/util'
|
80
|
+
|
80
81
|
@package_vendored_path ||= File.join(PDK::Util.package_cachedir, file_name)
|
81
82
|
end
|
82
83
|
|
83
84
|
def gem_vendored_path
|
85
|
+
require 'pdk/util'
|
86
|
+
require 'pdk/version'
|
87
|
+
|
84
88
|
@gem_vendored_path ||= File.join(PDK::Util.cachedir, PDK::VERSION, file_name)
|
85
89
|
end
|
86
90
|
end
|
data/lib/pdk/util/version.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
|
-
require 'pdk/version'
|
2
|
-
require 'pdk/cli/exec'
|
3
|
-
require 'pdk/util/git'
|
4
|
-
require 'pdk/logger'
|
5
|
-
|
6
1
|
module PDK
|
7
2
|
module Util
|
8
3
|
module Version
|
9
4
|
def self.version_string
|
5
|
+
require 'pdk/version'
|
6
|
+
|
10
7
|
"#{PDK::VERSION} #{pdk_ref}".strip.freeze
|
11
8
|
end
|
12
9
|
|
@@ -25,6 +22,7 @@ module PDK
|
|
25
22
|
end
|
26
23
|
|
27
24
|
def self.git_ref
|
25
|
+
require 'pdk/util/git'
|
28
26
|
source_git_dir = File.join(File.expand_path('../../..', File.dirname(__FILE__)), '.git')
|
29
27
|
|
30
28
|
return unless File.directory?(source_git_dir)
|
@@ -33,6 +31,8 @@ module PDK
|
|
33
31
|
end
|
34
32
|
|
35
33
|
def self.version_file
|
34
|
+
require 'pdk/util'
|
35
|
+
|
36
36
|
# FIXME: this gets called a LOT and doesn't currently get cached
|
37
37
|
PDK::Util.find_upwards('PDK_VERSION', File.dirname(__FILE__))
|
38
38
|
end
|
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
|
-
require 'pdk/module'
|
4
|
-
|
5
1
|
module PDK
|
6
2
|
module Validate
|
7
3
|
class BaseValidator
|
@@ -82,6 +78,8 @@ module PDK
|
|
82
78
|
end
|
83
79
|
|
84
80
|
def self.ignore_pathspec
|
81
|
+
require 'pdk/module'
|
82
|
+
|
85
83
|
ignore_pathspec = PDK::Module.default_ignored_pathspec(ignore_dotfiles?)
|
86
84
|
|
87
85
|
if respond_to?(:pattern_ignore)
|
@@ -136,6 +134,8 @@ module PDK
|
|
136
134
|
end
|
137
135
|
|
138
136
|
def self.invoke(report, options = {})
|
137
|
+
require 'pdk/cli/exec/command'
|
138
|
+
|
139
139
|
targets, skipped, invalid = parse_targets(options)
|
140
140
|
|
141
141
|
process_skipped(report, skipped)
|
@@ -154,6 +154,7 @@ module PDK
|
|
154
154
|
if self::INVOKE_STYLE == :per_target
|
155
155
|
targets = targets.combination(1).to_a
|
156
156
|
else
|
157
|
+
require 'pdk/cli/exec_group'
|
157
158
|
targets = targets.each_slice(1000).to_a
|
158
159
|
options[:split_exec] = PDK::CLI::ExecGroup.new(spinner_text(targets), parallel: false)
|
159
160
|
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
1
|
require 'pdk/validate/base_validator'
|
4
|
-
require 'pathname'
|
5
2
|
|
6
3
|
module PDK
|
7
4
|
module Validate
|
@@ -21,13 +18,18 @@ module PDK
|
|
21
18
|
end
|
22
19
|
|
23
20
|
def self.create_spinner(targets = [], options = {})
|
21
|
+
require 'pdk/cli/util'
|
22
|
+
|
24
23
|
return unless PDK::CLI::Util.interactive?
|
24
|
+
|
25
25
|
options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
|
26
26
|
|
27
27
|
exec_group = options[:exec_group]
|
28
28
|
@spinner = if exec_group
|
29
29
|
exec_group.add_spinner(spinner_text(targets), options)
|
30
30
|
else
|
31
|
+
require 'pdk/cli/util/spinner'
|
32
|
+
|
31
33
|
TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
|
32
34
|
end
|
33
35
|
@spinner.auto_spin
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
1
|
require 'pdk/validate/base_validator'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'tmpdir'
|
6
2
|
|
7
3
|
module PDK
|
8
4
|
module Validate
|
@@ -63,6 +59,8 @@ module PDK
|
|
63
59
|
end
|
64
60
|
|
65
61
|
def self.validate_tmpdir
|
62
|
+
require 'tmpdir'
|
63
|
+
|
66
64
|
@validate_tmpdir ||= Dir.mktmpdir('puppet-epp-validate')
|
67
65
|
end
|
68
66
|
|
@@ -70,6 +68,8 @@ module PDK
|
|
70
68
|
return unless @validate_tmpdir
|
71
69
|
return unless File.directory?(@validate_tmpdir)
|
72
70
|
|
71
|
+
require 'fileutils'
|
72
|
+
|
73
73
|
FileUtils.remove_entry_secure(@validate_tmpdir)
|
74
74
|
@validate_tmpdir = nil
|
75
75
|
end
|
@@ -1,8 +1,4 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
1
|
require 'pdk/validate/base_validator'
|
4
|
-
require 'fileutils'
|
5
|
-
require 'tmpdir'
|
6
2
|
|
7
3
|
module PDK
|
8
4
|
module Validate
|
@@ -63,6 +59,8 @@ module PDK
|
|
63
59
|
end
|
64
60
|
|
65
61
|
def self.validate_tmpdir
|
62
|
+
require 'tmpdir'
|
63
|
+
|
66
64
|
@validate_tmpdir ||= Dir.mktmpdir('puppet-parser-validate')
|
67
65
|
end
|
68
66
|
|
@@ -70,6 +68,8 @@ module PDK
|
|
70
68
|
return unless @validate_tmpdir
|
71
69
|
return unless File.directory?(@validate_tmpdir)
|
72
70
|
|
71
|
+
require 'fileutils'
|
72
|
+
|
73
73
|
FileUtils.remove_entry_secure(@validate_tmpdir)
|
74
74
|
@validate_tmpdir = nil
|
75
75
|
end
|
@@ -1,9 +1,4 @@
|
|
1
|
-
require 'pdk'
|
2
|
-
require 'pdk/cli/exec'
|
3
1
|
require 'pdk/validate/base_validator'
|
4
|
-
require 'pdk/util'
|
5
|
-
require 'pathname'
|
6
|
-
require 'json-schema'
|
7
2
|
|
8
3
|
module PDK
|
9
4
|
module Validate
|
@@ -26,13 +21,18 @@ module PDK
|
|
26
21
|
end
|
27
22
|
|
28
23
|
def self.create_spinner(targets = [], options = {})
|
24
|
+
require 'pdk/cli/util'
|
25
|
+
|
29
26
|
return unless PDK::CLI::Util.interactive?
|
27
|
+
|
30
28
|
options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
|
31
29
|
|
32
30
|
exec_group = options[:exec_group]
|
33
31
|
@spinner = if exec_group
|
34
32
|
exec_group.add_spinner(spinner_text(targets), options)
|
35
33
|
else
|
34
|
+
require 'pdk/cli/util/spinner'
|
35
|
+
|
36
36
|
TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
|
37
37
|
end
|
38
38
|
@spinner.auto_spin
|
@@ -47,6 +47,8 @@ module PDK
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def self.schema_file
|
50
|
+
require 'pdk/util/vendored_file'
|
51
|
+
|
50
52
|
schema = PDK::Util::VendoredFile.new('task.json', FORGE_SCHEMA_URL).read
|
51
53
|
|
52
54
|
JSON.parse(schema)
|
@@ -67,6 +69,8 @@ module PDK
|
|
67
69
|
return_val = 0
|
68
70
|
create_spinner(targets, options)
|
69
71
|
|
72
|
+
require 'json-schema'
|
73
|
+
|
70
74
|
targets.each do |target|
|
71
75
|
unless File.readable?(target)
|
72
76
|
report.add_event(
|
@@ -1,6 +1,4 @@
|
|
1
|
-
require 'pdk'
|
2
1
|
require 'pdk/validate/base_validator'
|
3
|
-
require 'pdk/util'
|
4
2
|
|
5
3
|
module PDK
|
6
4
|
module Validate
|
@@ -26,6 +24,8 @@ module PDK
|
|
26
24
|
end
|
27
25
|
|
28
26
|
def self.create_spinner(targets = [], options = {})
|
27
|
+
require 'pdk/cli/util'
|
28
|
+
|
29
29
|
return unless PDK::CLI::Util.interactive?
|
30
30
|
options = options.merge(PDK::CLI::Util.spinner_opts_for_platform)
|
31
31
|
|
@@ -33,6 +33,8 @@ module PDK
|
|
33
33
|
@spinner = if exec_group
|
34
34
|
exec_group.add_spinner(spinner_text(targets), options)
|
35
35
|
else
|
36
|
+
require 'pdk/cli/util/spinner'
|
37
|
+
|
36
38
|
TTY::Spinner.new("[:spinner] #{spinner_text(targets)}", options)
|
37
39
|
end
|
38
40
|
@spinner.auto_spin
|