pdk 2.3.0 → 2.4.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 +1329 -1321
- data/LICENSE +201 -201
- data/README.md +163 -163
- data/exe/pdk +10 -10
- data/lib/pdk/analytics/client/google_analytics.rb +143 -143
- data/lib/pdk/analytics/client/noop.rb +25 -25
- data/lib/pdk/analytics/util.rb +19 -19
- data/lib/pdk/analytics.rb +30 -30
- data/lib/pdk/answer_file.rb +12 -12
- data/lib/pdk/bolt.rb +19 -19
- data/lib/pdk/cli/build.rb +82 -82
- data/lib/pdk/cli/bundle.rb +48 -48
- data/lib/pdk/cli/config/get.rb +26 -26
- data/lib/pdk/cli/config.rb +22 -22
- data/lib/pdk/cli/console.rb +148 -148
- data/lib/pdk/cli/convert.rb +52 -52
- data/lib/pdk/cli/env.rb +52 -52
- data/lib/pdk/cli/errors.rb +25 -25
- data/lib/pdk/cli/exec/command.rb +293 -293
- data/lib/pdk/cli/exec/interactive_command.rb +114 -114
- data/lib/pdk/cli/exec.rb +84 -84
- data/lib/pdk/cli/exec_group.rb +104 -104
- data/lib/pdk/cli/get/config.rb +24 -24
- data/lib/pdk/cli/get.rb +20 -20
- data/lib/pdk/cli/module/build.rb +12 -12
- data/lib/pdk/cli/module/generate.rb +47 -47
- data/lib/pdk/cli/module.rb +14 -14
- data/lib/pdk/cli/new/class.rb +32 -32
- data/lib/pdk/cli/new/defined_type.rb +32 -32
- data/lib/pdk/cli/new/fact.rb +29 -29
- data/lib/pdk/cli/new/function.rb +29 -29
- data/lib/pdk/cli/new/module.rb +53 -53
- data/lib/pdk/cli/new/provider.rb +29 -29
- data/lib/pdk/cli/new/task.rb +34 -34
- data/lib/pdk/cli/new/test.rb +52 -52
- data/lib/pdk/cli/new/transport.rb +27 -27
- data/lib/pdk/cli/new.rb +21 -21
- data/lib/pdk/cli/release/prep.rb +39 -39
- data/lib/pdk/cli/release/publish.rb +50 -50
- data/lib/pdk/cli/release.rb +194 -194
- data/lib/pdk/cli/remove/config.rb +80 -80
- data/lib/pdk/cli/remove.rb +20 -20
- data/lib/pdk/cli/set/config.rb +119 -119
- data/lib/pdk/cli/set.rb +20 -20
- data/lib/pdk/cli/test/unit.rb +90 -90
- data/lib/pdk/cli/test.rb +11 -11
- data/lib/pdk/cli/update.rb +64 -64
- data/lib/pdk/cli/util/command_redirector.rb +27 -27
- data/lib/pdk/cli/util/interview.rb +72 -72
- data/lib/pdk/cli/util/option_normalizer.rb +55 -55
- data/lib/pdk/cli/util/option_validator.rb +68 -68
- data/lib/pdk/cli/util/spinner.rb +13 -13
- data/lib/pdk/cli/util/update_manager_printer.rb +82 -82
- data/lib/pdk/cli/util.rb +305 -305
- data/lib/pdk/cli/validate.rb +116 -116
- data/lib/pdk/cli.rb +175 -175
- data/lib/pdk/config/analytics_schema.json +26 -26
- data/lib/pdk/config/errors.rb +5 -5
- data/lib/pdk/config/ini_file.rb +183 -183
- data/lib/pdk/config/ini_file_setting.rb +39 -39
- data/lib/pdk/config/json.rb +34 -34
- data/lib/pdk/config/json_schema_namespace.rb +142 -142
- data/lib/pdk/config/json_schema_setting.rb +53 -53
- data/lib/pdk/config/json_with_schema.rb +49 -49
- data/lib/pdk/config/namespace.rb +354 -354
- data/lib/pdk/config/setting.rb +135 -135
- data/lib/pdk/config/validator.rb +31 -31
- data/lib/pdk/config/yaml.rb +46 -46
- data/lib/pdk/config/yaml_with_schema.rb +59 -59
- data/lib/pdk/config.rb +390 -390
- data/lib/pdk/context/control_repo.rb +60 -60
- data/lib/pdk/context/module.rb +28 -28
- data/lib/pdk/context/none.rb +22 -22
- data/lib/pdk/context.rb +99 -99
- data/lib/pdk/control_repo.rb +90 -90
- data/lib/pdk/generate/defined_type.rb +43 -43
- data/lib/pdk/generate/fact.rb +25 -25
- data/lib/pdk/generate/function.rb +48 -48
- data/lib/pdk/generate/module.rb +352 -352
- data/lib/pdk/generate/provider.rb +28 -28
- data/lib/pdk/generate/puppet_class.rb +43 -43
- data/lib/pdk/generate/puppet_object.rb +232 -232
- data/lib/pdk/generate/task.rb +68 -68
- data/lib/pdk/generate/transport.rb +33 -33
- data/lib/pdk/generate.rb +24 -24
- data/lib/pdk/i18n.rb +4 -4
- data/lib/pdk/logger.rb +45 -45
- data/lib/pdk/module/build.rb +322 -322
- data/lib/pdk/module/convert.rb +296 -296
- data/lib/pdk/module/metadata.rb +202 -202
- data/lib/pdk/module/release.rb +260 -260
- data/lib/pdk/module/update.rb +131 -131
- data/lib/pdk/module/update_manager.rb +227 -227
- data/lib/pdk/module.rb +30 -30
- data/lib/pdk/report/event.rb +370 -370
- data/lib/pdk/report.rb +121 -121
- data/lib/pdk/template/fetcher/git.rb +85 -85
- data/lib/pdk/template/fetcher/local.rb +28 -28
- data/lib/pdk/template/fetcher.rb +98 -98
- data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +116 -116
- data/lib/pdk/template/renderer/v1/renderer.rb +132 -132
- data/lib/pdk/template/renderer/v1/template_file.rb +102 -102
- data/lib/pdk/template/renderer/v1.rb +25 -25
- data/lib/pdk/template/renderer.rb +96 -96
- data/lib/pdk/template/template_dir.rb +67 -67
- data/lib/pdk/template.rb +59 -59
- data/lib/pdk/tests/unit.rb +252 -252
- data/lib/pdk/util/bundler.rb +259 -259
- data/lib/pdk/util/changelog_generator.rb +137 -137
- data/lib/pdk/util/env.rb +47 -47
- data/lib/pdk/util/filesystem.rb +138 -138
- data/lib/pdk/util/git.rb +179 -179
- data/lib/pdk/util/json_finder.rb +85 -85
- data/lib/pdk/util/puppet_strings.rb +125 -125
- data/lib/pdk/util/puppet_version.rb +266 -266
- data/lib/pdk/util/ruby_version.rb +179 -179
- data/lib/pdk/util/template_uri.rb +295 -295
- data/lib/pdk/util/vendored_file.rb +93 -93
- data/lib/pdk/util/version.rb +43 -43
- data/lib/pdk/util/windows/api_types.rb +82 -82
- data/lib/pdk/util/windows/file.rb +36 -36
- data/lib/pdk/util/windows/process.rb +79 -79
- data/lib/pdk/util/windows/string.rb +16 -16
- data/lib/pdk/util/windows.rb +15 -15
- data/lib/pdk/util.rb +278 -277
- data/lib/pdk/validate/control_repo/control_repo_validator_group.rb +23 -23
- data/lib/pdk/validate/control_repo/environment_conf_validator.rb +98 -98
- data/lib/pdk/validate/external_command_validator.rb +208 -208
- data/lib/pdk/validate/internal_ruby_validator.rb +100 -100
- data/lib/pdk/validate/invokable_validator.rb +228 -228
- data/lib/pdk/validate/metadata/metadata_json_lint_validator.rb +86 -86
- data/lib/pdk/validate/metadata/metadata_syntax_validator.rb +78 -78
- data/lib/pdk/validate/metadata/metadata_validator_group.rb +20 -20
- data/lib/pdk/validate/puppet/puppet_epp_validator.rb +133 -133
- data/lib/pdk/validate/puppet/puppet_lint_validator.rb +66 -66
- data/lib/pdk/validate/puppet/puppet_syntax_validator.rb +137 -137
- data/lib/pdk/validate/puppet/puppet_validator_group.rb +21 -21
- data/lib/pdk/validate/ruby/ruby_rubocop_validator.rb +80 -80
- data/lib/pdk/validate/ruby/ruby_validator_group.rb +19 -19
- data/lib/pdk/validate/tasks/tasks_metadata_lint_validator.rb +88 -88
- data/lib/pdk/validate/tasks/tasks_name_validator.rb +50 -50
- data/lib/pdk/validate/tasks/tasks_validator_group.rb +20 -20
- data/lib/pdk/validate/validator.rb +118 -118
- data/lib/pdk/validate/validator_group.rb +104 -104
- data/lib/pdk/validate/yaml/yaml_syntax_validator.rb +95 -95
- data/lib/pdk/validate/yaml/yaml_validator_group.rb +19 -19
- data/lib/pdk/validate.rb +94 -94
- data/lib/pdk/version.rb +4 -4
- data/lib/pdk.rb +76 -76
- data/locales/config.yaml +21 -21
- data/locales/pdk.pot +2094 -2094
- metadata +5 -6
data/lib/pdk/cli/release.rb
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
require 'pdk/cli/util'
|
|
2
|
-
require 'pdk/validate'
|
|
3
|
-
require 'pdk/util/bundler'
|
|
4
|
-
require 'pdk/cli/util/interview'
|
|
5
|
-
require 'pdk/util/changelog_generator'
|
|
6
|
-
require 'pdk/module/build'
|
|
7
|
-
|
|
8
|
-
module PDK::CLI
|
|
9
|
-
@release_cmd = @base_cmd.define_command do
|
|
10
|
-
name 'release'
|
|
11
|
-
usage _('release [options]')
|
|
12
|
-
summary _('(Experimental) Release a module to the Puppet Forge.')
|
|
13
|
-
|
|
14
|
-
flag nil, :force, _('Release the module automatically, with no prompts.')
|
|
15
|
-
flag nil, :'skip-validation', _('Skips the module validation check.')
|
|
16
|
-
flag nil, :'skip-changelog', _('Skips the automatic changelog generation.')
|
|
17
|
-
flag nil, :'skip-dependency', _('Skips the module dependency check.')
|
|
18
|
-
flag nil, :'skip-documentation', _('Skips the documentation update.')
|
|
19
|
-
flag nil, :'skip-build', _('Skips module build.')
|
|
20
|
-
flag nil, :'skip-publish', _('Skips publishing the module to the forge.')
|
|
21
|
-
|
|
22
|
-
option nil, :'forge-upload-url', _('Set forge upload url path.'),
|
|
23
|
-
argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
|
|
24
|
-
|
|
25
|
-
option nil, :'forge-token', _('Set Forge API token.'),
|
|
26
|
-
argument: :optional
|
|
27
|
-
|
|
28
|
-
option nil, :version, _('Update the module to the specified version prior to release. When not specified, the new version will be computed from the Changelog where possible.'),
|
|
29
|
-
argument: :required
|
|
30
|
-
|
|
31
|
-
option nil, :file, _('Path to the built module to push to the Forge. This option can only be used when --skip-build is also used. Defaults to pkg/<module version>.tar.gz'),
|
|
32
|
-
argument: :required
|
|
33
|
-
|
|
34
|
-
run do |opts, _args, _cmd|
|
|
35
|
-
# Make sure build is being run in a valid module directory with a metadata.json
|
|
36
|
-
PDK::CLI::Util.ensure_in_module!(
|
|
37
|
-
message: _('`pdk release` can only be run from inside a valid module with a metadata.json.'),
|
|
38
|
-
log_level: :info,
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
Release.prepare_interview(opts) unless opts[:force]
|
|
42
|
-
|
|
43
|
-
Release.send_analytics('release', opts)
|
|
44
|
-
|
|
45
|
-
release = PDK::Module::Release.new(nil, opts)
|
|
46
|
-
|
|
47
|
-
Release.module_compatibility_checks!(release, opts)
|
|
48
|
-
|
|
49
|
-
release.run
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
module Release
|
|
54
|
-
# Checks whether the module is compatible with PDK release process
|
|
55
|
-
# @param release PDK::Module::Release Object representing the release
|
|
56
|
-
# @param opts Options Hash from Cri
|
|
57
|
-
def self.module_compatibility_checks!(release, opts)
|
|
58
|
-
unless release.module_metadata.forge_ready?
|
|
59
|
-
if opts[:force]
|
|
60
|
-
PDK.logger.warn _(
|
|
61
|
-
'This module is missing the following fields in the metadata.json: %{fields}. ' \
|
|
62
|
-
'These missing fields may affect the visibility of the module on the Forge.',
|
|
63
|
-
) % {
|
|
64
|
-
fields: release.module_metadata.missing_fields.join(', '),
|
|
65
|
-
}
|
|
66
|
-
else
|
|
67
|
-
release.module_metadata.interview_for_forge!
|
|
68
|
-
release.write_module_metadata!
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
unless release.pdk_compatible? # rubocop:disable Style/GuardClause Nope!
|
|
73
|
-
if opts[:force]
|
|
74
|
-
PDK.logger.warn _('This module is not compatible with PDK, so PDK can not validate or test this build.')
|
|
75
|
-
else
|
|
76
|
-
PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
|
|
77
|
-
'Unvalidated modules may have errors when uploading to the Forge. ' \
|
|
78
|
-
'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')
|
|
79
|
-
unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
|
|
80
|
-
PDK.logger.info _('Build cancelled; exiting.')
|
|
81
|
-
PDK::Util.exit_process(1)
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# Send_analytics for the given command and Cri options
|
|
88
|
-
def self.send_analytics(command, opts)
|
|
89
|
-
# Don't pass tokens to analytics
|
|
90
|
-
PDK::CLI::Util.analytics_screen_view(command, opts.reject { |k, _| k == :'forge-token' })
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def self.prepare_interview(opts)
|
|
94
|
-
questions = []
|
|
95
|
-
|
|
96
|
-
unless opts[:'skip-validation']
|
|
97
|
-
questions << {
|
|
98
|
-
name: 'validation',
|
|
99
|
-
question: _('Do you want to run the module validation ?'),
|
|
100
|
-
type: :yes,
|
|
101
|
-
}
|
|
102
|
-
end
|
|
103
|
-
unless opts[:'skip-changelog']
|
|
104
|
-
questions << {
|
|
105
|
-
name: 'changelog',
|
|
106
|
-
question: _('Do you want to run the automatic changelog generation ?'),
|
|
107
|
-
type: :yes,
|
|
108
|
-
}
|
|
109
|
-
end
|
|
110
|
-
unless opts[:version]
|
|
111
|
-
questions << {
|
|
112
|
-
name: 'setversion',
|
|
113
|
-
question: _('Do you want to set the module version ?'),
|
|
114
|
-
type: :yes,
|
|
115
|
-
}
|
|
116
|
-
end
|
|
117
|
-
unless opts[:'skip-dependency']
|
|
118
|
-
questions << {
|
|
119
|
-
name: 'dependency',
|
|
120
|
-
question: _('Do you want to run the dependency-checker on this module?'),
|
|
121
|
-
type: :yes,
|
|
122
|
-
}
|
|
123
|
-
end
|
|
124
|
-
unless opts[:'skip-documentation']
|
|
125
|
-
questions << {
|
|
126
|
-
name: 'documentation',
|
|
127
|
-
question: _('Do you want to update the documentation for this module?'),
|
|
128
|
-
type: :yes,
|
|
129
|
-
}
|
|
130
|
-
end
|
|
131
|
-
unless opts[:'skip-publish']
|
|
132
|
-
questions << {
|
|
133
|
-
name: 'publish',
|
|
134
|
-
question: _('Do you want to publish the module on the Puppet Forge?'),
|
|
135
|
-
type: :yes,
|
|
136
|
-
}
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
prompt = TTY::Prompt.new(help_color: :cyan)
|
|
140
|
-
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
141
|
-
interview.add_questions(questions)
|
|
142
|
-
answers = interview.run
|
|
143
|
-
|
|
144
|
-
unless answers.nil?
|
|
145
|
-
opts[:'skip-validation'] = !answers['validation']
|
|
146
|
-
opts[:'skip-changelog'] = !answers['changelog']
|
|
147
|
-
opts[:'skip-dependency'] = !answers['dependency']
|
|
148
|
-
opts[:'skip-documentation'] = !answers['documentation']
|
|
149
|
-
opts[:'skip-publish'] = !answers['publish']
|
|
150
|
-
|
|
151
|
-
prepare_version_interview(prompt, opts) if answers['setversion']
|
|
152
|
-
|
|
153
|
-
prepare_publish_interview(prompt, opts) if answers['publish']
|
|
154
|
-
end
|
|
155
|
-
answers
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def self.prepare_version_interview(prompt, opts)
|
|
159
|
-
questions = [
|
|
160
|
-
{
|
|
161
|
-
name: 'version',
|
|
162
|
-
question: _('Please set the module version'),
|
|
163
|
-
help: _('This value is the version that will be used in the changelog generator and building of the module.'),
|
|
164
|
-
required: true,
|
|
165
|
-
validate_pattern: %r{(\*|\d+(\.\d+){0,2}(\.\*)?)$}i,
|
|
166
|
-
validate_message: _('The version format should be in the format x.y.z where x represents the major version, y the minor version and z the build number.'),
|
|
167
|
-
},
|
|
168
|
-
]
|
|
169
|
-
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
170
|
-
interview.add_questions(questions)
|
|
171
|
-
ver_answer = interview.run
|
|
172
|
-
opts[:version] = ver_answer['version']
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def self.prepare_publish_interview(prompt, opts)
|
|
176
|
-
return if opts[:'forge-token']
|
|
177
|
-
questions = [
|
|
178
|
-
{
|
|
179
|
-
name: 'apikey',
|
|
180
|
-
question: _('Please set the api key(authorization token) to upload on the Puppet Forge'),
|
|
181
|
-
help: _('This value is used for authentication on the Puppet Forge to upload your module tarball.'),
|
|
182
|
-
required: true,
|
|
183
|
-
},
|
|
184
|
-
]
|
|
185
|
-
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
186
|
-
interview.add_questions(questions)
|
|
187
|
-
api_answer = interview.run
|
|
188
|
-
opts[:'forge-token'] = api_answer['apikey']
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
require 'pdk/cli/release/prep'
|
|
194
|
-
require 'pdk/cli/release/publish'
|
|
1
|
+
require 'pdk/cli/util'
|
|
2
|
+
require 'pdk/validate'
|
|
3
|
+
require 'pdk/util/bundler'
|
|
4
|
+
require 'pdk/cli/util/interview'
|
|
5
|
+
require 'pdk/util/changelog_generator'
|
|
6
|
+
require 'pdk/module/build'
|
|
7
|
+
|
|
8
|
+
module PDK::CLI
|
|
9
|
+
@release_cmd = @base_cmd.define_command do
|
|
10
|
+
name 'release'
|
|
11
|
+
usage _('release [options]')
|
|
12
|
+
summary _('(Experimental) Release a module to the Puppet Forge.')
|
|
13
|
+
|
|
14
|
+
flag nil, :force, _('Release the module automatically, with no prompts.')
|
|
15
|
+
flag nil, :'skip-validation', _('Skips the module validation check.')
|
|
16
|
+
flag nil, :'skip-changelog', _('Skips the automatic changelog generation.')
|
|
17
|
+
flag nil, :'skip-dependency', _('Skips the module dependency check.')
|
|
18
|
+
flag nil, :'skip-documentation', _('Skips the documentation update.')
|
|
19
|
+
flag nil, :'skip-build', _('Skips module build.')
|
|
20
|
+
flag nil, :'skip-publish', _('Skips publishing the module to the forge.')
|
|
21
|
+
|
|
22
|
+
option nil, :'forge-upload-url', _('Set forge upload url path.'),
|
|
23
|
+
argument: :required, default: 'https://forgeapi.puppetlabs.com/v3/releases'
|
|
24
|
+
|
|
25
|
+
option nil, :'forge-token', _('Set Forge API token.'),
|
|
26
|
+
argument: :optional
|
|
27
|
+
|
|
28
|
+
option nil, :version, _('Update the module to the specified version prior to release. When not specified, the new version will be computed from the Changelog where possible.'),
|
|
29
|
+
argument: :required
|
|
30
|
+
|
|
31
|
+
option nil, :file, _('Path to the built module to push to the Forge. This option can only be used when --skip-build is also used. Defaults to pkg/<module version>.tar.gz'),
|
|
32
|
+
argument: :required
|
|
33
|
+
|
|
34
|
+
run do |opts, _args, _cmd|
|
|
35
|
+
# Make sure build is being run in a valid module directory with a metadata.json
|
|
36
|
+
PDK::CLI::Util.ensure_in_module!(
|
|
37
|
+
message: _('`pdk release` can only be run from inside a valid module with a metadata.json.'),
|
|
38
|
+
log_level: :info,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
Release.prepare_interview(opts) unless opts[:force]
|
|
42
|
+
|
|
43
|
+
Release.send_analytics('release', opts)
|
|
44
|
+
|
|
45
|
+
release = PDK::Module::Release.new(nil, opts)
|
|
46
|
+
|
|
47
|
+
Release.module_compatibility_checks!(release, opts)
|
|
48
|
+
|
|
49
|
+
release.run
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
module Release
|
|
54
|
+
# Checks whether the module is compatible with PDK release process
|
|
55
|
+
# @param release PDK::Module::Release Object representing the release
|
|
56
|
+
# @param opts Options Hash from Cri
|
|
57
|
+
def self.module_compatibility_checks!(release, opts)
|
|
58
|
+
unless release.module_metadata.forge_ready?
|
|
59
|
+
if opts[:force]
|
|
60
|
+
PDK.logger.warn _(
|
|
61
|
+
'This module is missing the following fields in the metadata.json: %{fields}. ' \
|
|
62
|
+
'These missing fields may affect the visibility of the module on the Forge.',
|
|
63
|
+
) % {
|
|
64
|
+
fields: release.module_metadata.missing_fields.join(', '),
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
release.module_metadata.interview_for_forge!
|
|
68
|
+
release.write_module_metadata!
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
unless release.pdk_compatible? # rubocop:disable Style/GuardClause Nope!
|
|
73
|
+
if opts[:force]
|
|
74
|
+
PDK.logger.warn _('This module is not compatible with PDK, so PDK can not validate or test this build.')
|
|
75
|
+
else
|
|
76
|
+
PDK.logger.info _('This module is not compatible with PDK, so PDK can not validate or test this build. ' \
|
|
77
|
+
'Unvalidated modules may have errors when uploading to the Forge. ' \
|
|
78
|
+
'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.')
|
|
79
|
+
unless PDK::CLI::Util.prompt_for_yes(_('Continue build without converting?'))
|
|
80
|
+
PDK.logger.info _('Build cancelled; exiting.')
|
|
81
|
+
PDK::Util.exit_process(1)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Send_analytics for the given command and Cri options
|
|
88
|
+
def self.send_analytics(command, opts)
|
|
89
|
+
# Don't pass tokens to analytics
|
|
90
|
+
PDK::CLI::Util.analytics_screen_view(command, opts.reject { |k, _| k == :'forge-token' })
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def self.prepare_interview(opts)
|
|
94
|
+
questions = []
|
|
95
|
+
|
|
96
|
+
unless opts[:'skip-validation']
|
|
97
|
+
questions << {
|
|
98
|
+
name: 'validation',
|
|
99
|
+
question: _('Do you want to run the module validation ?'),
|
|
100
|
+
type: :yes,
|
|
101
|
+
}
|
|
102
|
+
end
|
|
103
|
+
unless opts[:'skip-changelog']
|
|
104
|
+
questions << {
|
|
105
|
+
name: 'changelog',
|
|
106
|
+
question: _('Do you want to run the automatic changelog generation ?'),
|
|
107
|
+
type: :yes,
|
|
108
|
+
}
|
|
109
|
+
end
|
|
110
|
+
unless opts[:version]
|
|
111
|
+
questions << {
|
|
112
|
+
name: 'setversion',
|
|
113
|
+
question: _('Do you want to set the module version ?'),
|
|
114
|
+
type: :yes,
|
|
115
|
+
}
|
|
116
|
+
end
|
|
117
|
+
unless opts[:'skip-dependency']
|
|
118
|
+
questions << {
|
|
119
|
+
name: 'dependency',
|
|
120
|
+
question: _('Do you want to run the dependency-checker on this module?'),
|
|
121
|
+
type: :yes,
|
|
122
|
+
}
|
|
123
|
+
end
|
|
124
|
+
unless opts[:'skip-documentation']
|
|
125
|
+
questions << {
|
|
126
|
+
name: 'documentation',
|
|
127
|
+
question: _('Do you want to update the documentation for this module?'),
|
|
128
|
+
type: :yes,
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
unless opts[:'skip-publish']
|
|
132
|
+
questions << {
|
|
133
|
+
name: 'publish',
|
|
134
|
+
question: _('Do you want to publish the module on the Puppet Forge?'),
|
|
135
|
+
type: :yes,
|
|
136
|
+
}
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
prompt = TTY::Prompt.new(help_color: :cyan)
|
|
140
|
+
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
141
|
+
interview.add_questions(questions)
|
|
142
|
+
answers = interview.run
|
|
143
|
+
|
|
144
|
+
unless answers.nil?
|
|
145
|
+
opts[:'skip-validation'] = !answers['validation']
|
|
146
|
+
opts[:'skip-changelog'] = !answers['changelog']
|
|
147
|
+
opts[:'skip-dependency'] = !answers['dependency']
|
|
148
|
+
opts[:'skip-documentation'] = !answers['documentation']
|
|
149
|
+
opts[:'skip-publish'] = !answers['publish']
|
|
150
|
+
|
|
151
|
+
prepare_version_interview(prompt, opts) if answers['setversion']
|
|
152
|
+
|
|
153
|
+
prepare_publish_interview(prompt, opts) if answers['publish']
|
|
154
|
+
end
|
|
155
|
+
answers
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
def self.prepare_version_interview(prompt, opts)
|
|
159
|
+
questions = [
|
|
160
|
+
{
|
|
161
|
+
name: 'version',
|
|
162
|
+
question: _('Please set the module version'),
|
|
163
|
+
help: _('This value is the version that will be used in the changelog generator and building of the module.'),
|
|
164
|
+
required: true,
|
|
165
|
+
validate_pattern: %r{(\*|\d+(\.\d+){0,2}(\.\*)?)$}i,
|
|
166
|
+
validate_message: _('The version format should be in the format x.y.z where x represents the major version, y the minor version and z the build number.'),
|
|
167
|
+
},
|
|
168
|
+
]
|
|
169
|
+
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
170
|
+
interview.add_questions(questions)
|
|
171
|
+
ver_answer = interview.run
|
|
172
|
+
opts[:version] = ver_answer['version']
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def self.prepare_publish_interview(prompt, opts)
|
|
176
|
+
return if opts[:'forge-token']
|
|
177
|
+
questions = [
|
|
178
|
+
{
|
|
179
|
+
name: 'apikey',
|
|
180
|
+
question: _('Please set the api key(authorization token) to upload on the Puppet Forge'),
|
|
181
|
+
help: _('This value is used for authentication on the Puppet Forge to upload your module tarball.'),
|
|
182
|
+
required: true,
|
|
183
|
+
},
|
|
184
|
+
]
|
|
185
|
+
interview = PDK::CLI::Util::Interview.new(prompt)
|
|
186
|
+
interview.add_questions(questions)
|
|
187
|
+
api_answer = interview.run
|
|
188
|
+
opts[:'forge-token'] = api_answer['apikey']
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
require 'pdk/cli/release/prep'
|
|
194
|
+
require 'pdk/cli/release/publish'
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
module PDK::CLI
|
|
2
|
-
module Remove
|
|
3
|
-
module Config
|
|
4
|
-
def self.run(opts, args)
|
|
5
|
-
item_name = (args.count > 0) ? args[0] : nil
|
|
6
|
-
item_value = (args.count > 1) ? args[1].strip : nil
|
|
7
|
-
item_value = nil if !item_value.nil? && item_value.empty?
|
|
8
|
-
|
|
9
|
-
force = opts[:force] || false
|
|
10
|
-
|
|
11
|
-
raise PDK::CLI::ExitWithError, _('Configuration name is required') if item_name.nil?
|
|
12
|
-
|
|
13
|
-
current_value = PDK.config.get(item_name)
|
|
14
|
-
raise PDK::CLI::ExitWithError, _("The configuration item '%{name}' can not be removed.") % { name: item_name } if current_value.is_a?(PDK::Config::Namespace)
|
|
15
|
-
if current_value.nil?
|
|
16
|
-
PDK.logger.info(_("Could not remove '%{name}' as it has not been set") % { name: item_name })
|
|
17
|
-
return 0
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
PDK.logger.info(_("Ignoring the item value '%{value}' as --force has been set") % { value: item_value }) if current_value.is_a?(Array) && !item_value.nil? && force
|
|
21
|
-
PDK.logger.info(_('Ignoring --force as the setting is not multi-valued')) if !current_value.is_a?(Array) && force
|
|
22
|
-
|
|
23
|
-
# FIXME: It'd be nice to shortcircuit deleting default values. This causes the configuration file
|
|
24
|
-
# to be saved, even though nothing actually changes
|
|
25
|
-
|
|
26
|
-
# For most value types, just changing the value to nil is enough, however Arrays are a special case.
|
|
27
|
-
# Unless they're forced, array removal with either remove a single entry (matched by .to_s) or clear the
|
|
28
|
-
# array. When forced, the array is completed removed just like a string or number.
|
|
29
|
-
if current_value.is_a?(Array) && !force
|
|
30
|
-
# If the user didn't set a value then set the array as empty, otherwise remove that one item
|
|
31
|
-
new_value = item_value.nil? ? [] : current_value.reject { |item| item.to_s == item_value }
|
|
32
|
-
if current_value.count == new_value.count
|
|
33
|
-
if item_value.nil?
|
|
34
|
-
PDK.logger.info(_("Could not remove '%{name}' as it is already empty") % { name: item_name })
|
|
35
|
-
else
|
|
36
|
-
PDK.logger.info(_("Could not remove '%{value}' from '%{name}' as it has not been set") % { value: item_value, name: item_name })
|
|
37
|
-
end
|
|
38
|
-
return 0
|
|
39
|
-
end
|
|
40
|
-
PDK.config.set(item_name, new_value, force: true)
|
|
41
|
-
else
|
|
42
|
-
# Set the value to nil for deleting.
|
|
43
|
-
PDK.config.set(item_name, nil, force: true)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
# Output the result to the user
|
|
47
|
-
new_value = PDK.config.get(item_name)
|
|
48
|
-
if current_value.is_a?(Array) && !force
|
|
49
|
-
# Arrays have a special output format. If item_value is nil then the user wanted to empty/clear
|
|
50
|
-
# the array otherwise they just wanted to remove a single entry.
|
|
51
|
-
if item_value.nil?
|
|
52
|
-
PDK.logger.info(_("Cleared '%{name}' which had a value of '%{from}'") % { name: item_name, from: current_value })
|
|
53
|
-
else
|
|
54
|
-
PDK.logger.info(_("Removed '%{value}' from '%{name}'") % { value: item_value, name: item_name })
|
|
55
|
-
end
|
|
56
|
-
elsif !new_value.nil?
|
|
57
|
-
PDK.logger.info(_("Could not remove '%{name}' as it using a default value of '%{to}'") % { name: item_name, to: new_value })
|
|
58
|
-
else
|
|
59
|
-
PDK.logger.info(_("Removed '%{name}' which had a value of '%{from}'") % { name: item_name, from: current_value })
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# Same output as `get config`
|
|
63
|
-
$stdout.puts _('%{name}=%{value}') % { name: item_name, value: new_value }
|
|
64
|
-
0
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
@remove_config_cmd = @remove_cmd.define_command do
|
|
70
|
-
name 'config'
|
|
71
|
-
usage _('config [name] [value]')
|
|
72
|
-
summary _('Remove or delete the configuration for <name>')
|
|
73
|
-
|
|
74
|
-
option :f, :force, _('Force multi-value configuration settings to be removed instead of emptied.'), argument: :forbidden
|
|
75
|
-
|
|
76
|
-
run do |opts, args, _cmd|
|
|
77
|
-
exit PDK::CLI::Remove::Config.run(opts, args)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
1
|
+
module PDK::CLI
|
|
2
|
+
module Remove
|
|
3
|
+
module Config
|
|
4
|
+
def self.run(opts, args)
|
|
5
|
+
item_name = (args.count > 0) ? args[0] : nil
|
|
6
|
+
item_value = (args.count > 1) ? args[1].strip : nil
|
|
7
|
+
item_value = nil if !item_value.nil? && item_value.empty?
|
|
8
|
+
|
|
9
|
+
force = opts[:force] || false
|
|
10
|
+
|
|
11
|
+
raise PDK::CLI::ExitWithError, _('Configuration name is required') if item_name.nil?
|
|
12
|
+
|
|
13
|
+
current_value = PDK.config.get(item_name)
|
|
14
|
+
raise PDK::CLI::ExitWithError, _("The configuration item '%{name}' can not be removed.") % { name: item_name } if current_value.is_a?(PDK::Config::Namespace)
|
|
15
|
+
if current_value.nil?
|
|
16
|
+
PDK.logger.info(_("Could not remove '%{name}' as it has not been set") % { name: item_name })
|
|
17
|
+
return 0
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
PDK.logger.info(_("Ignoring the item value '%{value}' as --force has been set") % { value: item_value }) if current_value.is_a?(Array) && !item_value.nil? && force
|
|
21
|
+
PDK.logger.info(_('Ignoring --force as the setting is not multi-valued')) if !current_value.is_a?(Array) && force
|
|
22
|
+
|
|
23
|
+
# FIXME: It'd be nice to shortcircuit deleting default values. This causes the configuration file
|
|
24
|
+
# to be saved, even though nothing actually changes
|
|
25
|
+
|
|
26
|
+
# For most value types, just changing the value to nil is enough, however Arrays are a special case.
|
|
27
|
+
# Unless they're forced, array removal with either remove a single entry (matched by .to_s) or clear the
|
|
28
|
+
# array. When forced, the array is completed removed just like a string or number.
|
|
29
|
+
if current_value.is_a?(Array) && !force
|
|
30
|
+
# If the user didn't set a value then set the array as empty, otherwise remove that one item
|
|
31
|
+
new_value = item_value.nil? ? [] : current_value.reject { |item| item.to_s == item_value }
|
|
32
|
+
if current_value.count == new_value.count
|
|
33
|
+
if item_value.nil?
|
|
34
|
+
PDK.logger.info(_("Could not remove '%{name}' as it is already empty") % { name: item_name })
|
|
35
|
+
else
|
|
36
|
+
PDK.logger.info(_("Could not remove '%{value}' from '%{name}' as it has not been set") % { value: item_value, name: item_name })
|
|
37
|
+
end
|
|
38
|
+
return 0
|
|
39
|
+
end
|
|
40
|
+
PDK.config.set(item_name, new_value, force: true)
|
|
41
|
+
else
|
|
42
|
+
# Set the value to nil for deleting.
|
|
43
|
+
PDK.config.set(item_name, nil, force: true)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Output the result to the user
|
|
47
|
+
new_value = PDK.config.get(item_name)
|
|
48
|
+
if current_value.is_a?(Array) && !force
|
|
49
|
+
# Arrays have a special output format. If item_value is nil then the user wanted to empty/clear
|
|
50
|
+
# the array otherwise they just wanted to remove a single entry.
|
|
51
|
+
if item_value.nil?
|
|
52
|
+
PDK.logger.info(_("Cleared '%{name}' which had a value of '%{from}'") % { name: item_name, from: current_value })
|
|
53
|
+
else
|
|
54
|
+
PDK.logger.info(_("Removed '%{value}' from '%{name}'") % { value: item_value, name: item_name })
|
|
55
|
+
end
|
|
56
|
+
elsif !new_value.nil?
|
|
57
|
+
PDK.logger.info(_("Could not remove '%{name}' as it using a default value of '%{to}'") % { name: item_name, to: new_value })
|
|
58
|
+
else
|
|
59
|
+
PDK.logger.info(_("Removed '%{name}' which had a value of '%{from}'") % { name: item_name, from: current_value })
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Same output as `get config`
|
|
63
|
+
$stdout.puts _('%{name}=%{value}') % { name: item_name, value: new_value }
|
|
64
|
+
0
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
@remove_config_cmd = @remove_cmd.define_command do
|
|
70
|
+
name 'config'
|
|
71
|
+
usage _('config [name] [value]')
|
|
72
|
+
summary _('Remove or delete the configuration for <name>')
|
|
73
|
+
|
|
74
|
+
option :f, :force, _('Force multi-value configuration settings to be removed instead of emptied.'), argument: :forbidden
|
|
75
|
+
|
|
76
|
+
run do |opts, args, _cmd|
|
|
77
|
+
exit PDK::CLI::Remove::Config.run(opts, args)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
data/lib/pdk/cli/remove.rb
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
module PDK::CLI
|
|
2
|
-
@remove_cmd = @base_cmd.define_command do
|
|
3
|
-
name 'remove'
|
|
4
|
-
usage _('remove [subcommand] [options]')
|
|
5
|
-
summary _('Remove or delete information about the PDK or current project.')
|
|
6
|
-
default_subcommand 'help'
|
|
7
|
-
|
|
8
|
-
run do |_opts, args, _cmd|
|
|
9
|
-
if args == ['help']
|
|
10
|
-
PDK::CLI.run(%w[remove --help])
|
|
11
|
-
exit 0
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
PDK::CLI.run(%w[remove help]) if args.empty?
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
@remove_cmd.add_command Cri::Command.new_basic_help
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
require 'pdk/cli/remove/config'
|
|
1
|
+
module PDK::CLI
|
|
2
|
+
@remove_cmd = @base_cmd.define_command do
|
|
3
|
+
name 'remove'
|
|
4
|
+
usage _('remove [subcommand] [options]')
|
|
5
|
+
summary _('Remove or delete information about the PDK or current project.')
|
|
6
|
+
default_subcommand 'help'
|
|
7
|
+
|
|
8
|
+
run do |_opts, args, _cmd|
|
|
9
|
+
if args == ['help']
|
|
10
|
+
PDK::CLI.run(%w[remove --help])
|
|
11
|
+
exit 0
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
PDK::CLI.run(%w[remove help]) if args.empty?
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
@remove_cmd.add_command Cri::Command.new_basic_help
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
require 'pdk/cli/remove/config'
|