Documentation
¶
Overview ¶
Copyright © 2023 Xu Wu <ixw1991@126.com> Use of this source code is governed by a MIT style license that can be found in the LICENSE file.
Index ¶
- type Client
- func (c *Client) CopyProjectVariables(sourceProjectID, targetProjectID string) error
- func (c *Client) CreateBranch(projectID, branch, ref string) error
- func (c *Client) CreateCommitFromFiles(projectID string, files map[string]*FileData) error
- func (c *Client) CreateProjectInGroup(name, group, desc string) error
- func (c *Client) DeleteProject(projectID string) error
- func (c *Client) EnableRunner(sourceProjectID, targetProjectID string) error
- func (c *Client) GetProjectArchive(projectWithNamespace string) ([]byte, error)
- func (c *Client) IsProjectExist(projectWithNamespace string) (bool, error)
- func (c *Client) ListProjectsInGroup(groupName string) (map[string]string, error)
- func (c *Client) SetDefaultBranch(projectID, branch string) error
- type Config
- type FileData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 结构体包含一个go-gitlab客户端实例
func NewClient ¶
NewClient 函数创建一个新的GitLab客户端,接收GitLab的URL和token作为参数 如果没有提供URL或者URL是默认的GitLab URL,那么会使用默认的GitLab URL创建客户端 如果没有提供token,那么会返回一个错误
func (*Client) CopyProjectVariables ¶
func (*Client) CreateBranch ¶
func (*Client) CreateCommitFromFiles ¶
func (*Client) CreateProjectInGroup ¶
CreateProjectInGroup 在指定的 GitLab 组内创建一个新项目。 name 参数是新项目的名称。 group 参数是项目所属的 GitLab 组的名称。 desc 参数是新项目的描述。 如果项目创建成功,返回 nil error。 如果在查找组 ID 或创建项目过程中出现错误,返回对应的 error。
func (*Client) DeleteProject ¶
func (*Client) EnableRunner ¶
func (*Client) GetProjectArchive ¶
GetProjectArchive 通过项目名(包括命名空间)获取指定项目的源码压缩包 输入参数 projectWithNamespace 是包括命名空间的 GitLab 项目名。 返回值是一个字节切片,其中包含了项目的 tar.gz 归档文件。如果在获取归档文件过程中发生错误,会返回一个非 nil 的 error。
func (*Client) IsProjectExist ¶
IsProjectExist 函数用于检查在 GitLab 中是否存在特定的项目。 该函数接收一个包含项目名称和命名空间的字符串作为输入(例如,"namespace/project")。
函数返回两个值:
- 一个布尔值,表示项目是否存在(true)或不存在(false)。
- 一个 error,如果在过程中发生错误,它将是非空的。如果项目不存在, 但是向 GitLab 的查询是成功的(即,项目只是不存在), 则函数将返回 false 和一个 nil error。
该函数通过尝试从 GitLab 获取项目信息来工作。如果请求成功 (即使项目不存在),函数将返回一个 nil error。 如果请求失败(例如,由于网络问题、认证问题等), 函数将返回相应的错误。
func (*Client) ListProjectsInGroup ¶
ListProjectsInGroup 方法根据提供的组名获取组内的所有项目,返回一个包含项目名和项目描述的map,如果组不存在则返回错误