harness

package
v1.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

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

View Source
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 Contains

func Contains(slice []*PluginPkg, search string) bool

Contains forwards to command.Contains.

func GeneratePlugin

func GeneratePlugin(logger hclog.Logger) (exitCode int)

GeneratePlugin forwards to command.GeneratePlugin.

func GetBenchmarkCmd added in v1.32.0

func GetBenchmarkCmd(writerFn func() Writer) *cobra.Command

GetBenchmarkCmd returns the `pvtr benchmark` command.

func GetInstallCmd

func GetInstallCmd(writerFn func() Writer) *cobra.Command

GetInstallCmd forwards to command.GetInstallCmd.

func GetListCmd

func GetListCmd(writerFn func() Writer) *cobra.Command

GetListCmd forwards to command.GetListCmd.

func GetLoginCmd

func GetLoginCmd(writerFn func() Writer) *cobra.Command

GetLoginCmd returns the `pvtr login` command. Its implementation has already been relocated into this package (see login.go).

func GetLogoutCmd

func GetLogoutCmd(writerFn func() Writer) *cobra.Command

GetLogoutCmd returns the `pvtr logout` command. Its implementation has already been relocated into this package (see login.go).

func GetPublishCmd

func GetPublishCmd(writerFn func() Writer) *cobra.Command

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

func SetHarnessFlags(cmd *cobra.Command)

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

func SetListCmdFlags(cmd *cobra.Command)

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 PluginPkg = command.PluginPkg

Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.

func GetPlugins

func GetPlugins() []*PluginPkg

GetPlugins forwards to command.GetPlugins.

func NewPluginPkg

func NewPluginPkg(pluginName, version, serviceName string) *PluginPkg

NewPluginPkg forwards to command.NewPluginPkg.

type Req

type Req = command.Req

Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.

type Writer

type Writer = command.Writer

Type aliases (identity-preserving) so values cross the package boundary freely: harness.PluginPkg is literally command.PluginPkg, etc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL