Skip to content
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

(maint) Raise error when template content is empty #782

Closed
wants to merge 1 commit into from

Conversation

logicminds
Copy link
Contributor

  • Throws and error if the content is nil. This fixes a problem
    when a template cannot be rendered correctly due to some filesytem
    issue.

    This was originally seen when config_defaults.yml had a
    delte: true set for any of the files.

    The error message previously thrown was confusing so this is meant
    to throw a better error message.

  * Throws and error if the content is nil.  This fixes a problem
    when a template cannot be rendered correctly due to some filesytem
    issue.

    This was originally seen when config_defaults.yml had a
      delte: true set for any of the files.

    The error message previously thrown was confusing so this is meant
    to throw a better error message.
@logicminds logicminds requested a review from a team as a code owner October 18, 2019 22:37
@logicminds logicminds changed the title (maint) Raise error when template content is empty or nil (maint) Raise error when template content is empty Oct 18, 2019
@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 91.723% when pulling 06e9288 on nwops:filesystem_error into e059be6 on puppetlabs:master.

@@ -2,6 +2,7 @@ module PDK
module Util
module Filesystem
def write_file(path, content)
raise ArgumentError, "#{path} is empty" unless content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably go a step further here. content is expected to be a string due to the ...encode command later.

An empty string would be a valid content, but a nil value would not.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this should be using the gettext format e.g.

raise PDK::CLI::ExitWithError, _(
          '%{message} Rename the file or exclude it from the package ' \
          'by adding it to the .pdkignore file in your module.',
        ) % { message: e.message }

@rodjek
Copy link
Contributor

rodjek commented Oct 30, 2019

See #794

@rodjek rodjek closed this Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants