Class: PDK::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/pdk/config.rb,
lib/pdk/config/json.rb,
lib/pdk/config/yaml.rb,
lib/pdk/config/value.rb,
lib/pdk/config/errors.rb,
lib/pdk/config/namespace.rb,
lib/pdk/config/validator.rb
Defined Under Namespace
Modules: Validator
Classes: JSON, LoadError, Namespace, Value, YAML
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.analytics_config_exist? ⇒ Boolean
63
64
65
|
# File 'lib/pdk/config.rb', line 63
def self.analytics_config_exist?
PDK::Util::Filesystem.file?(analytics_config_path)
end
|
.analytics_config_interview! ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/pdk/config.rb', line 67
def self.analytics_config_interview!
return unless PDK::CLI::Util.interactive?
pre_message = _(
'PDK collects anonymous usage information to help us understand how ' \
'it is being used and make decisions on how to improve it. You can ' \
'find out more about what data we collect and how it is used in the ' \
"PDK documentation at %{url}.\n",
) % { url: 'https://puppet.com/docs/pdk/latest/pdk_install.html' }
post_message = _(
'You can opt in or out of the usage data collection at any time by ' \
'editing the analytics configuration file at %{path} and changing ' \
"the '%{key}' value.",
) % {
path: PDK::Config.analytics_config_path,
key: 'disabled',
}
questions = [
{
name: 'enabled',
question: _('Do you consent to the collection of anonymous PDK usage information?'),
type: :yes,
},
]
PDK.logger.info(text: pre_message, wrap: true)
prompt = TTY::Prompt.new(help_color: :cyan)
interview = PDK::CLI::Util::Interview.new(prompt)
interview.add_questions(questions)
answers = interview.run
if answers.nil?
PDK.logger.info _('No answer given, opting out of analytics collection.')
PDK.config.user['analytics']['disabled'] = true
else
PDK.config.user['analytics']['disabled'] = !answers['enabled']
end
PDK.logger.info(text: post_message, wrap: true)
end
|
.analytics_config_path ⇒ Object
55
56
57
|
# File 'lib/pdk/config.rb', line 55
def self.analytics_config_path
ENV['PDK_ANALYTICS_CONFIG'] || File.join(File.dirname(PDK::Util.configdir), 'puppet', 'analytics.yml')
end
|
.bolt_analytics_config ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/pdk/config.rb', line 44
def self.bolt_analytics_config
file = File.expand_path('~/.puppetlabs/bolt/analytics.yaml')
PDK::Config::YAML.new(file: file)
rescue PDK::Config::LoadError => e
PDK.logger.debug _('Unable to load %{file}: %{message}') % {
file: file,
message: e.message,
}
PDK::Config::YAML.new
end
|
.user_config_path ⇒ Object
59
60
61
|
# File 'lib/pdk/config.rb', line 59
def self.user_config_path
File.join(PDK::Util.configdir, 'user_config.json')
end
|
Instance Method Details
#resolve(filter = nil) ⇒ Hash{String => Object}
Resolves all filtered settings from all namespaces
40
41
42
|
# File 'lib/pdk/config.rb', line 40
def resolve(filter = nil)
user.resolve(filter)
end
|