gitprovider

package
v0.2.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package gitprovider holds the small slice of REST-client plumbing that is genuinely identical across internal/githubapp, internal/gitlabapp, and internal/bitbucketapp: sending a built request and turning its response into either a decoded value or a uniform API error. Request construction (auth scheme, headers, pagination shape) stays in each provider's own package, since that is exactly where the three providers' real, non-coincidental differences live.

Index

Constants

View Source
const MaxErrorBodySnippet = 512

MaxErrorBodySnippet caps how much of a non-2xx response body an APIError retains, so a misbehaving upstream can't inflate a log line unboundedly.

Variables

This section is empty.

Functions

func Execute

func Execute(client *http.Client, req *http.Request, prefix, api, label string, out any) error

Execute sends req and, on a 2xx response, decodes its body into out (skipped when out is nil). prefix and api identify the caller for both wrapped errors and a returned *APIError's own message; label is the method/URL text those wrapped errors describe, since GitHub's own caller wraps a relative path while GitLab's and Bitbucket's wrap a full URL.

Types

type APIError

type APIError struct {
	Prefix     string
	API        string
	StatusCode int
	Body       string
}

APIError is returned for any non-2xx response from a git provider's REST API. Prefix and API identify the caller (e.g. "gitlabapp", "gitlab") so Error() reproduces that client's own message shape.

func (*APIError) Error

func (e *APIError) Error() string

Jump to

Keyboard shortcuts

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