Skip to content

Commit

Permalink
Merge pull request #1165 from me-minus/#1164-operatingsystem_support
Browse files Browse the repository at this point in the history
Take "operatingsystem_support" parameter from answer.json
  • Loading branch information
chelnak authored Jun 14, 2023
2 parents 947c1f1 + f04c636 commit 5ca0632
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Lint/EmptyBlock:
# Offense count: 113
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 109
Max: 110

# Offense count: 27
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode.
Expand All @@ -42,7 +42,7 @@ Metrics/BlockLength:
# Offense count: 16
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 253
Max: 260

# Offense count: 53
# Configuration parameters: AllowedMethods, AllowedPatterns.
Expand Down
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 5ca0632

Please sign in to comment.