Giter Club home page Giter Club logo

metadata-json-lint's Introduction

metadata-json-lint

License Test codecov Release RubyGem Version RubyGem Downloads

The metadata-json-lint tool validates and lints metadata.json files in Puppet modules against style guidelines from the Puppet Forge module metadata recommendations.

Compatibility

metadata-json-lint is compatible with Ruby versions 2.0.0, 2.1.9, 2.3.1, and 2.4.1.

Installation

via gem command:

gem install metadata-json-lint

via Gemfile:

gem 'metadata-json-lint'

Usage

Testing with metadata-json-lint

On the command line, run metadata-json-lint with the path of your metadata.json file:

metadata-json-lint /path/to/metadata.json

Testing with metadata-json-lint as a Rake task

If you are already using puppet_spec_helper, the 'validate' task already includes metadata-json-lint.

You can also integrate metadata-json-lint checks into your tests using the Rake task. Add require 'metadata-json-lint/rake_task' to your Rakefile, and then run:

rake metadata_lint

To set options for the Rake task, include them when you define the task:

require 'metadata_json_lint'
task :metadata_lint do
  MetadataJsonLint.parse('metadata.json') do |options|
      options.strict_license = false
  end
end

Alternatively, set the option after requiring the Rake task:

require 'metadata-json-lint/rake_task'
MetadataJsonLint.options.strict_license = false

Options

  • --[no-]strict-dependencies: Whether to fail if module version dependencies are open-ended. Defaults to false.
  • --[no-]strict-license: Whether to fail on strict license check. Defaults to true.
  • --[no-]fail-on-warnings: Whether to fail on warnings. Defaults to true.
  • --[no-]strict-puppet-version: Whether to fail if Puppet version requirements are open-ended or no longer supported. Defaults to false.

Contributors

A big thank you to the contributors.

Making a new release

How to make a new release?

  • update the gemspec file with the desired version
$ git diff
diff --git a/metadata-json-lint.gemspec b/metadata-json-lint.gemspec
index c86668e..6a3ad38 100644
--- a/metadata-json-lint.gemspec
+++ b/metadata-json-lint.gemspec
@@ -2,7 +2,7 @@ require 'date'

 Gem::Specification.new do |s|
   s.name        = 'metadata-json-lint'
-  s.version     = '2.4.0'
+  s.version     = '2.5.0'
   s.date        = Date.today.to_s
   s.summary     = 'metadata-json-lint /path/to/metadata.json'
   s.description = 'Utility to verify Puppet metadata.json files'
  • export a GitHub access token as environment variable:
export CHANGELOG_GITHUB_TOKEN=*token*
  • Install deps and generate the changelog
$ bundle install --path .vendor/ --jobs=$(nproc) --with release
$ bundle exec rake changelog
Found 25 tags
Fetching tags dates: 25/25
Sorting tags...
Received issues: 103
Pull Request count: 77
Filtered pull requests: 72
Filtered issues: 26
Fetching events for issues and PR: 98
Fetching closed dates for issues: 98/98
Fetching SHAs for tags: 25
Associating PRs with tags: 72/72
Generating entry...
Done!
Generated log placed in ~/metadata-json-lint/CHANGELOG.md
  • Check the diff for CHANGELOG.md. Does it contain a breaking change but the new version is only a minor bump? Does the new release only contains bug fixes? Adjust the version properly while honouring semantic versioning. If required, regenerate the CHANGELOG.md. Afterwards submit it as a PR.

  • If it gets approved, merge the PR, create a git tag on that and push it.

metadata-json-lint's People

Contributors

3flex avatar alexjfisher avatar bastelfreak avatar baurmatt avatar bmjen avatar chelnak avatar davidmogar avatar davids avatar dependabot[bot] avatar dhollinger avatar dhoppe avatar domcleal avatar dsbaars avatar ekohl avatar electrical avatar emilienm avatar ghoneycutt avatar igalic avatar jyaworski avatar nanliu avatar nibalizer avatar pegasd avatar petems avatar raphink avatar razorsedge avatar rnelson0 avatar rodjek avatar sbadia avatar scotje avatar vstone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

metadata-json-lint's Issues

one test fails against ruby 2.7 when semantic_puppet is not present

Hello,

I tried running the tests for metadata-json-lint agains ruby 2.7 (since it's the version in debian sid) without having semantic_puppet installed (I was basically trying to cut corners to avoid needing to create one more debian package in order to package metadata-json-lint into debian) and there was one test that was failing consistently:

RUBYLIB=. GEM_PATH=/<<PKGBUILDDIR>>/debian/metadata-json-lint/usr/share/rubygems-integration/all:/<<PKGBUILDDIR>>/debian/.debhelper/generated/_source/home/.local/share/gem/ruby/2.7.0:/var/lib/gems/2.7.0:/usr/local/lib/ruby/gems/2.7.0:/usr/lib/ruby/gems/2.7.0:/usr/lib/x86_64-linux-gnu/ruby/gems/2.7.0:/usr/share/rubygems-integration/2.7.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0 ruby2.7 -S rake -f debian/ruby-tests.rake
/usr/bin/ruby2.7 -I/usr/share/rubygems-integration/all/gems/rspec-support-3.9.3/lib:/usr/share/rubygems-integration/all/gems/rspec-core-3.9.2/lib /usr/share/rubygems-integration/all/gems/rspec-core-3.9.2/exe/rspec --pattern ./spec/\*\*/\*_spec.rb --format documentation
Could not find semantic_puppet gem, falling back to internal functionality. Version checks may be less robust.

MetadataJsonLint
  .validate_requirements!
    empty requirements
      is expected not to raise Exception
    with pe
      is expected not to raise Exception
    with invalid requirement
      is expected not to raise Exception (FAILED - 1)

MetadataJsonLint::Schema
  #schema
    is expected to be a kind of Hash
  #validate
    with empty hash
      is expected to be a kind of Array
      is expected to eq 7
      is expected to include {:field => "root", :message => "The file did not contain a required property of 'author'"}
    with minimal entries
      is expected to eq []
    with validation error on entry
      is expected to eq [{:field=>"summary", :message=>"The property 'summary' was not of a maximum string length of 144"}]
    with validation error on nested entry
      is expected to eq 1
      is expected to include {:field => "dependencies", :message => (a string matching /The property 'dependencies\/0\/name' value "in###id" did not a string matching the regex/)}
    with semver validation failure
      is expected to eq 1
      is expected to include {:field => "version", :message => (a string matching /The property 'version' must be a valid semantic version/)}

MetadataJsonLint::VersionRequirement
  .new
    is expected to be a kind of MetadataJsonLint::VersionRequirement
    is expected to be a kind of MetadataJsonLint::VersionRequirement
    is expected to raise ArgumentError
  #mixed_syntax?
    is expected to equal false
    is expected to equal false
    is expected to equal false
    is expected to equal false
    is expected to equal true
    is expected to equal true
    is expected to equal true
    is expected to equal true
    is expected to equal true
    is expected to equal true
    is expected to equal true
  #open_ended?
    is expected to equal false
    is expected to equal true
    is expected to equal true

Failures:

  1) MetadataJsonLint.validate_requirements! with invalid requirement is expected not to raise Exception
     Failure/Error: expect(described_class).to receive('error').with(:requirements, "Invalid 'version_requirement' field in metadata.json: Unparsable version range: \"a\"")

       (MetadataJsonLint).error(:requirements, "Invalid 'version_requirement' field in metadata.json: Unparsable version range: \"a\"")
           expected: 1 time with arguments: (:requirements, "Invalid 'version_requirement' field in metadata.json: Unparsable version range: \"a\"")
           received: 0 times
     # ./spec/metadata_json_lint_spec.rb:32:in `block (4 levels) in <top (required)>'

Finished in 0.04038 seconds (files took 0.22268 seconds to load)
30 examples, 1 failure

This might be somewhat expected since the warning does say that version parsing is maybe less accurate when running the test suite without semantic_puppet. The same test (all of them actually) does pass when semantic_puppet is installed as a build dependency.

If that test cannot pass without semantic_puppet, maybe it should be skipped if the library is not present? or maybe it has deeper implications that I haven't thought of..

(p.s. I'm going forward with packaging semantic_puppet since the tests all pass with it, so this can be viewed as a low priority issue -- I just thought I'd report this anyway since I have the test output)

get to v1.0.0

Since this is a dependency of puppetlabs_spec_helper and is widely used, a roadmap to get to v1.0.0 should be planned.

Open-ended dependency warnings

It would be nice if metadata-json-lint warns about open-ended dependencies like gem does. To have version boundaries for all dependencies to signal the user what versions are compatible and tested is an important quality criteria in my opinion.

Example from gem:
WARNING: open-ended dependency on rake (>= 0, development) is not recommended if rake is semantically versioned, use: add_development_dependency 'rake', '~> 0'

Validate puppet version_requirement

Add validation that will parse the puppet version requirement and validate it against the following parameters:

  • It is a valid SemVer formatted version number.
  • It is within the range of supported Puppet versions.

"dependencies" error

The dependencies code needs some "relaxing". Even --no-strict-dependency had NO EFFECT on these.

{
 "dependencies": []
}

Should be fine, indicating no dependencies known at present. But it doesn't work.
Similarly, only the name attribute of an entry should be required. The version information should be optional.

     "issues_url": "",
     "dependencies": [
        { "name": "puppetlabs/stdlib" }
     ]
    }

Similarly, if the "version_requirement" tag is specified, its contents could/might be empty.
  "issues_url": "",
  "dependencies": [
    { "name": "puppetlabs/stdlib", "version_requirement": "" }
  ]
}

also doesn't work.

Work-around: add a "0" to the version_requirement

License type GPL-3.0-or-later throws warning

Using metadata-json-lint (2.1.0)

Set the following in metadata.json:

  "license": "GPL-3.0-or-later",

Run tests and get this warning message:

(WARN) license: License identifier GPL-3.0-or-later is not in the SPDX list: http://spdx.org/licenses/
Warnings found in metadata.json

The expected behavior is no warnings and the test to pass. The license is valid according to https://spdx.org/licenses/.

pdk validate does not flag task metadata files with invalid JSON escape sequence

Describe the bug
When a task metadata json file contains an invalid escape sequence, JSON linters (such as jq and Puppet Forge) raise an error but pdk validate does not flag that issue.

To Reproduce
Consider this task metadata test.json:

{
  "puppet_task_version": 1,
  "supports_noop": false,
  "description": "A description with an invalid \( escape sequence",
  "parameters": {
  }
}

pdk validate task passes normally but jq flags a problem:

cat test.json | jq
parse error: Invalid escape at line 4, column 67

Expected behavior
pdk validate raises the same error as jq.

Additional context

  • Installation method: native packages
  • PDK version 2.1
  • OS: MacOS Catalina / Ubuntu 18.04

`--no-strict-license` exits with 1

I've been using
MetadataJsonLint.options.strict_license = false

in my Rakefile and it's been working great - Warning was being issued instead of an Error and rake metadata_lint would exit with 0, but today I found out that this behavior is broken in 1.2.1

% bundle exec rake metadata_lint
(WARN) license: License identifier Proprietary is not in the SPDX list: http://spdx.org/licenses/
Warnings found in metadata.json
% echo $?
1

Current version of the Gem is Ruby >= 2 only

There is a syntax issue with Ruby < 2

SyntaxError: /.../vendor/bundle/ruby/1.9.1/gems/metadata-json-lint-1.2.2/lib/metadata_json_lint.rb:39: unknown type of %string
...on('-f', '--format FORMAT', %i[text json], 'The format in wh...
...                               ^

I had to pin the gem to 1.1 to fix it.

Fix github project title.

There's a typo. It currently reads Tool to check the validity of Puppet metatdata.json files. I think only a VP admin can fix this.

Illegal formed requirement not detected

A version_requirement of a dependency that is illegal formed is not detected.

{
  "name": "test-testmodule",
  "version": "3.0.0",
  "author": "test",
  "summary": "",
  "license": "Apache-2.0",
  "source": "",
  "project_page": "",
  "issues_url": "",
  "dependencies": [
    {
      "name": "herculesteam-augeasproviders_ssh", "version_requirement": ">=2.5.3  <3.0.0"
    }
  ],
  "operatingsystem_support": []
}

Between the lower and upper bound of the version requirement are 2 spaces.
When running metadata-json-lint no errors are displayed. So this gem approves the metadata.json file.

When running librarian-puppet the following error occurs:
/usr/share/rubygems/rubygems/requirement.rb:101:in `parse': Illformed requirement [">=2.5.3 < 3.0.0"] (Gem::Requirement::BadRequirementError)

Needs separate gem dependencies based on Puppet Version

Puppet 5.x comes with a bundled version of the semantic_puppet gem that contains new APIs not available in the semantic_puppet 1.0.0 gem used with Puppet 4.x

These new APIs are preventing Forge module installs if the semantic_puppet gem is installed.

We need to have metadata-json-lint only depend on semantic_puppet if puppet is < 5.

`--fail-on-warnings` does not fail on warnings

$ bundle list metadata-json-lint
/home/jhoblitt/github/puppet-jenkins/.bundle/ruby/2.2.0/gems/metadata-json-lint-1.0.0
$ bundle exec metadata-json-lint --fail-on-warnings
Warning: Dependency camptocamp/systemd has an open ended dependency version requirement >= 0.3.0
$ echo $?
0

Post latest release grouped rake tasks exits after running metadata_lint task.

After the latest update grouped rake tasks exit just after running metadata_lint task without any error. In the case below rake validation task exits just after running metadata_lint without running the syntax task.

desc 'Validate json hieradata'
JsonLint::RakeTask.new do |task|
  task.paths = ['data/**/*.json']
end

desc 'validation'
task :validation do
  Rake::Task[:jsonlint].invoke
  Rake::Task[:metadata_lint].invoke
  Rake::Task[:syntax].invoke
end

Confusing error/warning messages if `version_requirement` has extra characters

With version 2.2.0, when listing module deps if you put in version_requirements by mistake, you get a warning about "open ended version requirements" even if the listed version is not open ended.

This should instead flag the typo in the field name as an error since it should be version_requirement (no trailing s) instead.

Note that this only shows up if --strict-dependencies is used, but the type should probably be flagged regardless.

should this be a stack trace?

The metadata.json has a bad license "Apache 2.0" instead of "Apache-2.0"

should it throw a stack trace or just give a correct error?

Is this a bug? a bad iteracion with a another module?

bundle exec rake metadata_lint --trace
** Invoke metadata_lint (first_time)
** Execute metadata_lint
Warning: License identifier Apache 2.0 is not in the SPDX list: http://spdx.org/licenses/
rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/metadata-json-lint-0.0.6/lib/metadata_json_lint.rb:83:in `parse'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/metadata-json-lint-0.0.6/lib/metadata-json-lint/rake_task.rb:9:in `block in <top (required)>'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/otaeguis/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/bin/rake:23:in `load'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/bin/rake:23:in `<main>'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
/Users/otaeguis/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => metadata_lint

Metadata-json-lint 0.0.5 + puppet-blacksmith errors

Something with metadata-json-lint version 0.0.5 has broken rake when puppet-blacksmith is installed. The error is:

โœ— bundle exec rake spec
rake aborted!
NameError: uninitialized constant Semantic::Dependency
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/forge.rb:11:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications/installer.rb:6:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications/installer.rb:6:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications.rb:8:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications.rb:8:in `<module:Applications>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications.rb:4:in `<module:ModuleTool>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool/applications.rb:3:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool.rb:187:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-3.7.3/lib/puppet/module_tool.rb:187:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith/modulefile.rb:13:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith/modulefile.rb:13:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith.rb:5:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith.rb:5:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith/rake_tasks.rb:3:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/.bundle/vendor/gems/puppet-blacksmith-3.1.1/lib/puppet_blacksmith/rake_tasks.rb:3:in `<top (required)>'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/Rakefile:5:in `require'
/Users/jlambert/Documents/evenup/git/puppet/sensu-puppet/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

Reverting to metadata-json-lint 0.0.4 or removing puppet-blacksmith resolves the issue. voxpupuli/puppet-blacksmith#14 also exists referencing this issue.

Open ended dependencies

Would be cool if we could check for open ended dependencies like the Forge does for the scoring.

strict_dependencies = false doesn't work

Default should be false for looking at open ended dependencies but with 1.2.2 it's complaining and failing.
Tried to set the following in Rakefile

require 'metadata-json-lint/rake_task'
MetadataJsonLint.options.strict_dependencies = false

as per the README but still errors on the open ended dependencies.

Output:

# be rake test; echo $?
(WARN) dependencies: Dependency puppetlabs-stdlib has an open ended dependency version requirement >= 4.15.0
(WARN) dependencies: Dependency puppetlabs-firewall has an open ended dependency version requirement >= 1.8.2
(WARN) dependencies: Dependency puppetlabs-ntp has an open ended dependency version requirement >= 6.0.0
(WARN) dependencies: Dependency puppetlabs-inifile has an open ended dependency version requirement >= 1.6.0
(WARN) dependencies: Dependency puppetlabs-accounts has an open ended dependency version requirement >= 1.1.0
(WARN) dependencies: Dependency bashtoni-timezone has an open ended dependency version requirement >= 1.0.0
(WARN) dependencies: Dependency razorsedge-snmp has an open ended dependency version requirement >= 3.6.0
(WARN) dependencies: Dependency saz-sudo has an open ended dependency version requirement >= 4.1.0
(WARN) dependencies: Dependency puppet-selinux has an open ended dependency version requirement >= 0.8.0
(WARN) dependencies: Dependency sensu-puppet has an open ended dependency version requirement >= 2.1.0
(WARN) dependencies: Dependency puppet-yum has an open ended dependency version requirement >= 1.0.0
(WARN) dependencies: Dependency pcfens-ca_cert has an open ended dependency version requirement >= 1.6.1
(WARN) dependencies: Dependency puppetlabs-apt has an open ended dependency version requirement >= 2.3.0
(WARN) dependencies: Dependency lwf-remote_file has an open ended dependency version requirement >= 1.1.3
(WARN) dependencies: Dependency pcfens-filebeat has an open ended dependency version requirement >= 0.10.2
(WARN) dependencies: Dependency razorsedge-openvmtools has an open ended dependency version requirement >= 1.0.0
(WARN) dependencies: Dependency razorsedge-vmwaretools has an open ended dependency version requirement >= 6.0.0
(WARN) dependencies: Dependency stahnma-epel has an open ended dependency version requirement >= 1.2.2
(WARN) dependencies: Dependency treydock-yum_cron has an open ended dependency version requirement >= 2.0.0
(WARN) dependencies: Dependency herculesteam-augeasproviders_shellvar has an open ended dependency version requirement >= 2.2.1
(WARN) dependencies: Dependency herculesteam-augeasproviders_core has an open ended dependency version requirement >= 2.1.3
Warnings found in metadata.json
1

metadata-json-lint should be easier to consume as a gem, not always via CLI

I am one of the developers of the Visual Studio Code Puppet Extension (https://github.com/jpogran/puppet-vscode) and I started to add metadata lint support to the extension using this gem. Currently the metadata-json-lint is somewhat impossible to consume in a programmatic form, and assumes it will always be invoked from a command line:

  1. The parse method assumes that the metadata string is a file on disk whereas I already have the string content, and it may not actually be on disk. This method seems to conflate loading a file and parsing a file into the same method

  2. The output from parse is always via puts and the instance variables for warnings and errors are not exposed on the public API. This means even if I could parse a text string (from point 1) I wouldn't have access to any lint failures

  3. The linting options are only settable in the run method however this again means I need a file on disk. It seems the run method is conflating setting lint options and linting text content

  4. Minor nit, but the failures just say the file failed linting but doesn't give a line/char offset, but granted this is difficult to do with the current JSON parser

I will probably end up forking the gem source and adding the ability to consume the gem in a programmatic way. Would you be interesting in accepting PRs for this assume I'm not breaking any public APIs?

Rake task does not respect options

Not sure if this is a puppetlabs_spec_helper problem or an issue with this gem.
I'm using the boilerplate Rakefile from puppet module generate in version 4.7.1
Ruby env, gem versions and Rakefile below:

  • rbenv + Ruby 2.4.0
  • metadata-json-lint (1.1.0)
  • puppetlabs_spec_helper (2.1.1)

Rakefile

require 'puppetlabs_spec_helper'
require 'puppet-lint/tasks/puppet-lint'
require 'metadata-json-lint/rake_task'
...<truncated PuppetLint stuff>

desc '(override) Run metadata-json-lint'
task :lint_metadata do
  MetadataJsonLint.parse('metadata.json') do |options|
      options.strict_dependencies = false
  end
end

When I run rake validate, rake metadata_lint or the overriden task above rake lint_metadata, it runs and complains about an open-ended version requirement....which is by design as I don't want to pin my module to a specific puppetlabs/stdlib version (just the one I wrote it for).

metadata.json

{
  "name": "company/modulename",
  "version": "0.1.0",
  "author": "Thomas Cooper",
  "summary": "company modulename",
  "license": "Apache-2.0",
  "source": "https://internalgithub.com/modulename",
  "project_page": "https://internalgithub.com/modulename",
  "issues_url": "https://internalgithub.com/modulename/issues",
  "dependencies": [
    {"name":"puppetlabs/stdlib", "version_requirement": ">= 4.12.0"},   
    {"name":"puppetlabs/ciscopuppet", "version_requirement": "1.6.0"}
  ],
  "data_provider": null
}

Any idea what I might be doing wrong here? It seems like spec_helper includes standard tasks that are overwritting my desired configured one :(

Perhaps use a JSON Schema document

As part of the Puppet VS Code extension I ended up writing a JSON Schema doc for metadata.json. This gem already makes use of the JSON Schema gem (https://github.com/voxpupuli/metadata-json-lint/blob/master/lib/metadata_json_lint.rb#L85-L89)

Instead of writing/encoding the JSON rules in ruby, they can easily be expressed in JSON Schema format. Although the more esoteric rules may require more ruby magic.

This would hopefully make it easy to consume this gem programmatically (as per #85)

Source code for JSON Schema Doc.
https://github.com/jpogran/puppet-vscode/blob/master/client/src/metadata-json-schema.json

json-schema unmaintained and fails to build on ruby 2.7

Hello,

I'm currently working on getting pdk (and thus metadata-json-lint too as a dependency) packaged for debian. I was told that during the just-finished dev sprint of the debian ruby team (working on transitioning debian testing to ruby 2.7), it was found that the json-schema library fails to build from source with ruby 2.7

Info about the failure can be found here:

https://people.debian.org/~kanashiro/ruby2.7/builds/7/ruby-json-schema/ruby-json-schema_2.8.1-1+rebuild1580878603_amd64-2020-02-05T04:56:44Z.build.txt

it was brought to my attention that the json-schema library has been unmaintained for a while now. this upstream ticket about trying to find new maintainers mentions some alternative libraries that can be used instead:

voxpupuli/json-schema#423

So, for the future maintainability of metadata-json-lint, it might be worthwhile to consider switching this library for another one offering similar functionality.

I've already reported the same issue with PDK which also directly depends on json-schema, and upstream told me that the dependency to the json-schema library will be removed in pdk 2.0.0

puppetlabs/pdk#848

Cheers!

cannot load such file -- metadata-json-lint/rake_task

just done a bundle install (forked sgnl05/sssd and made a few changes) and i get the above error when running rake

using ruby 2.1.0 from PE 2012.2.1 agent install.

Am i doing something wrong?

If i use 0.0.11 i don't get the error and the rake task succeeds:

$ rake metadata_lint --trace
rake aborted!
cannot load such file -- metadata-json-lint/rake_task
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/xxx/github/sgnl05-sssd/Rakefile:6:in `<top (required)>'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/rake_module.rb:25:in `load'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/rake_module.rb:25:in `load_rakefile'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:637:in `raw_load_rakefile'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:94:in `block in load_rakefile'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:165:in `standard_exception_handling'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:93:in `load_rakefile'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:77:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:165:in `standard_exception_handling'
/opt/puppetlabs/puppet/lib/ruby/2.1.0/rake/application.rb:75:in `run'
/opt/puppetlabs/puppet/bin/rake:33:in `<main>'

Do I need to pin 0.0.11 in the Gemfile for now?

For the license: missing a file and license headers in source files

Hello,

While scrutinizing this project for creating a package for debian with it, I noticed some details that seem to be missing according to the license that you've chosen for the code:

  • There needs to be a NOTICE file at the top level
  • Each source code file should have a header comment mentioning the license and a copyright attribution

You can find more details about those two points in the following URL: https://infra.apache.org/apply-license.html

Warn when a module supports an OS that is not supported by Puppet (optional)

https://docs.puppet.com/puppet/latest/system_requirements.html lists the OSes and versions supported by Puppet. In the 1/5/2016 community triage call, it was discussed that module metadata may have compatibility with versions not supported by puppet. Notes from the meeting:

  • metadata indicates support rather than compatibility; what are thoughts on this?
    • the forge "supported" field is generated on this and is the expectation according no rnelson0
    • supported platforms should be tested. Untested platforms should not be supported
    • the forge tab does say "compatible" instead of "supported". Suggestion: indicate on the forge "compatibility" tab which platforms are provided by Puppet Inc ("officially provided" platforms) and which platforms are "Community" maintained ("magic" platforms ๐Ÿ”ฅ) eg based on https://puppet.com/content/platform-support-lifecycle ; created https://tickets.puppetlabs.com/browse/FORGE-354
    • rnelson0 wants to contribute metadata-json-lint parsing for warnings about which platforms are EOL

While the forge changes will identify new and existing modules and what compatible OSes are not supported, it would be nice to add a check to metadata-json-lint so that module owners could flag these values in their CI pipeline.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.