githook

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTPRequestPathPreReceive is the subpath under the provided base url the client uses to call pre-receive.
	HTTPRequestPathPreReceive = "pre-receive"

	// HTTPRequestPathPostReceive is the subpath under the provided base url the client uses to call post-receive.
	HTTPRequestPathPostReceive = "post-receive"

	// HTTPRequestPathUpdate is the subpath under the provided base url the client uses to call update.
	HTTPRequestPathUpdate = "update"
)

Variables

View Source
var (
	// ExecutionTimeout is the timeout used for githook CLI runs.
	ExecutionTimeout = 3 * time.Minute
)

Functions

func GenerateEnvironmentVariables

func GenerateEnvironmentVariables(
	ctx context.Context,
	apiBaseURL string,
	repoID int64,
	principalID int64,
	disabled bool,
	internal bool,
) (map[string]string, error)

GenerateEnvironmentVariables generates the required environment variables for a payload constructed from the provided parameters. The parameter `internal` should be true if the call is coming from the Harness and therefore protection from rules shouldn't be verified.

func GetInputBaseFromPayload

func GetInputBaseFromPayload(p Payload) types.GithookInputBase

func LoadFromEnvironment

func LoadFromEnvironment() (*hook.CLICore, error)

LoadFromEnvironment returns a new githook.CLICore created by loading the payload from the environment variable.

func NewRestClient

func NewRestClient(
	payload Payload,
) hook.Client

Types

type Payload

type Payload struct {
	BaseURL     string
	RepoID      int64
	PrincipalID int64
	RequestID   string
	Disabled    bool
	Internal    bool // Internal calls originate from Harness, and external calls are direct git pushes.
}

Payload defines the payload that's send to git via environment variables.

func (Payload) Validate

func (p Payload) Validate() error

type RestClient

type RestClient struct {
	// contains filtered or unexported fields
}

RestClient is the hook.Client used to call the githooks api of Harness api server.

func (*RestClient) PostReceive

func (c *RestClient) PostReceive(
	ctx context.Context,
	in hook.PostReceiveInput,
) (hook.Output, error)

PostReceive calls the post-receive githook api of the Harness api server.

func (*RestClient) PreReceive

func (c *RestClient) PreReceive(
	ctx context.Context,
	in hook.PreReceiveInput,
) (hook.Output, error)

PreReceive calls the pre-receive githook api of the Harness api server.

func (*RestClient) Update

func (c *RestClient) Update(
	ctx context.Context,
	in hook.UpdateInput,
) (hook.Output, error)

Update calls the update githook api of the Harness api server.

type RestClientFactory

type RestClientFactory struct{}

RestClientFactory creates clients that make rest api calls to Harness to execute githooks.

func (*RestClientFactory) NewClient

func (f *RestClientFactory) NewClient(envVars map[string]string) (hook.Client, error)

Jump to

Keyboard shortcuts

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