gitlab

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDateTime added in v0.3.0

func ParseDateTime(dateTime string) (time.Time, error)

ParseDateTime validates that dateTime complies with the ISO 8601 format time.RFC3339 = "2006-01-02T15:04:05Z07:00" which is subset of the ISO 8601 which allows using timezones

Types

type Assets added in v0.3.0

type Assets struct {
	Count   int `json:"count,omitempty"`
	Sources []struct {
		Format string `json:"format"`
		URL    string `json:"url"`
	} `json:"sources,omitempty"`
	Links []*Link `json:"links"`
}

Assets describes the assets as Links associated to a release.

func AssetMarshaller added in v0.11.0

func AssetMarshaller(assetLink []string) (*Assets, error)

AssetMarshaller parses asset links, either single instance of them or as an array.

func ParseAssets added in v0.3.0

func ParseAssets(assetsLink []string) (*Assets, error)

ParseAssets generates an instance of Asset from names and urls

type Author added in v0.9.0

type Author struct {
	ID        int    `json:"id"`
	Name      string `json:"name"`
	Username  string `json:"username"`
	State     string `json:"state"`
	AvatarURL string `json:"avatar_url"`
	WebURL    string `json:"web_url"`
}

Author body

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is used to send requests to the GitLab API. Normally created with the `New` function

func New

func New(serverURL, jobToken, privateToken, projectID string, httpClient HTTPClient, logger log.FieldLogger) (*Client, error)

New creates a new GitLab Client

func (*Client) CreateRelease

func (gc *Client) CreateRelease(ctx context.Context, createReleaseReq *CreateReleaseRequest) (*CreateReleaseResponse, error)

CreateRelease will try to create a release via GitLab's Releases API

func (*Client) GetRelease added in v0.9.0

func (gc *Client) GetRelease(ctx context.Context, tagName string, includeHTML bool) (*GetReleaseResponse, error)

GetRelease by tagName

type Commit added in v0.9.0

type Commit struct {
	ID             string    `json:"id"`
	ShortID        string    `json:"short_id"`
	Title          string    `json:"title"`
	CreatedAt      time.Time `json:"created_at"`
	ParentIds      []string  `json:"parent_ids"`
	Message        string    `json:"message"`
	AuthorName     string    `json:"author_name"`
	AuthorEmail    string    `json:"author_email"`
	AuthoredDate   time.Time `json:"authored_date"`
	CommitterName  string    `json:"committer_name"`
	CommitterEmail string    `json:"committer_email"`
	CommittedDate  time.Time `json:"committed_date"`
}

Commit body

type CreateReleaseRequest

type CreateReleaseRequest struct {
	ID          string     `json:"id"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	TagName     string     `json:"tag_name"`
	TagMessage  string     `json:"tag_message"`
	Ref         string     `json:"ref,omitempty"`
	Assets      *Assets    `json:"assets,omitempty"`
	Milestones  []string   `json:"milestones,omitempty"`
	ReleasedAt  *time.Time `json:"released_at,omitempty"`
}

CreateReleaseRequest body. The full documentation can be found at https://docs.gitlab.com/ee/api/releases/index.html#create-a-release

type CreateReleaseResponse

type CreateReleaseResponse struct {
	Name            string       `json:"name"`
	Description     string       `json:"description"`
	DescriptionHTML string       `json:"description_html"`
	TagName         string       `json:"tag_name"`
	CreatedAt       time.Time    `json:"created_at"`
	ReleasedAt      time.Time    `json:"released_at"`
	Assets          *Assets      `json:"assets,omitempty"`
	Milestones      []*Milestone `json:"milestones,omitempty"`
}

CreateReleaseResponse body. The full documentation can be found at https://docs.gitlab.com/ee/api/releases/index.html#create-a-release

type Date added in v0.10.0

type Date time.Time

Date is a custom time.Time wrapper that can parse a date without a timestamp See https://gitlab.com/gitlab-org/release-cli/-/issues/121.

func (Date) MarshalJSON added in v0.10.0

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*Date) UnmarshalJSON added in v0.10.0

func (d *Date) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message,omitempty"`
	// Err will only be populated if the Releases API returns an unexpected error and is not contained in Message
	Err string `json:"error,omitempty"`
	// contains filtered or unexported fields
}

ErrorResponse expected from the API

func (*ErrorResponse) Error

func (er *ErrorResponse) Error() string

Error implements the error interface. Wraps an error message from the API into an error type

type Evidence added in v0.9.0

type Evidence struct {
	Sha         string    `json:"sha"`
	Filepath    string    `json:"filepath"`
	CollectedAt time.Time `json:"collected_at"`
}

Evidence body

type GetReleaseResponse added in v0.9.0

type GetReleaseResponse struct {
	TagName         string       `json:"tag_name"`
	Description     string       `json:"description"`
	DescriptionHTML string       `json:"description_html,omitempty"`
	Name            string       `json:"name"`
	CreatedAt       time.Time    `json:"created_at"`
	ReleasedAt      time.Time    `json:"released_at"`
	Author          *Author      `json:"author"`
	Commit          *Commit      `json:"commit"`
	Milestones      []*Milestone `json:"milestones"`
	CommitPath      string       `json:"commit_path"`
	TagPath         string       `json:"tag_path"`
	Assets          *Assets      `json:"assets"`
	Evidences       []*Evidence  `json:"evidences"`
}

GetReleaseResponse body from the API. The full documentation can be found at https://docs.gitlab.com/ee/api/releases/index.html#get-a-release-by-a-tag-name

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient is an interface that describes the available actions of the client. Use http.Client during runtime. See mock_httpClient_test.go for a testing implementation

type Link struct {
	ID       int64  `json:"id,omitempty"`
	Name     string `json:"name"`
	URL      string `json:"url"`
	External bool   `json:"external,omitempty"`
	LinkType string `json:"link_type,omitempty"`
	Filepath string `json:"filepath,omitempty"`
}

Link describes the Link request/response body.

type Milestone added in v0.3.0

type Milestone struct {
	ID          int       `json:"id"`
	Iid         int       `json:"iid"`
	ProjectID   int       `json:"project_id"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	State       string    `json:"state"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	DueDate     *Date     `json:"due_date"`
	StartDate   *Date     `json:"start_date"`
	WebURL      string    `json:"web_url"`
	IssueStats  struct {
		Total  int `json:"total"`
		Closed int `json:"closed"`
	} `json:"issue_stats"`
}

Milestone response body when creating a release. Only uses a subset of all the fields. The full documentation can be found at https://docs.gitlab.com/ee/api/releases/index.html#create-a-release

type MockHTTPClient added in v0.2.0

type MockHTTPClient struct {
	mock.Mock
}

MockHTTPClient is an autogenerated mock type for the HTTPClient type

func (*MockHTTPClient) Do added in v0.2.0

func (_m *MockHTTPClient) Do(_a0 *http.Request) (*http.Response, error)

Do provides a mock function with given fields: _a0

Jump to

Keyboard shortcuts

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