Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateEnvironmentVariables(ctx context.Context, apiBaseURL string, repoID int64, principalID int64, ...) (map[string]string, error)
- func GetInputBaseFromPayload(p Payload) types.GithookInputBase
- func LoadFromEnvironment() (*hook.CLICore, error)
- func NewRestClient(payload Payload) hook.Client
- type Payload
- type RestClient
- type RestClientFactory
Constants ¶
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 ¶
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 ¶
LoadFromEnvironment returns a new githook.CLICore created by loading the payload from the environment variable.
func NewRestClient ¶
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.
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.