pdk 1.10.0 → 1.11.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 +50 -1
- data/lib/pdk.rb +16 -1
- data/lib/pdk/analytics.rb +28 -0
- data/lib/pdk/analytics/client/google_analytics.rb +138 -0
- data/lib/pdk/analytics/client/noop.rb +23 -0
- data/lib/pdk/analytics/util.rb +17 -0
- data/lib/pdk/cli.rb +37 -0
- data/lib/pdk/cli/build.rb +2 -0
- data/lib/pdk/cli/bundle.rb +2 -1
- data/lib/pdk/cli/convert.rb +2 -0
- data/lib/pdk/cli/exec.rb +28 -1
- data/lib/pdk/cli/new/class.rb +2 -0
- data/lib/pdk/cli/new/defined_type.rb +2 -0
- data/lib/pdk/cli/new/module.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/test.rb +0 -1
- data/lib/pdk/cli/test/unit.rb +13 -10
- data/lib/pdk/cli/update.rb +21 -0
- data/lib/pdk/cli/util.rb +35 -0
- data/lib/pdk/cli/util/interview.rb +7 -1
- data/lib/pdk/cli/validate.rb +9 -2
- data/lib/pdk/config.rb +94 -0
- data/lib/pdk/config/errors.rb +5 -0
- data/lib/pdk/config/json.rb +23 -0
- data/lib/pdk/config/namespace.rb +273 -0
- data/lib/pdk/config/validator.rb +31 -0
- data/lib/pdk/config/value.rb +94 -0
- data/lib/pdk/config/yaml.rb +31 -0
- data/lib/pdk/generate/module.rb +3 -2
- data/lib/pdk/logger.rb +21 -1
- data/lib/pdk/module/build.rb +58 -0
- data/lib/pdk/module/convert.rb +1 -1
- data/lib/pdk/module/metadata.rb +1 -0
- data/lib/pdk/module/templatedir.rb +24 -5
- data/lib/pdk/module/update_manager.rb +2 -2
- data/lib/pdk/report/event.rb +3 -3
- data/lib/pdk/template_file.rb +1 -1
- data/lib/pdk/tests/unit.rb +10 -12
- data/lib/pdk/util.rb +9 -0
- data/lib/pdk/util/bundler.rb +5 -9
- data/lib/pdk/util/filesystem.rb +37 -0
- data/lib/pdk/util/puppet_version.rb +1 -1
- data/lib/pdk/util/ruby_version.rb +16 -6
- data/lib/pdk/util/template_uri.rb +72 -43
- data/lib/pdk/util/version.rb +1 -1
- data/lib/pdk/util/windows.rb +1 -0
- data/lib/pdk/util/windows/api_types.rb +0 -7
- data/lib/pdk/util/windows/file.rb +1 -1
- data/lib/pdk/util/windows/string.rb +1 -1
- data/lib/pdk/validate/base_validator.rb +8 -6
- data/lib/pdk/validate/puppet/puppet_syntax.rb +1 -1
- data/lib/pdk/validate/ruby/rubocop.rb +1 -1
- data/lib/pdk/version.rb +1 -1
- data/locales/pdk.pot +223 -114
- metadata +103 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5ec16ddd2727410b30d9b0d41457e4c4973f14607af8fffd10cf3ce5f7a5027b
|
4
|
+
data.tar.gz: 5288a7bfae1df2106fc9bd012ae71fd7e61473482404b0ccac0de6375399175e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b08bd2bf5c1e54de90c6b1b8f3b91a3569827ddc06a5277b0b2bc5387f9fd21526c23f7a63cc97e7c87eb3c64b859214a94a9c86c79ba9509b3349cd1da39545
|
7
|
+
data.tar.gz: 7d101cca2234748f4edd69e7f5aafab5e99c9161efc08c36af3c8cd2aa4d613bdfbc0b7210ef6c47eee15bfab4332eebb1d2efba9cbe5bb9397454d4f4517057
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,54 @@ All changes to this repo will be documented in this file.
|
|
4
4
|
See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) for a high-level summary.
|
5
5
|
|
6
6
|
|
7
|
+
## [v1.11.0](https://github.com/puppetlabs/pdk/tree/v1.11.0) (2019-06-27)
|
8
|
+
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.10.0...v1.11.0)
|
9
|
+
|
10
|
+
**Fixed bugs:**
|
11
|
+
|
12
|
+
- \(PDK-1348\) remove unused constants throwing warns [\#656](https://github.com/puppetlabs/pdk/pull/656) ([tphoney](https://github.com/tphoney))
|
13
|
+
|
14
|
+
**Closed issues:**
|
15
|
+
|
16
|
+
- template-ref behaviour in PDK 1.10.0 breaks backwards compatibility [\#661](https://github.com/puppetlabs/pdk/issues/661)
|
17
|
+
- pdk validate reports error on is\_to\_s [\#642](https://github.com/puppetlabs/pdk/issues/642)
|
18
|
+
- pdk 1.9.1.0 on windows does not set path env variable [\#641](https://github.com/puppetlabs/pdk/issues/641)
|
19
|
+
- default\_facts.yml does not override values from facterdb [\#628](https://github.com/puppetlabs/pdk/issues/628)
|
20
|
+
- PDK and beaker [\#622](https://github.com/puppetlabs/pdk/issues/622)
|
21
|
+
- Configure 'ordering' for rspec-puppet in PDK [\#511](https://github.com/puppetlabs/pdk/issues/511)
|
22
|
+
- Cannot override module Hiera 5 config for unit tests [\#487](https://github.com/puppetlabs/pdk/issues/487)
|
23
|
+
|
24
|
+
**Merged pull requests:**
|
25
|
+
|
26
|
+
- \(FIXUP\) Avoid attempting to append nokogiri pin to nil in package tests [\#686](https://github.com/puppetlabs/pdk/pull/686) ([scotje](https://github.com/scotje))
|
27
|
+
- Revert "\(PDK-1366\) Update default operatingsystem versions" [\#685](https://github.com/puppetlabs/pdk/pull/685) ([rodjek](https://github.com/rodjek))
|
28
|
+
- \(maint\) Clear Gemfile overrides before pdk update test [\#684](https://github.com/puppetlabs/pdk/pull/684) ([rodjek](https://github.com/rodjek))
|
29
|
+
- \(PDK-1366\) Update default operatingsystem versions [\#682](https://github.com/puppetlabs/pdk/pull/682) ([rodjek](https://github.com/rodjek))
|
30
|
+
- \(PDK-1362\) Warn user if updating module with older PDK version [\#681](https://github.com/puppetlabs/pdk/pull/681) ([rodjek](https://github.com/rodjek))
|
31
|
+
- \(PDK-1365\) Use dynamic ruby detection for default ruby instance [\#678](https://github.com/puppetlabs/pdk/pull/678) ([glennsarti](https://github.com/glennsarti))
|
32
|
+
- \(PDK-1354\) Default template ref for custom templates should always be master [\#677](https://github.com/puppetlabs/pdk/pull/677) ([rodjek](https://github.com/rodjek))
|
33
|
+
- \(maint\) Pin cri to \<= 2.15.6 [\#675](https://github.com/puppetlabs/pdk/pull/675) ([rodjek](https://github.com/rodjek))
|
34
|
+
- \(MAINT\) Fix issues related to Cri behavior change with options hash [\#672](https://github.com/puppetlabs/pdk/pull/672) ([scotje](https://github.com/scotje))
|
35
|
+
- \(PDK-1337\) Warn and unset any of the legacy \*\_GEM\_VERSION env vars [\#671](https://github.com/puppetlabs/pdk/pull/671) ([rodjek](https://github.com/rodjek))
|
36
|
+
- \(PDK-1345\) Disable analytics during package tests [\#670](https://github.com/puppetlabs/pdk/pull/670) ([rodjek](https://github.com/rodjek))
|
37
|
+
- \(MAINT\) Fix MSYS2 update on Appveyor [\#669](https://github.com/puppetlabs/pdk/pull/669) ([rodjek](https://github.com/rodjek))
|
38
|
+
- \(PDK-1342\) Submit PDK analytics events [\#668](https://github.com/puppetlabs/pdk/pull/668) ([rodjek](https://github.com/rodjek))
|
39
|
+
- \(PDK-1336\) Update rubocop to 0.57.2 [\#667](https://github.com/puppetlabs/pdk/pull/667) ([scotje](https://github.com/scotje))
|
40
|
+
- \(PDK-1341\) Hook up PDK analytics to Google Analytics [\#665](https://github.com/puppetlabs/pdk/pull/665) ([rodjek](https://github.com/rodjek))
|
41
|
+
- \(MAINT\) Add "needs-triage" default labels to issue templates [\#664](https://github.com/puppetlabs/pdk/pull/664) ([scotje](https://github.com/scotje))
|
42
|
+
- \(PDK-1264\) Display a nicer error when tarring long paths [\#663](https://github.com/puppetlabs/pdk/pull/663) ([rodjek](https://github.com/rodjek))
|
43
|
+
- \(maint\) Add spawned process stdout & stderr to debug log [\#662](https://github.com/puppetlabs/pdk/pull/662) ([rodjek](https://github.com/rodjek))
|
44
|
+
- \(PDK-1300\) Ensure `test unit --list` uses correct Puppet/Ruby env [\#660](https://github.com/puppetlabs/pdk/pull/660) ([scotje](https://github.com/scotje))
|
45
|
+
- \(MAINT\) Fixup package acceptance tests for 'pdk-default' template URL [\#658](https://github.com/puppetlabs/pdk/pull/658) ([scotje](https://github.com/scotje))
|
46
|
+
- \(PDK-1339\) Read or interview for analytics config [\#657](https://github.com/puppetlabs/pdk/pull/657) ([rodjek](https://github.com/rodjek))
|
47
|
+
- \(PDK-1350\) Handle SCP style URLs in metadata.json [\#655](https://github.com/puppetlabs/pdk/pull/655) ([rodjek](https://github.com/rodjek))
|
48
|
+
- \(PDK-1338\) Initial import of analytics code from Bolt [\#652](https://github.com/puppetlabs/pdk/pull/652) ([rodjek](https://github.com/rodjek))
|
49
|
+
- \(MAINT\) Bump version to 1.11.0.pre [\#651](https://github.com/puppetlabs/pdk/pull/651) ([scotje](https://github.com/scotje))
|
50
|
+
- \(PDK-1335\) Add development note when on Windows [\#649](https://github.com/puppetlabs/pdk/pull/649) ([glennsarti](https://github.com/glennsarti))
|
51
|
+
- \(maint\) Allow developers to add additional gems [\#648](https://github.com/puppetlabs/pdk/pull/648) ([glennsarti](https://github.com/glennsarti))
|
52
|
+
- \(PDK-1167\) Validator should honor case sensitive of the file system [\#646](https://github.com/puppetlabs/pdk/pull/646) ([glennsarti](https://github.com/glennsarti))
|
53
|
+
- \(PDK-1193\) Saves packaged template-url in metadata as a keyword [\#639](https://github.com/puppetlabs/pdk/pull/639) ([bmjen](https://github.com/bmjen))
|
54
|
+
|
7
55
|
## [v1.10.0](https://github.com/puppetlabs/pdk/tree/v1.10.0) (2019-04-02)
|
8
56
|
[Full Changelog](https://github.com/puppetlabs/pdk/compare/v1.9.1...v1.10.0)
|
9
57
|
|
@@ -22,6 +70,7 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
22
70
|
|
23
71
|
**Merged pull requests:**
|
24
72
|
|
73
|
+
- \(PDK-1324\) Release 1.10.0 [\#650](https://github.com/puppetlabs/pdk/pull/650) ([rodjek](https://github.com/rodjek))
|
25
74
|
- \(maint\) Fix package specs for template-ref changes [\#647](https://github.com/puppetlabs/pdk/pull/647) ([rodjek](https://github.com/rodjek))
|
26
75
|
- \(maint\) Enforce LF line endings in Rubocop [\#645](https://github.com/puppetlabs/pdk/pull/645) ([glennsarti](https://github.com/glennsarti))
|
27
76
|
- \(FM-7579, PDK-1236\) bump the version of CRI used [\#638](https://github.com/puppetlabs/pdk/pull/638) ([tphoney](https://github.com/tphoney))
|
@@ -896,4 +945,4 @@ See the [release notes](https://puppet.com/docs/pdk/latest/release_notes.html) f
|
|
896
945
|
|
897
946
|
|
898
947
|
|
899
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
948
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/lib/pdk.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require 'pdk/analytics'
|
1
2
|
require 'pdk/answer_file'
|
3
|
+
require 'pdk/config'
|
2
4
|
require 'pdk/generate'
|
3
5
|
require 'pdk/i18n'
|
4
6
|
require 'pdk/logger'
|
@@ -7,4 +9,17 @@ require 'pdk/template_file'
|
|
7
9
|
require 'pdk/validate'
|
8
10
|
require 'pdk/version'
|
9
11
|
|
10
|
-
module PDK
|
12
|
+
module PDK
|
13
|
+
def self.analytics
|
14
|
+
@analytics ||= PDK::Analytics.build_client(
|
15
|
+
logger: PDK.logger,
|
16
|
+
disabled: ENV['PDK_DISABLE_ANALYTICS'] || PDK.config.user['analytics']['disabled'],
|
17
|
+
user_id: PDK.config.user['analytics']['user-id'],
|
18
|
+
app_id: "UA-139917834-#{PDK::Util.development_mode? ? '2' : '1'}",
|
19
|
+
client: :google_analytics,
|
20
|
+
app_name: 'pdk',
|
21
|
+
app_version: PDK::VERSION,
|
22
|
+
app_installer: PDK::Util.package_install? ? 'package' : 'gem',
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'pdk/analytics/util'
|
3
|
+
require 'pdk/analytics/client/google_analytics'
|
4
|
+
require 'pdk/analytics/client/noop'
|
5
|
+
|
6
|
+
module PDK
|
7
|
+
module Analytics
|
8
|
+
CLIENTS = {
|
9
|
+
noop: Client::Noop,
|
10
|
+
google_analytics: Client::GoogleAnalytics,
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
def self.build_client(opts = {})
|
14
|
+
opts[:logger] ||= ::Logger.new(STDERR)
|
15
|
+
opts[:client] ||= :noop
|
16
|
+
|
17
|
+
if opts[:disabled]
|
18
|
+
opts[:logger].debug 'Analytics opt-out is set, analytics will be disabled'
|
19
|
+
CLIENTS[:noop].new(opts)
|
20
|
+
else
|
21
|
+
CLIENTS[opts[:client]].new(opts)
|
22
|
+
end
|
23
|
+
rescue StandardError => e
|
24
|
+
opts[:logger].debug "Failed to initialize analytics client, analytics will be disabled: #{e}"
|
25
|
+
CLIENTS[:noop].new(opts)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
module PDK
|
2
|
+
module Analytics
|
3
|
+
module Client
|
4
|
+
class GoogleAnalytics
|
5
|
+
PROTOCOL_VERSION = 1
|
6
|
+
TRACKING_URL = 'https://google-analytics.com/collect'.freeze
|
7
|
+
CUSTOM_DIMENSIONS = {
|
8
|
+
operating_system: :cd1,
|
9
|
+
output_format: :cd2,
|
10
|
+
ruby_version: :cd3,
|
11
|
+
cli_options: :cd4,
|
12
|
+
env_vars: :cd5,
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
attr_reader :user_id
|
16
|
+
attr_reader :logger
|
17
|
+
attr_reader :app_name
|
18
|
+
attr_reader :app_id
|
19
|
+
attr_reader :app_version
|
20
|
+
attr_reader :app_installer
|
21
|
+
|
22
|
+
def initialize(opts)
|
23
|
+
# lazy-load expensive gem code
|
24
|
+
require 'concurrent/configuration'
|
25
|
+
require 'concurrent/future'
|
26
|
+
require 'httpclient'
|
27
|
+
require 'locale'
|
28
|
+
|
29
|
+
@http = HTTPClient.new
|
30
|
+
@user_id = opts[:user_id]
|
31
|
+
@executor = Concurrent.global_io_executor
|
32
|
+
@os = PDK::Analytics::Util.fetch_os_async
|
33
|
+
@logger = opts[:logger]
|
34
|
+
@app_name = opts[:app_name]
|
35
|
+
@app_id = opts[:app_id]
|
36
|
+
@app_version = opts[:app_version]
|
37
|
+
@app_installer = opts[:app_installer]
|
38
|
+
end
|
39
|
+
|
40
|
+
def screen_view(screen, **kwargs)
|
41
|
+
custom_dimensions = walk_keys(kwargs) do |k|
|
42
|
+
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '#{k}'")
|
43
|
+
end
|
44
|
+
|
45
|
+
screen_view_params = {
|
46
|
+
# Type
|
47
|
+
t: 'screenview',
|
48
|
+
# Screen Name
|
49
|
+
cd: screen,
|
50
|
+
}.merge(custom_dimensions)
|
51
|
+
|
52
|
+
submit(base_params.merge(screen_view_params))
|
53
|
+
end
|
54
|
+
|
55
|
+
def event(category, action, label: nil, value: nil, **kwargs)
|
56
|
+
custom_dimensions = walk_keys(kwargs) do |k|
|
57
|
+
CUSTOM_DIMENSIONS[k] || raise("Unknown analytics key '#{k}'")
|
58
|
+
end
|
59
|
+
|
60
|
+
event_params = {
|
61
|
+
# Type
|
62
|
+
t: 'event',
|
63
|
+
# Event Category
|
64
|
+
ec: category,
|
65
|
+
# Event Action
|
66
|
+
ea: action,
|
67
|
+
}.merge(custom_dimensions)
|
68
|
+
|
69
|
+
# Event Label
|
70
|
+
event_params[:el] = label if label
|
71
|
+
# Event Value
|
72
|
+
event_params[:ev] = value if value
|
73
|
+
|
74
|
+
submit(base_params.merge(event_params))
|
75
|
+
end
|
76
|
+
|
77
|
+
def submit(params)
|
78
|
+
# Handle analytics submission in the background to avoid blocking the
|
79
|
+
# app or polluting the log with errors
|
80
|
+
Concurrent::Future.execute(executor: @executor) do
|
81
|
+
logger.debug "Submitting analytics: #{JSON.pretty_generate(params)}"
|
82
|
+
@http.post(TRACKING_URL, params)
|
83
|
+
logger.debug 'Completed analytics submission'
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# These parameters have terrible names. See this page for complete documentation:
|
88
|
+
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
|
89
|
+
def base_params
|
90
|
+
{
|
91
|
+
v: PROTOCOL_VERSION,
|
92
|
+
# Client ID
|
93
|
+
cid: user_id,
|
94
|
+
# Tracking ID
|
95
|
+
tid: app_id,
|
96
|
+
# Application Name
|
97
|
+
an: app_name,
|
98
|
+
# Application Version
|
99
|
+
av: app_version,
|
100
|
+
# Application Installer ID
|
101
|
+
aiid: app_installer,
|
102
|
+
# Anonymize IPs
|
103
|
+
aip: true,
|
104
|
+
# User locale
|
105
|
+
ul: Locale.current.to_rfc,
|
106
|
+
# Custom Dimension 1 (Operating System)
|
107
|
+
cd1: @os.value,
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
# If the user is running a very fast command, there may not be time for
|
112
|
+
# analytics submission to complete before the command is finished. In
|
113
|
+
# that case, we give a little buffer for any stragglers to finish up.
|
114
|
+
# 250ms strikes a balance between accomodating slower networks while not
|
115
|
+
# introducing a noticeable "hang".
|
116
|
+
def finish
|
117
|
+
@executor.shutdown
|
118
|
+
@executor.wait_for_termination(0.25)
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def walk_keys(data, &block)
|
124
|
+
if data.is_a?(Hash)
|
125
|
+
data.each_with_object({}) do |(k, v), acc|
|
126
|
+
v = walk_keys(v, &block)
|
127
|
+
acc[yield(k)] = v
|
128
|
+
end
|
129
|
+
elsif data.is_a?(Array)
|
130
|
+
data.map { |v| walk_keys(v, &block) }
|
131
|
+
else
|
132
|
+
data
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module PDK
|
2
|
+
module Analytics
|
3
|
+
module Client
|
4
|
+
class Noop
|
5
|
+
attr_reader :logger
|
6
|
+
|
7
|
+
def initialize(opts)
|
8
|
+
@logger = opts[:logger]
|
9
|
+
end
|
10
|
+
|
11
|
+
def screen_view(screen, **_kwargs)
|
12
|
+
logger.debug "Skipping submission of '#{screen}' screenview because analytics is disabled"
|
13
|
+
end
|
14
|
+
|
15
|
+
def event(category, action, **_kwargs)
|
16
|
+
logger.debug "Skipping submission of '#{category} #{action}' event because analytics is disabled"
|
17
|
+
end
|
18
|
+
|
19
|
+
def finish; end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module PDK
|
2
|
+
module Analytics
|
3
|
+
module Util
|
4
|
+
def self.fetch_os_async
|
5
|
+
require 'concurrent/configuration'
|
6
|
+
require 'concurrent/future'
|
7
|
+
|
8
|
+
Concurrent::Future.execute(executor: :io) do
|
9
|
+
require 'facter'
|
10
|
+
os = Facter.value('os')
|
11
|
+
|
12
|
+
os.nil? ? 'unknown' : "#{os['name']} #{os.fetch('release', {}).fetch('major', '')}".strip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/pdk/cli.rb
CHANGED
@@ -13,8 +13,45 @@ require 'pdk/report'
|
|
13
13
|
require 'pdk/util/version'
|
14
14
|
require 'pdk/util/puppet_version'
|
15
15
|
|
16
|
+
class Cri::Command::CriExitException
|
17
|
+
def initialize(is_error:)
|
18
|
+
@is_error = is_error
|
19
|
+
PDK.analytics.event('CLI', 'invalid command', label: PDK::CLI.anonymised_args.join(' ')) if error?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
module PDK::CLI
|
24
|
+
# Attempt to anonymise the raw ARGV array if the command parsing failed.
|
25
|
+
#
|
26
|
+
# If an item does not start with '-' but is preceeded by an item that does
|
27
|
+
# start with '-', assume that these items are an option/value pair and redact
|
28
|
+
# the value. Any additional values that do not start with '-' that follow an
|
29
|
+
# option/value pair are assumed to be arguments (rather than subcommand
|
30
|
+
# names) and are also redacted.
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# # Where PDK::CLI.args => ['new', 'plan', '--some', 'value', 'plan_name']
|
34
|
+
#
|
35
|
+
# PDK::CLI.anonymised_args
|
36
|
+
# => ['new', 'plan', '--some', 'redacted', 'redacted']
|
37
|
+
#
|
38
|
+
# @return Array[String] the command arguments with any identifying values
|
39
|
+
# redacted.
|
40
|
+
def self.anonymised_args
|
41
|
+
in_args = false
|
42
|
+
@args.map do |arg|
|
43
|
+
if arg.start_with?('-')
|
44
|
+
in_args = true
|
45
|
+
arg
|
46
|
+
else
|
47
|
+
in_args ? 'redacted' : arg
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
17
52
|
def self.run(args)
|
53
|
+
@args = args
|
54
|
+
PDK::Config.analytics_config_interview! unless PDK::Config.analytics_config_exist?
|
18
55
|
@base_cmd.run(args)
|
19
56
|
rescue PDK::CLI::ExitWithError => e
|
20
57
|
PDK.logger.send(e.log_level, e.message)
|
data/lib/pdk/cli/build.rb
CHANGED
data/lib/pdk/cli/bundle.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module PDK::CLI
|
3
2
|
@bundle_cmd = @base_cmd.define_command do
|
4
3
|
name 'bundle'
|
@@ -20,6 +19,8 @@ EOF
|
|
20
19
|
|
21
20
|
PDK::CLI::Util.validate_puppet_version_opts({})
|
22
21
|
|
22
|
+
PDK::CLI::Util.analytics_screen_view('bundle')
|
23
|
+
|
23
24
|
# Ensure that the correct Ruby is activated before running commend.
|
24
25
|
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env({})
|
25
26
|
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])
|
data/lib/pdk/cli/convert.rb
CHANGED
@@ -28,6 +28,8 @@ module PDK::CLI
|
|
28
28
|
raise PDK::CLI::ExitWithError, _('You can not specify --noop and --force when converting a module')
|
29
29
|
end
|
30
30
|
|
31
|
+
PDK::CLI::Util.analytics_screen_view('convert', opts)
|
32
|
+
|
31
33
|
if opts[:'skip-interview'] && opts[:'full-interview']
|
32
34
|
PDK.logger.info _('Ignoring --full-interview and continuing with --skip-interview.')
|
33
35
|
opts[:'full-interview'] = false
|
data/lib/pdk/cli/exec.rb
CHANGED
@@ -121,6 +121,24 @@ module PDK
|
|
121
121
|
@environment.merge!(additional_env)
|
122
122
|
end
|
123
123
|
|
124
|
+
def check_for_legacy_env_vars
|
125
|
+
if ENV['PUPPET_GEM_VERSION']
|
126
|
+
PDK.logger.warn_once _(
|
127
|
+
'PUPPET_GEM_VERSION is not supported by PDK. ' \
|
128
|
+
'Please use the --puppet-version option on your PDK command ' \
|
129
|
+
'or set the PDK_PUPPET_VERSION environment variable instead',
|
130
|
+
)
|
131
|
+
@process.environment['PUPPET_GEM_VERSION'] = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
%w[FACTER HIERA].each do |gem|
|
135
|
+
if ENV["#{gem}_GEM_VERSION"]
|
136
|
+
PDK.logger.warn_once _("#{gem}_GEM_VERSION is not supported by PDK.")
|
137
|
+
@process.environment["#{gem}_GEM_VERSION"] = nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
124
142
|
def execute!
|
125
143
|
# Start spinning if configured.
|
126
144
|
@spinner.auto_spin if @spinner
|
@@ -130,6 +148,8 @@ module PDK
|
|
130
148
|
@process.environment[k] = v
|
131
149
|
end
|
132
150
|
|
151
|
+
check_for_legacy_env_vars
|
152
|
+
|
133
153
|
@process.environment['BUNDLE_IGNORE_CONFIG'] = '1'
|
134
154
|
|
135
155
|
if [:module, :pwd].include?(context)
|
@@ -179,7 +199,14 @@ module PDK
|
|
179
199
|
duration: @duration,
|
180
200
|
}
|
181
201
|
|
182
|
-
|
202
|
+
PDK.logger.debug _('STDOUT: %{output}') % {
|
203
|
+
output: process_data[:stdout].empty? ? 'N/A' : "\n#{process_data[:stdout]}",
|
204
|
+
}
|
205
|
+
PDK.logger.debug _('STDERR: %{output}') % {
|
206
|
+
output: process_data[:stderr].empty? ? 'N/A' : "\n#{process_data[:stderr]}",
|
207
|
+
}
|
208
|
+
|
209
|
+
process_data
|
183
210
|
ensure
|
184
211
|
@stdout.close
|
185
212
|
@stderr.close
|