gh

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Executor
}

Client executes secret operations via the gh CLI. Executor is embedded so methods like ExecContext are promoted directly onto Client.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a Client, verifying that the gh CLI is available. Pass functional options to override defaults (e.g. WithExecutor for tests).

func (*Client) CurrentRepository added in v0.2.0

func (c *Client) CurrentRepository(ctx context.Context) (string, error)

CurrentRepository returns the current GitHub repository in owner/repo format.

func (*Client) UpsertRepoSecret

func (c *Client) UpsertRepoSecret(ctx context.Context, req UpsertSecretRequest) error

UpsertRepoSecret sets a secret on a repository by delegating to the gh CLI.

type Executor

type Executor interface {
	// Path returns the path to the gh binary, or an error if not found.
	Path() (string, error)
	// ExecContext invokes a gh subcommand and returns its stdout and stderr.
	ExecContext(ctx context.Context, args ...string) (stdout, stderr bytes.Buffer, err error)
}

Executor abstracts the gh CLI subprocess calls so the Client can be unit-tested.

type Option

type Option func(*Client)

Option configures a Client.

func WithExecutor

func WithExecutor(exec Executor) Option

WithExecutor replaces the default gh CLI executor. Primarily for testing.

type UpsertSecretRequest

type UpsertSecretRequest struct {
	Repo  string
	Name  string
	Value string
}

UpsertSecretRequest holds the data needed to upsert one secret to one repo. Repo must be in "owner/repo" format.

func (UpsertSecretRequest) Validate

func (r UpsertSecretRequest) Validate() error

Validate checks that the request has all required fields.

Jump to

Keyboard shortcuts

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