Module: PDK::CLI::Release
- Defined in:
- lib/pdk/cli/release.rb
Class Method Summary collapse
-
.module_compatibility_checks!(release, opts) ⇒ Object
Checks whether the module is compatible with PDK release process.
- .prepare_interview(opts) ⇒ Object
- .prepare_publish_interview(prompt, opts) ⇒ Object
- .prepare_version_interview(prompt, opts) ⇒ Object
Class Method Details
.module_compatibility_checks!(release, opts) ⇒ Object
Checks whether the module is compatible with PDK release process
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/pdk/cli/release.rb', line 55 def self.module_compatibility_checks!(release, opts) unless release..forge_ready? if opts[:force] PDK.logger.warn "This module is missing the following fields in the metadata.json: #{release..missing_fields.join(', ')}. " \ 'These missing fields may affect the visibility of the module on the Forge.' else release..interview_for_forge! release. end end unless release.pdk_compatible? # rubocop:disable Style/GuardClause Nope! if opts[:force] PDK.logger.warn 'This module is not compatible with PDK, so PDK can not validate or test this build.' else PDK.logger.info 'This module is not compatible with PDK, so PDK can not validate or test this build. ' \ 'Unvalidated modules may have errors when uploading to the Forge. ' \ 'To make this module PDK compatible and use validate features, cancel the build and run `pdk convert`.' unless PDK::CLI::Util.prompt_for_yes('Continue build without converting?') PDK.logger.info 'Build cancelled; exiting.' PDK::Util.exit_process(1) end end end end |
.prepare_interview(opts) ⇒ Object
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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/pdk/cli/release.rb', line 81 def self.prepare_interview(opts) questions = [] unless opts[:'skip-validation'] questions << { name: 'validation', question: 'Do you want to run the module validation ?', type: :yes } end unless opts[:'skip-changelog'] questions << { name: 'changelog', question: 'Do you want to run the automatic changelog generation ?', type: :yes } end unless opts[:version] questions << { name: 'setversion', question: 'Do you want to set the module version ?', type: :yes } end unless opts[:'skip-dependency'] questions << { name: 'dependency', question: 'Do you want to run the dependency-checker on this module?', type: :yes } end unless opts[:'skip-documentation'] questions << { name: 'documentation', question: 'Do you want to update the documentation for this module?', type: :yes } end unless opts[:'skip-publish'] questions << { name: 'publish', question: 'Do you want to publish the module on the Puppet Forge?', type: :yes } end prompt = TTY::Prompt.new(help_color: :cyan) interview = PDK::CLI::Util::Interview.new(prompt) interview.add_questions(questions) answers = interview.run unless answers.nil? opts[:'skip-validation'] = !answers['validation'] opts[:'skip-changelog'] = !answers['changelog'] opts[:'skip-dependency'] = !answers['dependency'] opts[:'skip-documentation'] = !answers['documentation'] opts[:'skip-publish'] = !answers['publish'] prepare_version_interview(prompt, opts) if answers['setversion'] prepare_publish_interview(prompt, opts) if answers['publish'] end answers end |
.prepare_publish_interview(prompt, opts) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/pdk/cli/release.rb', line 163 def self.prepare_publish_interview(prompt, opts) return if opts[:'forge-token'] questions = [ { name: 'apikey', question: 'Please set the api key(authorization token) to upload on the Puppet Forge', help: 'This value is used for authentication on the Puppet Forge to upload your module tarball.', required: true } ] interview = PDK::CLI::Util::Interview.new(prompt) interview.add_questions(questions) api_answer = interview.run opts[:'forge-token'] = api_answer['apikey'] end |
.prepare_version_interview(prompt, opts) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/pdk/cli/release.rb', line 146 def self.prepare_version_interview(prompt, opts) questions = [ { name: 'version', question: 'Please set the module version', help: 'This value is the version that will be used in the changelog generator and building of the module.', required: true, validate_pattern: /(\*|\d+(\.\d+){0,2}(\.\*)?)$/i, validate_message: 'The version format should be in the format x.y.z where x represents the major version, y the minor version and z the build number.' } ] interview = PDK::CLI::Util::Interview.new(prompt) interview.add_questions(questions) ver_answer = interview.run opts[:version] = ver_answer['version'] end |