Revision 8b27dabf
Added by Ewoud Kohl van Wijngaarden about 4 years ago
lib/proxy/plugin_validators.rb | ||
---|---|---|
true
|
||
end
|
||
end
|
||
|
||
class Url < Base
|
||
def validate!(settings)
|
||
setting_value = settings[@setting_name]
|
||
raise ::Proxy::Error::ConfigurationError, "Setting '#{@setting_name}' is expected to contain a url" if setting_value.to_s.empty?
|
||
|
||
parsed = URI.parse(setting_value)
|
||
raise ::Proxy::Error::ConfigurationError, "Setting '#{@setting_name}' is missing a scheme" if parsed.scheme.nil? || parsed.scheme.empty?
|
||
|
||
true
|
||
rescue URI::InvalidURIError
|
||
raise ::Proxy::Error::ConfigurationError.new("Setting '#{@setting_name}' contains an invalid url")
|
||
end
|
||
end
|
||
end
|
Also available in: Unified diff
Fixes #29468 - Add default URL validator for plugins
URL settings are common and this moves it from a custom validator in the
Puppet module to a default. Also adds tests and ensures the dhcp and dns
libvirt providers use it too.