pdk 3.0.1 → 3.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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +37 -1
  3. data/lib/pdk/cli/build.rb +6 -5
  4. data/lib/pdk/cli/bundle.rb +0 -2
  5. data/lib/pdk/cli/console.rb +0 -2
  6. data/lib/pdk/cli/convert.rb +3 -3
  7. data/lib/pdk/cli/env.rb +0 -2
  8. data/lib/pdk/cli/exec/command.rb +0 -2
  9. data/lib/pdk/cli/new/class.rb +0 -2
  10. data/lib/pdk/cli/new/defined_type.rb +0 -2
  11. data/lib/pdk/cli/new/fact.rb +0 -2
  12. data/lib/pdk/cli/new/function.rb +0 -2
  13. data/lib/pdk/cli/new/module.rb +0 -2
  14. data/lib/pdk/cli/new/provider.rb +0 -2
  15. data/lib/pdk/cli/new/task.rb +0 -2
  16. data/lib/pdk/cli/new/test.rb +0 -2
  17. data/lib/pdk/cli/release/prep.rb +0 -2
  18. data/lib/pdk/cli/release/publish.rb +0 -2
  19. data/lib/pdk/cli/release.rb +0 -9
  20. data/lib/pdk/cli/test/unit.rb +0 -2
  21. data/lib/pdk/cli/update.rb +3 -3
  22. data/lib/pdk/cli/util.rb +0 -38
  23. data/lib/pdk/cli/validate.rb +0 -7
  24. data/lib/pdk/cli.rb +0 -2
  25. data/lib/pdk/config/namespace.rb +3 -3
  26. data/lib/pdk/config/setting.rb +3 -3
  27. data/lib/pdk/config.rb +0 -80
  28. data/lib/pdk/module/convert.rb +8 -3
  29. data/lib/pdk/module/metadata.rb +18 -10
  30. data/lib/pdk/module/release.rb +9 -6
  31. data/lib/pdk/module/update_manager.rb +29 -3
  32. data/lib/pdk/report/event.rb +1 -1
  33. data/lib/pdk/template/renderer/v1/legacy_template_dir.rb +10 -13
  34. data/lib/pdk/template/renderer/v1/renderer.rb +3 -1
  35. data/lib/pdk/template.rb +0 -3
  36. data/lib/pdk/tests/unit.rb +3 -3
  37. data/lib/pdk/util/filesystem.rb +10 -0
  38. data/lib/pdk/util.rb +1 -0
  39. data/lib/pdk/version.rb +2 -2
  40. data/lib/pdk.rb +0 -14
  41. metadata +63 -98
  42. data/lib/pdk/analytics/client/google_analytics.rb +0 -141
  43. data/lib/pdk/analytics/client/noop.rb +0 -25
  44. data/lib/pdk/analytics/util.rb +0 -18
  45. data/lib/pdk/analytics.rb +0 -30
  46. data/lib/pdk/config/analytics_schema.json +0 -26
  47. data/lib/pdk/module/build.rb +0 -302
  48. data/lib/pdk/monkey_patches.rb +0 -268
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c39902d0ebbac37358fd3fccf5de760b47f77860054b08864ccdae63150b7597
4
- data.tar.gz: 6a4d8beb3013edf1ed946b9cf94cd90b055ad63500102e131734600c81c3a5a5
3
+ metadata.gz: 7ea7fd13c13423022b2ef3e28275d98860b34b9afe9d4b5ccac56c06a0a29346
4
+ data.tar.gz: 5025806f00ad6d9b36bb0957d8da65765cc46cd335c11ef75cf3b82f88a61e79
5
5
  SHA512:
6
- metadata.gz: 7af78ce8b0c4bb9122081a2c6449d862da04c9fec85d428b2e8ace3e88a74930fcf809462062b07994307c54c3ee5a827a83ae26e5c67b95f659c3f5c0cb89b5
7
- data.tar.gz: c5af71c375d94c9e22f4c7ae284213a39aaa87b8bc21980580ce4e79743979d4cbb967f330c775dcd2ebc4d3046c4c9c5080480172e07dec33afd9546b94da7e
6
+ metadata.gz: a3b2866a2a221d87d7c87ecc15231b0a97b00bce150cdd97fd6a6a1ee99f36d9ead2fcee2aef644360aaef84e499f1adff1cdb8de9a10ec084ac302743255a6a
7
+ data.tar.gz: e4fbd9517b238b85d55c59df0a838f831ac1033e84ec2daa96487470f91e1c5954bf96208b223311ab8c8e4c00bc3150570094017576d7e1ffb105c57f2f2eff
data/CHANGELOG.md CHANGED
@@ -5,7 +5,43 @@ All notable changes to this project will be documented in this file.
5
5
 
6
6
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
7
7
 
8
- ## [v3.0.1](https://github.com/puppetlabs/pdk/tree/v3.0.1) - 2023-12-07
8
+ ## [v3.3.0](https://github.com/puppetlabs/pdk/tree/v3.3.0) - 2024-09-10
9
+
10
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.2.0...v3.3.0)
11
+
12
+ ## Added
13
+
14
+ - Skip 'name' validation when in a controlrepo context [#1352](https://github.com/puppetlabs/pdk/pull/1352) ([garrettrowell](https://github.com/garrettrowell))
15
+ - (CAT-1896) - Use puppet-modulebuilder for PDK build [#1374](https://github.com/puppetlabs/pdk/pull/1374) ([jordanbreen28](https://github.com/jordanbreen28))
16
+
17
+ ### Fixed
18
+
19
+ - (CAT-1643) Update childprocess and remove patch [#1356](https://github.com/puppetlabs/pdk/pull/1356) ([david22swan](https://github.com/david22swan))
20
+ - (CAT-2026) Update how pdk test unit --list detects an error [#1388](https://github.com/puppetlabs/pdk/pull/1388) ([david22swan](https://github.com/david22swan))
21
+
22
+ ## [v3.2.0](https://github.com/puppetlabs/pdk/tree/v3.2.0) - 2024-05-02
23
+
24
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.1.0...v3.2.0)
25
+
26
+ ### Fixed
27
+
28
+ - (CAT-1807) Remove analytics from the PDK [#1339](https://github.com/puppetlabs/pdk/pull/1339) ([david22swan](https://github.com/david22swan))
29
+
30
+ ## [v3.1.0](https://github.com/puppetlabs/pdk/tree/v3.1.0) - 2024-04-11
31
+
32
+ [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.0.1...v3.1.0)
33
+
34
+ ### Added
35
+
36
+ - Allow `pdk convert` and `pdk update` to work in a ControlRepo context [#1310](https://github.com/puppetlabs/pdk/pull/1310) ([garrettrowell](https://github.com/garrettrowell))
37
+ - Support executable templates [#1289](https://github.com/puppetlabs/pdk/pull/1289) ([nabertrand](https://github.com/nabertrand))
38
+
39
+ ### Fixed
40
+
41
+ - (CAT-1796) Fix missing locale gem [#1337](https://github.com/puppetlabs/pdk/pull/1337) ([LukasAud](https://github.com/LukasAud))
42
+ - (CAT-1703) Convert concurrent-ruby from a pin to a pessimistic constraint [#1312](https://github.com/puppetlabs/pdk/pull/1312) ([david22swan](https://github.com/david22swan))
43
+
44
+ ## [v3.0.1](https://github.com/puppetlabs/pdk/tree/v3.0.1) - 2023-12-13
9
45
 
10
46
  [Full Changelog](https://github.com/puppetlabs/pdk/compare/v3.0.0...v3.0.1)
11
47
 
data/lib/pdk/cli/build.rb CHANGED
@@ -12,7 +12,6 @@ module PDK
12
12
  option nil, 'force', 'Skips the prompts and builds the module package.'
13
13
 
14
14
  run do |opts, _args, _cmd|
15
- require 'pdk/module/build'
16
15
  require 'pdk/module/metadata'
17
16
  require 'pdk/cli/util'
18
17
 
@@ -22,8 +21,6 @@ module PDK
22
21
  log_level: :info
23
22
  )
24
23
 
25
- PDK::CLI::Util.analytics_screen_view('build', opts)
26
-
27
24
  module_metadata = PDK::Module::Metadata.from_file('metadata.json')
28
25
 
29
26
  # TODO: Ensure forge metadata has been set, or call out to interview
@@ -39,7 +36,11 @@ module PDK
39
36
  end
40
37
  end
41
38
 
42
- builder = PDK::Module::Build.new(opts)
39
+ # build module
40
+ require 'puppet/modulebuilder'
41
+ module_dir = PDK::Util::Filesystem.expand_path(Dir.pwd)
42
+ target_dir = PDK::Util::Filesystem.expand_path(opts[:'target-dir'])
43
+ builder = Puppet::Modulebuilder::Builder.new(module_dir, target_dir, PDK.logger)
43
44
 
44
45
  unless opts[:force]
45
46
  if builder.package_already_exists?
@@ -51,7 +52,7 @@ module PDK
51
52
  end
52
53
  end
53
54
 
54
- unless builder.module_pdk_compatible?
55
+ unless PDK::Util.module_pdk_compatible?(module_dir)
55
56
  PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \
56
57
  'Unvalidated modules may have errors when uploading to the Forge. ' \
57
58
  'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.'
@@ -23,8 +23,6 @@ module PDK
23
23
  screen_view_name << args[0] if args.size >= 1
24
24
  screen_view_name << args[1] if args.size >= 2 && args[0] == 'exec'
25
25
 
26
- PDK::CLI::Util.analytics_screen_view(screen_view_name.join('_'))
27
-
28
26
  # Ensure that the correct Ruby is activated before running command.
29
27
  puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
30
28
  PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
@@ -34,8 +34,6 @@ module PDK
34
34
 
35
35
  PDK::CLI::Util.validate_puppet_version_opts(processed_options)
36
36
 
37
- PDK::CLI::Util.analytics_screen_view('console', args)
38
-
39
37
  # TODO: figure out if we need to remove default configs set by puppet
40
38
  # so it is scoped for the module only
41
39
  # "--environmentpath"...
@@ -18,7 +18,9 @@ module PDK
18
18
  # Write the context information to the debug log
19
19
  PDK.context.to_debug_log
20
20
 
21
- raise PDK::CLI::ExitWithError, '`pdk convert` can only be run from inside a valid module directory.' unless PDK.context.is_a?(PDK::Context::Module)
21
+ unless PDK.context.is_a?(PDK::Context::Module) || PDK.context.is_a?(PDK::Context::ControlRepo)
22
+ raise PDK::CLI::ExitWithError, '`pdk convert` can only be run from inside a valid module directory.'
23
+ end
22
24
 
23
25
  raise PDK::CLI::ExitWithError, 'You can not specify --noop and --force when converting a module' if opts[:noop] && opts[:force]
24
26
 
@@ -31,8 +33,6 @@ module PDK
31
33
 
32
34
  PDK::CLI::Util.validate_template_opts(opts)
33
35
 
34
- PDK::CLI::Util.analytics_screen_view('convert', opts)
35
-
36
36
  if opts[:'skip-interview'] && opts[:'full-interview']
37
37
  PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
38
38
  opts[:'full-interview'] = false
data/lib/pdk/cli/env.rb CHANGED
@@ -17,8 +17,6 @@ module PDK
17
17
 
18
18
  PDK::CLI::Util.validate_puppet_version_opts(opts)
19
19
 
20
- PDK::CLI::Util.analytics_screen_view('env')
21
-
22
20
  # Ensure that the correct Ruby is activated before running command.
23
21
  puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
24
22
  PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
@@ -20,8 +20,6 @@ module PDK
20
20
 
21
21
  def initialize(*argv)
22
22
  require 'childprocess'
23
-
24
- require 'pdk/monkey_patches'
25
23
  require 'tempfile'
26
24
 
27
25
  @argv = argv
@@ -22,8 +22,6 @@ module PDK
22
22
 
23
23
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid class name", name: class_name) unless Util::OptionValidator.valid_class_name?(class_name)
24
24
 
25
- PDK::CLI::Util.analytics_screen_view('new_class', opts)
26
-
27
25
  updates = PDK::Generate::PuppetClass.new(PDK.context, class_name, opts).run
28
26
  PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
29
27
  end
@@ -20,8 +20,6 @@ module PDK
20
20
 
21
21
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid defined type name", name: defined_type_name) unless Util::OptionValidator.valid_defined_type_name?(defined_type_name)
22
22
 
23
- PDK::CLI::Util.analytics_screen_view('new_defined_type', opts)
24
-
25
23
  require 'pdk/generate/defined_type'
26
24
 
27
25
  updates = PDK::Generate::DefinedType.new(PDK.context, defined_type_name, opts).run
@@ -17,8 +17,6 @@ module PDK
17
17
 
18
18
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid fact name", name: fact_name) unless Util::OptionValidator.valid_fact_name?(fact_name)
19
19
 
20
- PDK::CLI::Util.analytics_screen_view('new_fact', opts)
21
-
22
20
  require 'pdk/generate/fact'
23
21
 
24
22
  updates = PDK::Generate::Fact.new(PDK.context, fact_name, opts).run
@@ -18,8 +18,6 @@ module PDK
18
18
 
19
19
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid function name", name: function_name) unless Util::OptionValidator.valid_function_name?(function_name)
20
20
 
21
- PDK::CLI::Util.analytics_screen_view('new_function', opts)
22
-
23
21
  require 'pdk/generate/function'
24
22
  updates = PDK::Generate::Function.new(PDK.context, function_name, opts).run
25
23
  PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
@@ -22,8 +22,6 @@ module PDK
22
22
 
23
23
  PDK::CLI::Util.validate_template_opts(opts)
24
24
 
25
- PDK::CLI::Util.analytics_screen_view('new_module', opts)
26
-
27
25
  if opts[:'skip-interview'] && opts[:'full-interview']
28
26
  PDK.logger.info 'Ignoring --full-interview and continuing with --skip-interview.'
29
27
  opts[:'full-interview'] = false
@@ -17,8 +17,6 @@ module PDK
17
17
 
18
18
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid provider name", name: provider_name) unless Util::OptionValidator.valid_provider_name?(provider_name)
19
19
 
20
- PDK::CLI::Util.analytics_screen_view('new_provider', opts)
21
-
22
20
  require 'pdk/generate/provider'
23
21
 
24
22
  updates = PDK::Generate::Provider.new(PDK.context, provider_name, opts).run
@@ -24,8 +24,6 @@ module PDK
24
24
 
25
25
  raise PDK::CLI::ExitWithError, format("'%{name}' is not a valid task name", name: task_name) unless Util::OptionValidator.valid_task_name?(task_name)
26
26
 
27
- PDK::CLI::Util.analytics_screen_view('new_task', opts)
28
-
29
27
  updates = PDK::Generate::Task.new(PDK.context, task_name, opts).run
30
28
  PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
31
29
  end
@@ -39,8 +39,6 @@ module PDK
39
39
  begin
40
40
  generator, obj = PDK::Util::PuppetStrings.find_object(object_name)
41
41
 
42
- PDK::CLI::Util.analytics_screen_view('new_test', opts)
43
-
44
42
  updates = generator.new(PDK.context, obj['name'], opts.merge(spec_only: true)).run
45
43
  PDK::CLI::Util::UpdateManagerPrinter.print_summary(updates, tense: :past)
46
44
  rescue PDK::Util::PuppetStrings::NoObjectError
@@ -28,8 +28,6 @@ module PDK
28
28
 
29
29
  Release.prepare_interview(opts) unless opts[:force]
30
30
 
31
- Release.send_analytics("release #{cmd.name}", opts)
32
-
33
31
  release = PDK::Module::Release.new(nil, opts)
34
32
 
35
33
  Release.module_compatibility_checks!(release, opts)
@@ -37,8 +37,6 @@ module PDK
37
37
 
38
38
  Release.prepare_publish_interview(TTY::Prompt.new(help_color: :cyan), opts) unless opts[:force]
39
39
 
40
- Release.send_analytics("release #{cmd.name}", opts)
41
-
42
40
  release = PDK::Module::Release.new(nil, opts)
43
41
 
44
42
  release.run
@@ -3,7 +3,6 @@ require 'pdk/validate'
3
3
  require 'pdk/util/bundler'
4
4
  require 'pdk/cli/util/interview'
5
5
  require 'pdk/util/changelog_generator'
6
- require 'pdk/module/build'
7
6
 
8
7
  module PDK
9
8
  module CLI
@@ -41,8 +40,6 @@ module PDK
41
40
 
42
41
  Release.prepare_interview(opts) unless opts[:force]
43
42
 
44
- Release.send_analytics('release', opts)
45
-
46
43
  release = PDK::Module::Release.new(nil, opts)
47
44
 
48
45
  Release.module_compatibility_checks!(release, opts)
@@ -81,12 +78,6 @@ module PDK
81
78
  end
82
79
  end
83
80
 
84
- # Send_analytics for the given command and Cri options
85
- def self.send_analytics(command, opts)
86
- # Don't pass tokens to analytics
87
- PDK::CLI::Util.analytics_screen_view(command, opts.reject { |k, _| k == :'forge-token' })
88
- end
89
-
90
81
  def self.prepare_interview(opts)
91
82
  questions = []
92
83
 
@@ -34,8 +34,6 @@ module PDK
34
34
 
35
35
  PDK::CLI::Util.module_version_check
36
36
 
37
- PDK::CLI::Util.analytics_screen_view('test_unit', opts)
38
-
39
37
  # Ensure that the bundled gems are up to date and correct Ruby is activated before running or listing tests.
40
38
  puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
41
39
  PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
@@ -14,7 +14,9 @@ module PDK
14
14
  # Write the context information to the debug log
15
15
  PDK.context.to_debug_log
16
16
 
17
- raise PDK::CLI::ExitWithError, '`pdk update` can only be run from inside a valid module directory.' unless PDK.context.is_a?(PDK::Context::Module)
17
+ unless PDK.context.is_a?(PDK::Context::Module) || PDK.context.is_a?(PDK::Context::ControlRepo)
18
+ raise PDK::CLI::ExitWithError, '`pdk update` can only be run from inside a valid module directory.'
19
+ end
18
20
 
19
21
  raise PDK::CLI::ExitWithError, 'This module does not appear to be PDK compatible. To make the module compatible with PDK, run `pdk convert`.' unless PDK::Util.module_pdk_compatible?
20
22
 
@@ -31,8 +33,6 @@ module PDK
31
33
  end
32
34
  end
33
35
 
34
- PDK::CLI::Util.analytics_screen_view('update', opts)
35
-
36
36
  updater = PDK::Module::Update.new(PDK.context.root_path, opts)
37
37
 
38
38
  if updater.pinned_to_puppetlabs_template_tag?
data/lib/pdk/cli/util.rb CHANGED
@@ -245,44 +245,6 @@ module PDK
245
245
  raise PDK::CLI::ExitWithError, '--template-url may not be used to specify paths containing #\'s.'
246
246
  end
247
247
  module_function :validate_template_opts
248
-
249
- def analytics_screen_view(screen_name, opts = {})
250
- require 'pdk/analytics'
251
-
252
- dimensions = {
253
- ruby_version: RUBY_VERSION
254
- }
255
-
256
- cmd_opts = opts.dup.reject do |_, v|
257
- v.nil? || (v.respond_to?(:empty?) && v.empty?)
258
- end
259
-
260
- if (format_args = cmd_opts.delete(:format))
261
- formats = PDK::CLI::Util::OptionNormalizer.report_formats(format_args)
262
- dimensions[:output_format] = formats.map { |r| r[:method].to_s.delete_prefix('write_') }.sort.uniq.join(',')
263
- else
264
- dimensions[:output_format] = 'default'
265
- end
266
-
267
- safe_opts = [:'puppet-version', :'pe-version']
268
- safe_bools = [true, false]
269
- redacted_opts = cmd_opts.map do |k, v|
270
- value = if safe_bools.include?(v) || safe_opts.include?(k)
271
- v
272
- else
273
- 'redacted'
274
- end
275
- "#{k}=#{value}"
276
- end
277
- dimensions[:cli_options] = redacted_opts.join(',') unless redacted_opts.empty?
278
-
279
- ignored_env_vars = ['PDK_ANALYTICS_CONFIG', 'PDK_DISABLE_ANALYTICS']
280
- env_vars = PDK::Util::Env.select { |k, _| k.start_with?('PDK_') && !ignored_env_vars.include?(k) }.map { |k, v| "#{k}=#{v}" }
281
- dimensions[:env_vars] = env_vars.join(',') unless env_vars.empty?
282
-
283
- PDK.analytics.screen_view(screen_name, **dimensions)
284
- end
285
- module_function :analytics_screen_view
286
248
  end
287
249
  end
288
250
  end
@@ -29,7 +29,6 @@ module PDK
29
29
  require 'pdk/validate'
30
30
 
31
31
  if opts[:list]
32
- PDK::CLI::Util.analytics_screen_view('validate', opts)
33
32
  PDK.logger.info(format('Available validators: %{validator_names}', validator_names: PDK::Validate.validator_names.join(', ')))
34
33
  exit 0
35
34
  end
@@ -75,12 +74,6 @@ module PDK
75
74
  end
76
75
  validators_to_run = PDK::Validate.validator_names if validators_to_run.nil?
77
76
 
78
- if validators_to_run.sort == PDK::Validate.validator_names.sort
79
- PDK::CLI::Util.analytics_screen_view('validate', opts)
80
- else
81
- PDK::CLI::Util.analytics_screen_view(['validate', validators_to_run.sort].flatten.join('_'), opts)
82
- end
83
-
84
77
  # Subsequent arguments are targets.
85
78
  targets.concat(args.to_a[1..]) if args.length > 1
86
79
 
data/lib/pdk/cli.rb CHANGED
@@ -16,7 +16,6 @@ module Cri
16
16
  class CriExitException
17
17
  def initialize(is_error:)
18
18
  @is_error = is_error
19
- PDK.analytics.event('CLI', 'invalid command', label: PDK::CLI.anonymised_args.join(' ')) if error?
20
19
  end
21
20
  end
22
21
  end
@@ -56,7 +55,6 @@ module PDK
56
55
 
57
56
  def self.run(args)
58
57
  @args = args
59
- PDK::Config.analytics_config_interview! unless PDK::Util::Env['PDK_DISABLE_ANALYTICS'] || PDK::Config.analytics_config_exist?
60
58
  @base_cmd.run(args)
61
59
  rescue PDK::CLI::ExitWithError => e
62
60
  PDK.logger.send(e.log_level, e.message)
@@ -24,7 +24,7 @@ module PDK
24
24
  # a child of (defaults to nil).
25
25
  # @option params [self] :persistent_defaults whether default values should be persisted
26
26
  # to disk when evaluated. By default they are not persisted to disk. This is typically
27
- # used for settings which a randomly generated, instead of being deterministic, e.g. analytics user-id
27
+ # used for settings which a randomly generated, instead of being deterministic, e.g. module_defaults author
28
28
  # @param block [Proc] a block that is evaluated within the new instance.
29
29
  def initialize(name = nil, file: nil, parent: nil, persistent_defaults: false, &block)
30
30
  @file = PDK::Util::Filesystem.expand_path(file) unless file.nil?
@@ -162,7 +162,7 @@ module PDK
162
162
  new_hash = {}
163
163
  settings.each_pair { |k, v| new_hash[k] = v.value }
164
164
  @mounts.each_pair { |k, mount_point| new_hash[k] = mount_point.to_h if mount_point.include_in_parent? }
165
- new_hash.delete_if { |_k, v| v.nil? } # rubocop :disable Style/CollectionCompact
165
+ new_hash.delete_if { |_k, v| v.nil? }
166
166
  new_hash
167
167
  end
168
168
 
@@ -238,7 +238,7 @@ module PDK
238
238
  # Returns true when filter is nil.
239
239
  # Returns true if the filter is exactly the same name as the setting.
240
240
  # Returns true if the name is a sub-key of the filter e.g.
241
- # Given a filter of user.module_defaults, `user.module_defaults.author` will return true, but `user.analytics.disabled` will return false.
241
+ # Given a filter of user.module_defaults, `user.module_defaults.author` will return true, but `user.pdk_feature_flags.requested` will return false.
242
242
  #
243
243
  # @param name [String] The setting name to test.
244
244
  # @param filter [String] The filter used to test on the name.
@@ -9,9 +9,9 @@ module PDK
9
9
  #
10
10
  # @example
11
11
  #
12
- # PDK::Config::Namespace.new('analytics') do
13
- # setting :disabled do
14
- # validate PDK::Config::Validator.boolean
12
+ # PDK::Config::Namespace.new('module_defaults') do
13
+ # setting :author do
14
+ # validate PDK::Config::Validator.string
15
15
  # default_to { false }
16
16
  # end
17
17
  # end
data/lib/pdk/config.rb CHANGED
@@ -19,7 +19,6 @@ module PDK
19
19
  # @option options [String] 'system.module_defaults.path' Path to the system module answers PDK configuration file
20
20
  # @option options [String] 'user.path' Path to the user PDK configuration file
21
21
  # @option options [String] 'user.module_defaults.path' Path to the user module answers PDK configuration file
22
- # @option options [String] 'user.analytics.path' Path to the user analytics PDK configuration file
23
22
  # @option options [PDK::Context::AbstractContext] 'context' The context that the configuration should be created in
24
23
  def initialize(options = nil)
25
24
  options = {} if options.nil?
@@ -28,7 +27,6 @@ module PDK
28
27
  'system.module_defaults.path' => PDK::Config.system_answers_path,
29
28
  'user.path' => PDK::Config.user_config_path,
30
29
  'user.module_defaults.path' => PDK::AnswerFile.default_answer_file_path,
31
- 'user.analytics.path' => PDK::Config.analytics_config_path,
32
30
  'context' => PDK.context
33
31
  }.merge(options)
34
32
  end
@@ -51,27 +49,6 @@ module PDK
51
49
  @user_config ||= PDK::Config::JSON.new('user', file: local_options['user.path']) do
52
50
  mount :module_defaults, PDK::Config::JSON.new(file: local_options['user.module_defaults.path'])
53
51
 
54
- # Due to the json-schema gem having issues with Windows based paths, and only supporting Draft 05 (or less) do
55
- # not use JSON validation yet. Once PDK drops support for EOL rubies, we will be able to use the json_schemer gem
56
- # Which has much more modern support
57
- # Reference - https://github.com/puppetlabs/pdk/pull/777
58
- # Reference - https://tickets.puppetlabs.com/browse/PDK-1526
59
- mount :analytics, PDK::Config::YAML.new(file: local_options['user.analytics.path'], persistent_defaults: true) do
60
- setting :disabled do
61
- validate PDK::Config::Validator.boolean
62
- default_to { PDK::Config.bolt_analytics_config.fetch('disabled', true) }
63
- end
64
-
65
- setting 'user-id' do
66
- validate PDK::Config::Validator.uuid
67
- default_to do
68
- require 'securerandom'
69
-
70
- PDK::Config.bolt_analytics_config.fetch('user-id', SecureRandom.uuid)
71
- end
72
- end
73
- end
74
-
75
52
  # Display the feature flags
76
53
  mount :pdk_feature_flags, PDK::Config::Namespace.new('pdk_feature_flags') do
77
54
  setting 'available' do
@@ -191,18 +168,6 @@ module PDK
191
168
  deep_set_object(value, options[:force], send(all_scopes[scope_name]), *names[1..])
192
169
  end
193
170
 
194
- def self.bolt_analytics_config
195
- file = PDK::Util::Filesystem.expand_path('~/.puppetlabs/bolt/analytics.yaml')
196
- PDK::Config::YAML.new(file: file)
197
- rescue PDK::Config::LoadError => e
198
- PDK.logger.debug format('Unable to load %{file}: %{message}', file: file, message: e.message)
199
- PDK::Config::YAML.new
200
- end
201
-
202
- def self.analytics_config_path
203
- PDK::Util::Env['PDK_ANALYTICS_CONFIG'] || File.join(File.dirname(PDK::Util.configdir), 'puppet', 'analytics.yml')
204
- end
205
-
206
171
  def self.user_config_path
207
172
  File.join(PDK::Util.configdir, 'user_config.json')
208
173
  end
@@ -224,51 +189,6 @@ module PDK
224
189
  File.join(json_schemas_path, "#{name}_schema.json")
225
190
  end
226
191
 
227
- def self.analytics_config_exist?
228
- PDK::Util::Filesystem.file?(analytics_config_path)
229
- end
230
-
231
- def self.analytics_config_interview!
232
- require 'pdk/cli/util'
233
-
234
- return unless PDK::CLI::Util.interactive?
235
-
236
- pre_message =
237
- format('PDK collects anonymous usage information to help us understand how ' \
238
- 'it is being used and make decisions on how to improve it. You can ' \
239
- 'find out more about what data we collect and how it is used in the ' \
240
- "PDK documentation at %{url}.\n", url: 'https://puppet.com/docs/pdk/latest/pdk_install.html')
241
- post_message =
242
- format('You can opt in or out of the usage data collection at any time by ' \
243
- 'editing the analytics configuration file at %{path} and changing ' \
244
- "the '%{key}' value.", path: PDK::Config.analytics_config_path, key: 'disabled')
245
-
246
- questions = [
247
- {
248
- name: 'enabled',
249
- question: 'Do you consent to the collection of anonymous PDK usage information?',
250
- type: :yes
251
- }
252
- ]
253
-
254
- require 'pdk/cli/util/interview'
255
-
256
- PDK.logger.info(text: pre_message, wrap: true)
257
- prompt = TTY::Prompt.new(help_color: :cyan)
258
- interview = PDK::CLI::Util::Interview.new(prompt)
259
- interview.add_questions(questions)
260
- answers = interview.run
261
-
262
- if answers.nil?
263
- PDK.logger.info 'No answer given, opting out of analytics collection.'
264
- PDK.config.set(['user', 'analytics', 'disabled'], true)
265
- else
266
- PDK.config.set(['user', 'analytics', 'disabled'], !answers['enabled'])
267
- end
268
-
269
- PDK.logger.info(text: post_message, wrap: true)
270
- end
271
-
272
192
  private
273
193
 
274
194
  # :nocov: This is a private method and is tested elsewhere
@@ -148,7 +148,7 @@ module PDK
148
148
  module_name = new_metadata.nil? ? 'new-module' : new_metadata.data['name']
149
149
  metadata_for_render = new_metadata.nil? ? {} : new_metadata.data
150
150
 
151
- template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status|
151
+ template_dir.render_new_module(module_name, metadata_for_render) do |relative_file_path, file_content, file_status, file_executable|
152
152
  absolute_file_path = File.join(module_dir, relative_file_path)
153
153
  case file_status
154
154
  when :unmanage
@@ -156,12 +156,17 @@ module PDK
156
156
  when :delete
157
157
  update_manager.remove_file(absolute_file_path)
158
158
  when :init
159
- update_manager.add_file(absolute_file_path, file_content) if convert? && !PDK::Util::Filesystem.exist?(absolute_file_path)
159
+ if convert? && !PDK::Util::Filesystem.exist?(absolute_file_path)
160
+ update_manager.add_file(absolute_file_path, file_content)
161
+ update_manager.make_file_executable(absolute_file_path) if file_executable
162
+ end
160
163
  when :manage
161
164
  if PDK::Util::Filesystem.exist?(absolute_file_path)
162
165
  update_manager.modify_file(absolute_file_path, file_content)
166
+ update_manager.make_file_executable(absolute_file_path) if file_executable && !PDK::Util::Filesystem.stat(absolute_file_path).executable?
163
167
  else
164
168
  update_manager.add_file(absolute_file_path, file_content)
169
+ update_manager.make_file_executable(absolute_file_path) if file_executable
165
170
  end
166
171
  end
167
172
  end
@@ -206,7 +211,7 @@ module PDK
206
211
  return if options[:noop]
207
212
 
208
213
  project_dir = File.basename(Dir.pwd)
209
- options[:module_name] = project_dir.split('-', 2).compact[-1]
214
+ options[:module_name] = PDK.context.is_a?(PDK::Context::ControlRepo) ? project_dir : project_dir.split('-', 2).compact[-1]
210
215
  options[:prompt] = false
211
216
  options[:'skip-interview'] = true if options[:force]
212
217