gitlab

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: MIT Imports: 14 Imported by: 2

README

GITLAB API library

This library is aimed for cooperative access of many users to a single gitlab instance.

Usage

package main

import (
	"context"
	"log"
	
	"github.com/sirkon/gitlab"
)

func main() {
	access := gitlab.NewAPIAccess(nil, "gitlab.com/api/v4")
	client := access.Client("user-token")
	
	tags, err := client.Tags(context.Background(), "user/project", "")
	if err != nil {
		log.Fatal(err)
	}
	
	log.Printf("%#v", tags)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIAccess

type APIAccess interface {
	Client(token string) Client
}

APIAccess spawns API clients for a given user

func NewAPIAccess

func NewAPIAccess(httpClient *http.Client, url string) APIAccess

NewAPIAccess creates an access point to gitlab API instance

httpClient can be nil, http.DefaultClient will be used if it is
url must be a full path to gitlab API, e.g. https://gitlab.com/api/v4, etc

type Client

type Client interface {
	// Tags get all tags for a given project
	Tags(ctx context.Context, project, tagPrefix string) ([]*gitlabdata.Tag, error)

	// File gets a file with given path and ref (branch, tag or commit SHA) from a given project. Returns os.ErrNotExist
	// if  gitlab API responses with 404 HTTP status code
	File(ctx context.Context, project, path, ref string) ([]byte, error)

	// ProjectInfo gets an info for a given project
	ProjectInfo(ctx context.Context, project string) (*gitlabdata.Project, error)

	// Archive gets an archive for a given project. Needs explicit numeric project ID unlike other methods
	Archive(ctx context.Context, projectID int, ref string) (io.ReadCloser, error)

	// Commits get commits history for given branch, tag or commit (via SHA).
	Commits(ctx context.Context, project string, ref string) ([]*gitlabdata.Commit, error)
}

Client an implementation of gitlab API access for a given user

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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