Documentation
¶
Overview ¶
Package harness is the import surface for Privateer harnesses (the pvtr CLI and future similar tools) — the commands that drive plugins rather than the commands a plugin serves about itself.
This is a separate, nested package by design, to exploit Go's per-package import resolution. Go computes a consumer's transitive dependency closure from the packages it actually imports, so isolating the harness commands here keeps their heavy dependency stack (internal/install, internal/publish, internal/oci, sigstore, oras, go-git, ...) out of the closure of anyone who does not import this package. Plugins import package command for NewPluginCommands and never touch this subpackage, so they don't compile or link against — or carry in their go.sum — the harness-only dependencies. Only harnesses, which import command/harness directly, take those on.
Most of these are thin forwarders to implementations that still live in package command; a few (publish, login/logout) have already been relocated here. Either way the exported names match command's, so the pvtr CLI can migrate its imports (command.GetInstallCmd -> harness.GetInstallCmd, etc.) without a flag-day change. As each command's logic moves out of command/ and into here, package command sheds more of its install/publish/oci/git dependency stack, until it is purely the plugin-facing surface (NewPluginCommands, SetBase, ReadConfig).
The plugin-facing helpers (NewPluginCommands, SetBase, ReadConfig) are deliberately NOT re-exported here: they stay in package command, which both plugins and harnesses continue to import directly.
Index ¶
- Constants
- func Contains(slice []*PluginPkg, search string) bool
- func GeneratePlugin(logger hclog.Logger) (exitCode int)
- func GetBenchmarkCmd(writerFn func() Writer) *cobra.Command
- func GetInstallCmd(writerFn func() Writer) *cobra.Command
- func GetListCmd(writerFn func() Writer) *cobra.Command
- func GetLoginCmd(writerFn func() Writer) *cobra.Command
- func GetLogoutCmd(writerFn func() Writer) *cobra.Command
- func GetPublishCmd(writerFn func() Writer) *cobra.Command
- func Run(ctx context.Context, w Writer, logger hclog.Logger, ...) (exitCode int)
- func SetHarnessFlags(cmd *cobra.Command)
- func SetListCmdFlags(cmd *cobra.Command)
- type CatalogData
- type PluginConfig
- type PluginError
- type PluginErrors
- type PluginPkg
- type Req
- type Writer
Constants ¶
const ( TestPass = shared.TestPass TestFail = shared.TestFail Aborted = shared.Aborted InternalError = shared.InternalError BadUsage = shared.BadUsage NoTests = shared.NoTests )
Exit-code values, identical to package command
Variables ¶
This section is empty.
Functions ¶
func GeneratePlugin ¶
GeneratePlugin forwards to command.GeneratePlugin.
func GetBenchmarkCmd ¶ added in v1.32.0
GetBenchmarkCmd returns the `pvtr benchmark` command.
func GetInstallCmd ¶
GetInstallCmd forwards to command.GetInstallCmd.
func GetListCmd ¶
GetListCmd forwards to command.GetListCmd.
func GetLoginCmd ¶
GetLoginCmd returns the `pvtr login` command. Its implementation has already been relocated into this package (see login.go).
func GetLogoutCmd ¶
GetLogoutCmd returns the `pvtr logout` command. Its implementation has already been relocated into this package (see login.go).
func GetPublishCmd ¶
GetPublishCmd returns the `pvtr publish` command. Its implementation has already been relocated into this package (see publish.go).
func Run ¶
func Run(ctx context.Context, w Writer, logger hclog.Logger, getPlugins func() []*PluginPkg) (exitCode int)
Run executes the plugins selected by getPlugins, first running the autoinstall preflight: when the config sets `autoinstall: true`, any requested-but-missing plugins are installed from grc.store before the run, so a single `pvtr run` works without a separate `pvtr install` step. Folding the preflight in here makes "a run installs what it needs" a guarantee of the run entry point rather than a convention each caller must remember; it is a no-op when autoinstall is disabled, leaving the usual "not installed" failure.
ctx bounds the preflight's hub/registry calls. w receives install progress and is flushed before plugins start. logger and getPlugins drive the run loop.
func SetHarnessFlags ¶
SetHarnessFlags registers the harness-global flags on a harness's root command (the pvtr CLI calls this on its root, alongside command.SetBase).
These are HARNESS concerns — they drive install/publish/run, not a plugin serving itself — so they live here rather than in command.SetBase. Keeping them out of SetBase also keeps the oci dependency out of the plugin-facing surface (plugins import package command, never command/harness).
Each flag binds to the same viper key its config.yml / PVTR_* env equivalent uses, so a value may come from flag, env, or config file. Precedence (highest first): flag > PVTR_* env > config.yml > the default shown here.
func SetListCmdFlags ¶
SetListCmdFlags forwards to command.SetListCmdFlags.
Types ¶
type CatalogData ¶
type CatalogData = command.CatalogData
Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.
type PluginConfig ¶
type PluginConfig = command.PluginConfig
Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.
type PluginError ¶
type PluginError = command.PluginError
Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.
type PluginErrors ¶
type PluginErrors = command.PluginErrors
Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.
type PluginPkg ¶
Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.
func NewPluginPkg ¶
NewPluginPkg forwards to command.NewPluginPkg.