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

(hack) Add bolt module show <module> command #2938

Merged
merged 1 commit into from Jul 20, 2021

Conversation

beechtom
Copy link
Contributor

This adds a new bolt module show <module> command that shows detailed
information for a module. It lists the module's name, version, summary,
available plans and tasks, operating system support, and dependencies.

!feature

  • Show detailed module information

    Bolt now supports showing detailed information about a module using
    the bolt module show <module> command and Get-BoltModule -Name <module> PowerShell cmdlet.

@beechtom beechtom marked this pull request as ready for review July 19, 2021 18:05
@beechtom beechtom requested a review from a team as a code owner July 19, 2021 18:05
lib/bolt/pal.rb Outdated
mod = Puppet.lookup(:current_environment).module(name.split(%r{[/-]}, 2).last)

unless mod && (mod.forge_name == name || mod.name == name)
raise Bolt::Error.new("Unknown module #{name}", 'bolt/unknown-module')
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise Bolt::Error.new("Unknown module #{name}", 'bolt/unknown-module')
raise Bolt::Error.new("Could not find #{name} on the modulepath. Use #{command} to install the module.", 'bolt/unknown-module')

Or something. I'm not sure users will know that this data comes from the modules on the modulepath and not the Forge, so mostly just want to clarify that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Left out the command suggestion since you can use a short module name (e.g. no author in the name), which doesn't work with the module add command.

Copy link
Contributor

@lucywyman lucywyman left a comment

Choose a reason for hiding this comment

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

  • Errors if the module doesn't exist
  • Accepts <namespace>/<module_name> syntax
  • Accepts <namespace>-<module_name> syntax
  • Accepts <module_name>
  • Formats as JSON with the JSON outputter
  • Formats a module with no metadata
  • Shows the first module on the path (modules are shadowed)
  • Gets module data locally, not from Forge
  • Handles invalid JSON in metadata.json
  • Has a nice message when a module exists on the Forge, but not the modulepath
  • Shows a module that doesn't have plans or tasks
  • Shows a project
  • Includes powershell cmdlet
  • Works when not inside a Bolt project
  • Does not list private tasks and plans

I don't think there's a lot we can do to make this better and it doesn't seem that bad, but the invalid metadata output is definitely a little odd:

lucy ~/githubs/bolt ((7c8fe299...)) $ be bolt module show mymodule
mymodule has an invalid and unparsable metadata.json file. The parse error: 783: unexpected token at '{
  "invalid"
}
'
mymodule has an invalid and unparsable metadata.json file. The parse error: 783: unexpected token at '{
  "invalid"
}
'
mymodule has an invalid and unparsable metadata.json file. The parse error: 783: unexpected token at '{
  "invalid"
}
'

This adds a new `bolt module show <module>` command that shows detailed
information for a module. It lists the module's name, version, summary,
available plans and tasks, operating system support, and dependencies.

!feature

* **Show detailed module information**

  Bolt now supports showing detailed information about a module using
  the `bolt module show <module>` command and `Get-BoltModule -Name
  <module>` PowerShell cmdlet.
@beechtom beechtom requested a review from lucywyman July 20, 2021 20:13
@lucywyman lucywyman merged commit 931ec09 into puppetlabs:main Jul 20, 2021
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.

None yet

2 participants