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

(MODULES-3430) Do not set default location to resource title #41

Conversation

ferventcoder
Copy link

@ferventcoder ferventcoder commented Aug 29, 2016

When ensuring a chocolateysource is present, location is a required value
and should be explicitly set. Previously, location would just take on the
default value of the resource title. This could be alarming to some users
who may set a resource like:

chocolateysource {'chocolatey':}

And be later surprised to find that it replaces the location value with
chocolatey instead of whatever it was originally, in this case that
value was https://chocolatey.org/api/v2/. Due to this, which could be
both alarming and upsetting, the resource should instead explicitly
require a location when ensure => present. When disabling or
removing a chocolateysource, it should be fine to simply name the
source to disable/remove.

@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3430-remove_location_default branch 3 times, most recently from 8c284bb to f86e9e9 Compare August 31, 2016 22:42
@ferventcoder ferventcoder changed the title {WIP}(MODULES-3430) Do not set default location to resource title (MODULES-3430) Do not set default location to resource title Aug 31, 2016
@ferventcoder
Copy link
Author

@puppetlabs/windows take a look.

@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3430-remove_location_default branch from f86e9e9 to 8eebf24 Compare September 1, 2016 16:52
@ferventcoder
Copy link
Author

And now we are good.

@@ -120,6 +111,10 @@ def insync?(is)
if provider.respond_to?(:validate)
provider.validate
end

if (self[:ensure].to_sym == :present && (self[:location].nil? || self[:location] == ''))
raise ArgumentError, "A non-empty location must be specified when not disabling/removing a source."

Choose a reason for hiding this comment

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

This error message is very confusing as it includes a double negative. Would prefer;
A location must be specified when setting a source

Copy link
Author

Choose a reason for hiding this comment

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

Not exactly a double negative.

non-empty is an adjective describing location.

The second part is about when it must be specified, as in when it is ensure => present (or the default of that when it is not specified). It was becoming a lot of words to express the same thing more succinctly.

@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3430-remove_location_default branch from 8eebf24 to 0a1538c Compare September 1, 2016 20:04
When ensuring a chocolateysource is present, location is a required value
and should be explicitly set. Previously, location would just take on the
default value of the resource title. This could be alarming to some users
who may set a resource like:

~~~puppet
chocolateysource {'chocolatey':}
~~~

And be later surprised to find that it replaces the location value with
`chocolatey` instead of whatever it was originally, in this case that
value was `https://chocolatey.org/api/v2/`. Due to this, which could be
both alarming and upsetting, the resource should instead explicitly
require a location when `ensure => present`. When disabling or
removing a chocolateysource, it should be fine to simply name the
source to disable/remove.
To see when someone sets the value of user => ' ' and validate
that it is not allowed, ensure to remove any extra spaces for
validation. We don't want to do the same for password, as it
may be possible the password is empty.
@ferventcoder ferventcoder force-pushed the ticket/master/MODULES-3430-remove_location_default branch from 0a1538c to 53f409e Compare September 1, 2016 20:40
@glennsarti glennsarti merged commit 8d2337d into puppetlabs:master Sep 1, 2016
@ferventcoder ferventcoder deleted the ticket/master/MODULES-3430-remove_location_default branch September 1, 2016 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants