(PUP-2901/PE-4524) Add module dependency validation

Prior to this commit there wasn't much verification for module dependencies.
This commit adds verification the module dependencies have sane names and version
ranges. If verification fails, it will raise an argument exception.
That would be fine.


On Wed, Jul 30, 2014 at 3:46 PM, Anderson Mills <notifications@github.com>
wrote:

> In lib/puppet/module_tool/metadata.rb:
>
> >
> >        @data.merge!(data)
> >        return self
> >      end
> >
> > +    # Validates the name and version_requirement for a dependency, then creates
> > +    # the Dependency and adds it.
> > +    # Returns the Dependency that was added.
> > +    def add_dependency(name, version_requirement=nil, repository=nil)
> > +      validate_name(name)
> > +      validate_version_range(version_requirement) if version_requirement
> > +      duplicates = @data['dependencies'].select { |d| d.full_module_name == name }
> > +      unless duplicates.empty?
> > +        duplicates.each do |dup|
> > +          if dup.version_requirement != version_requirement
> > +            raise ArgumentError, "Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json or the Modulefile."
>
> Would it be fine if we got wording from her stating "there should only be
> one dependency requirement for any given module, and that should be in
> metadata.json."?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/puppetlabs/puppet/pull/2838/files#r15617641>.
>