api

package
v5.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Custom content type for API responses, to catch routing / programming mistakes
	ResponseContentType = "application/vnd.gitlab-workhorse+json"

	// This header carries the JWT token for gitlab-rails
	RequestHeader = "Gitlab-Workhorse-Api-Request"
)

Variables

This section is empty.

Functions

func Block added in v0.8.0

func Block(h http.Handler) http.Handler

Prevent internal API responses intended for gitlab-workhorse from leaking to the end user

Types

type API

type API struct {
	Client  *http.Client
	URL     *url.URL
	Version string
}

func NewAPI

func NewAPI(myURL *url.URL, version string, roundTripper *badgateway.RoundTripper) *API

func (*API) PreAuthorize added in v1.2.0

func (api *API) PreAuthorize(suffix string, r *http.Request) (httpResponse *http.Response, authResponse *Response, outErr error)

Perform a pre-authorization check against the API for the given HTTP request

If `outErr` is set, the other fields will be nil and it should be treated as a 500 error.

If httpResponse is present, the caller is responsible for closing its body

authResponse will only be present if the authorization check was successful

func (*API) PreAuthorizeHandler

func (api *API) PreAuthorizeHandler(next HandleFunc, suffix string) http.Handler

type HandleFunc

type HandleFunc func(http.ResponseWriter, *http.Request, *Response)

type MultipartUploadParams

type MultipartUploadParams struct {
	// PartSize is the exact size of each uploaded part. Only the last one can be smaller
	PartSize int64
	// PartURLs contains the presigned URLs for each part
	PartURLs []string
	// CompleteURL is a presigned URL for CompleteMulipartUpload
	CompleteURL string
	// AbortURL is a presigned URL for AbortMultipartUpload
	AbortURL string
}

type RemoteObject

type RemoteObject struct {
	// GetURL is an S3 GetObject URL
	GetURL string
	// DeleteURL is a presigned S3 RemoveObject URL
	DeleteURL string
	// StoreURL is the temporary presigned S3 PutObject URL to which upload the first found file
	StoreURL string
	// ID is a unique identifier of object storage upload
	ID string
	// Timeout is a number that represents timeout in seconds for sending data to StoreURL
	Timeout int
	// MultipartUpload contains presigned URLs for S3 MultipartUpload
	MultipartUpload *MultipartUploadParams
}

type Response

type Response struct {
	// GL_ID is an environment variable used by gitlab-shell hooks during 'git
	// push' and 'git pull'
	GL_ID string

	// GL_USERNAME holds gitlab username of the user who is taking the action causing hooks to be invoked
	GL_USERNAME string

	// GL_REPOSITORY is an environment variable used by gitlab-shell hooks during
	// 'git push' and 'git pull'
	GL_REPOSITORY string
	// RepoPath is the full path on disk to the Git repository the request is
	// about
	RepoPath string
	// StoreLFSPath is provided by the GitLab Rails application to mark where the tmp file should be placed.
	// This field is deprecated. GitLab will use TempPath instead
	StoreLFSPath string
	// LFS object id
	LfsOid string
	// LFS object size
	LfsSize int64
	// TmpPath is the path where we should store temporary files
	// This is set by authorization middleware
	TempPath string
	// RemoteObject is provided by the GitLab Rails application
	// and defines a way to store object on remote storage
	RemoteObject RemoteObject
	// Archive is the path where the artifacts archive is stored
	Archive string `json:"archive"`
	// Entry is a filename inside the archive point to file that needs to be extracted
	Entry string `json:"entry"`
	// Used to communicate terminal session details
	Terminal *TerminalSettings
	// GitalyServer specifies an address and authentication token for a gitaly server we should connect to.
	GitalyServer gitaly.Server
	// Repository object for making gRPC requests to Gitaly. This will
	// eventually replace the RepoPath field.
	Repository pb.Repository
	// For git-http, does the requestor have the right to view all refs?
	ShowAllRefs bool
}

type TerminalSettings added in v1.2.0

type TerminalSettings struct {
	// The terminal provider may require use of a particular subprotocol. If so,
	// it must be specified here, and Workhorse must have a matching codec.
	Subprotocols []string

	// The websocket URL to connect to.
	Url string

	// Any headers (e.g., Authorization) to send with the websocket request
	Header http.Header

	// The CA roots to validate the remote endpoint with, for wss:// URLs. The
	// system-provided CA pool will be used if this is blank. PEM-encoded data.
	CAPem string

	// The value is specified in seconds. It is converted to time.Duration
	// later.
	MaxSessionTime int
}

func (*TerminalSettings) Clone added in v1.2.0

func (t *TerminalSettings) Clone() *TerminalSettings

func (*TerminalSettings) Dial added in v1.2.0

func (*TerminalSettings) Dialer added in v1.2.0

func (t *TerminalSettings) Dialer() *websocket.Dialer

func (*TerminalSettings) IsEqual added in v1.2.0

func (t *TerminalSettings) IsEqual(other *TerminalSettings) bool

func (*TerminalSettings) URL added in v1.2.0

func (t *TerminalSettings) URL() (*url.URL, error)

func (*TerminalSettings) Validate added in v1.2.0

func (t *TerminalSettings) Validate() error

Jump to

Keyboard shortcuts

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