gitlab

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts Opts) (forge.Forge, error)

New returns a Forge implementation that integrates with Gitlab, an open source Git service. See https://gitlab.com

Types

type GitLab

type GitLab struct {
	ClientID     string
	ClientSecret string
	SkipVerify   bool
	HideArchives bool
	Search       bool
	// contains filtered or unexported fields
}

Gitlab implements "Forge" interface

func (*GitLab) Activate

func (g *GitLab) Activate(ctx context.Context, user *model.User, repo *model.Repo, link string) error

Activate activates a repository by adding a Post-commit hook and a Public Deploy key, if applicable.

func (*GitLab) Auth

func (g *GitLab) Auth(ctx context.Context, token, _ string) (string, error)

Auth authenticates the session and returns the forge user login for the given token

func (*GitLab) BranchHead

func (g *GitLab) BranchHead(ctx context.Context, u *model.User, r *model.Repo, branch string) (string, error)

BranchHead returns the sha of the head (latest commit) of the specified branch

func (*GitLab) Branches

func (g *GitLab) Branches(ctx context.Context, user *model.User, repo *model.Repo, p *model.ListOptions) ([]string, error)

Branches returns the names of all branches for the named repository.

func (*GitLab) Deactivate

func (g *GitLab) Deactivate(ctx context.Context, user *model.User, repo *model.Repo, link string) error

Deactivate removes a repository by removing all the post-commit hooks which are equal to link and removing the SSH deploy key.

func (*GitLab) Dir

func (g *GitLab) Dir(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, path string) ([]*forge_types.FileMeta, error)

Dir fetches a folder from the forge repository

func (*GitLab) File

func (g *GitLab) File(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, fileName string) ([]byte, error)

File fetches a file from the forge repository and returns in string format.

func (*GitLab) Hook

func (g *GitLab) Hook(ctx context.Context, req *http.Request) (*model.Repo, *model.Pipeline, error)

Hook parses the post-commit hook from the Request body and returns the required data in a standard format.

func (*GitLab) Login

func (g *GitLab) Login(ctx context.Context, res http.ResponseWriter, req *http.Request) (*model.User, error)

Login authenticates the session and returns the forge user details.

func (*GitLab) Name

func (g *GitLab) Name() string

Name returns the string name of this driver

func (*GitLab) Netrc

func (g *GitLab) Netrc(u *model.User, r *model.Repo) (*model.Netrc, error)

Netrc returns a netrc file capable of authenticating Gitlab requests and cloning Gitlab repositories. The netrc will use the global machine account when configured.

func (*GitLab) Org

func (g *GitLab) Org(ctx context.Context, u *model.User, owner string) (*model.Org, error)

func (*GitLab) OrgMembership

func (g *GitLab) OrgMembership(ctx context.Context, u *model.User, owner string) (*model.OrgPerm, error)

OrgMembership returns if user is member of organization and if user is admin/owner in this organization.

func (*GitLab) PullRequests

func (g *GitLab) PullRequests(ctx context.Context, u *model.User, r *model.Repo, p *model.ListOptions) ([]*model.PullRequest, error)

func (*GitLab) Refresh

func (g *GitLab) Refresh(ctx context.Context, user *model.User) (bool, error)

Refresh refreshes the Gitlab oauth2 access token. If the token is refreshed the user is updated and a true value is returned.

func (*GitLab) Repo

func (g *GitLab) Repo(ctx context.Context, user *model.User, remoteID model.ForgeRemoteID, owner, name string) (*model.Repo, error)

Repo fetches the repository from the forge.

func (*GitLab) Repos

func (g *GitLab) Repos(ctx context.Context, user *model.User) ([]*model.Repo, error)

Repos fetches a list of repos from the forge.

func (*GitLab) Status

func (g *GitLab) Status(ctx context.Context, user *model.User, repo *model.Repo, pipeline *model.Pipeline, workflow *model.Workflow) error

Status sends the commit status back to gitlab.

func (*GitLab) Teams

func (g *GitLab) Teams(ctx context.Context, user *model.User) ([]*model.Team, error)

Teams fetches a list of team memberships from the forge.

func (*GitLab) URL

func (g *GitLab) URL() string

URL returns the root url of a configured forge

type Opts

type Opts struct {
	URL          string // Gitlab server url.
	ClientID     string // Oauth2 client id.
	ClientSecret string // Oauth2 client secret.
	SkipVerify   bool   // Skip ssl verification.
}

Opts defines configuration options.

Jump to

Keyboard shortcuts

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