Skip to content

(GH-461) Add command plug-ins to extend dsc with new commands - #1808

Draft
Gijs Reijn (Gijsreyn) wants to merge 1 commit into
PowerShell:mainfrom
Gijsreyn:gh-461/main/add-command-plugins
Draft

Gijs Reijn (Gijsreyn) wants to merge 1 commit into
PowerShell:mainfrom
Gijsreyn:gh-461/main/add-command-plugins

Conversation

@Gijsreyn

Copy link
Copy Markdown
Collaborator

PR Summary

This change:

  • Adds command plug-ins: an executable with a *.dsc.plugin.json (or .yaml/.yml) manifest becomes a dsc <command> subcommand.
  • Adds dsc plugin list, a "Plug-in commands" section in dsc --help, plug-in names in dsc completer, and dsc schema --type plugin-manifest.
  • Adds the plugins.enabled setting to turn plug-ins off, also from the policy file.
  • Adds reference docs, schemas, Rust integration tests, 65 Pester tests and a changelog entry.
  • Implements phase 1 of the RFC in Add RFC for command plug-ins in DSC #1805. Relates to Add ability to have plugins to dsc.exe #461.

PR Context

The working group asked for a way to extend dsc with commands that ship separately, the way git and the .NET CLI do. The first candidate is dsclint from #1768, which should be reachable as dsc lint without compiling the linter into dsc.

DSC finds plug-in manifests in the same directories as resource and extension manifests, so installing a plug-in is the same as installing a resource. When the first argument isn't a built-in command, DSC looks for a plug-in with that command name, starts its executable with the remaining arguments, and returns its exit code. Standard input, output and error are passed through untouched.

Remarks on the design

  • Built-in commands always win. A plug-in can't replace a built-in command or its alias. Such a plug-in is still listed, marked as shadowed.
  • Two plug-ins, one command name. The first one found wins and DSC writes a warning that names both. The other is listed as shadowed. This follows Steve's suggestion on the RFC.
  • Run by type name. dsc OpenDSC/Lint runs that exact plug-in regardless of who owns the lint command. The match is case-insensitive.
  • Context for the plug-in. DSC sets DSC_EXE, DSC_VERSION, DSC_PLUGIN_COMMAND (what the user typed), DSC_PLUGIN_DIR, and forwards the trace level, trace format, progress format and ignore-settings choice as environment variables. Options given before the command name, such as --trace-level, reach the plug-in this way.
  • Help. dsc help <command> and dsc <command> --help are forwarded to the plug-in. A mistyped built-in command still gets the "did you mean" tip.
  • Disabling. With plugins.enabled set to false, plug-ins aren't discovered or run, and unknown commands fail as they do today.
  • Manifest lists. A plugins array is accepted in manifest list files, next to resources and extensions.
  • Out of scope. Completion definitions for plug-in arguments (phase 2 of the RFC, waiting on a working group decision), and installing or updating plug-ins.

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.

1 participant