-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Metadata.from_file to reliably raise #503
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Working from direct branches seems to trigger double builds in travis/appveyor. :/ |
Expanded this a little bit to handle the underlying issue a bit better and make sure the error messages and warnings are useful. Also added tests. |
When no `metadata.json` exists, `File.file?` can throw nasty exceptions: ``` david@davids:~/git/pdk$ ./bin/pdk bundle list Traceback (most recent call last): 11: from ./bin/pdk:29:in `<main>' 10: from ./bin/pdk:29:in `load' 9: from /home/david/git/pdk/exe/pdk:6:in `<top (required)>' 8: from /home/david/git/pdk/lib/pdk/cli.rb:18:in `run' 7: from /home/david/gems/ruby/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:287:in `run' 6: from /home/david/gems/ruby/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:269:in `run' 5: from /home/david/gems/ruby/2.5.0/gems/cri-2.10.1/lib/cri/command.rb:329:in `run_this' 4: from /home/david/git/pdk/lib/pdk/cli/bundle.rb:24:in `block (2 levels) in <module:CLI>' 3: from /home/david/git/pdk/lib/pdk/cli/util.rb:96:in `puppet_from_opts_or_env' 2: from /home/david/git/pdk/lib/pdk/util/puppet_version.rb:86:in `from_module_metadata' 1: from /home/david/git/pdk/lib/pdk/module/metadata.rb:48:in `from_file' /home/david/git/pdk/lib/pdk/module/metadata.rb:48:in `file?': no implicit conversion of nil into String (TypeError) david@davids:~/git/pdk$ ```
If a module doesn't have metadata.json, the .find_upwards helper will return nil. We shouldn't send nil to the metadata helper but if we do it should handle it more gracefully.
PDK::Util::PuppetVersion.from_module_metadata now issues a warning and returns nil if the module does not have a metadata.json file.
The `pdk convert` acceptance tests were not specifying a --template-url which caused them to fall back to reading whatever template-url was specified in the users answers file, rather than the same template-url that was used to generate the test module. Also the tests were expecting there to be a .project file to manage but that was recently removed from the templates.
bmjen
approved these changes
May 8, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When no
metadata.json
exists,File.file?
can throw nasty exceptions: