Skip to content

Commit

Permalink
Take "operatingsystem_support" parameter from answer.json
Browse files Browse the repository at this point in the history
  • Loading branch information
me-minus committed Jun 10, 2023
1 parent f602322 commit 013d84f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 8 additions & 2 deletions lib/pdk/generate/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ def self.prepare_metadata(opts = {})
PDK.config.with_scoped_value('module_defaults.author') { |val| defaults['author'] = val }
PDK.config.with_scoped_value('module_defaults.license') { |val| defaults['license'] = val }
defaults['license'] = opts[:license] if opts.key?(:license)
PDK.config.with_scoped_value('module_defaults.operatingsystem_support') { |val| defaults['operatingsystem_support'] = val }

metadata = PDK::Module::Metadata.new(defaults)
module_interview(metadata, opts) unless opts[:'skip-interview']

if opts[:'skip-interview']
metadata.data['operatingsystem_support'] = metadata.data['operatingsystem_support'].map { |val| PDK::Module::Metadata::OPERATING_SYSTEMS[val] }.flatten
else
module_interview(metadata, opts)
end

metadata
end
Expand Down Expand Up @@ -200,7 +206,7 @@ def self.module_interview(metadata, opts = {})
required: true,
type: :multi_select,
choices: PDK::Module::Metadata::OPERATING_SYSTEMS,
default: PDK::Module::Metadata::DEFAULT_OPERATING_SYSTEMS.map do |os_name|
default: metadata.data['operatingsystem_support'] do |os_name|
# tty-prompt uses a 1-index
PDK::Module::Metadata::OPERATING_SYSTEMS.keys.index(os_name) + 1
end
Expand Down
4 changes: 1 addition & 3 deletions lib/pdk/module/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class Metadata
'issues_url' => nil,
'dependencies' => [],
'data_provider' => nil,
'operatingsystem_support' => DEFAULT_OPERATING_SYSTEMS.map do |os_name|
OPERATING_SYSTEMS[os_name]
end.flatten,
'operatingsystem_support' => DEFAULT_OPERATING_SYSTEMS.dup,
'requirements' => [
{ 'name' => 'puppet', 'version_requirement' => '>= 7.24 < 9.0.0' }
]
Expand Down

0 comments on commit 013d84f

Please sign in to comment.