Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AssetInfo ¶
type AssetInfo struct {
ID int64 // 附件的唯一 ID(由平台生成),用于删除或引用
Name string // 附件的名称(如文件名),如 "app-v1.0.0-linux-amd64.tar.gz"
URL string // 附件的下载 URL(通常是公开链接或 API 地址)
}
AssetInfo 表示一个发布版本(Release)中附带的单个附件信息。 常用于获取、上传或删除 Release 中的二进制包、安装文件等资源。
type IPlatform ¶
type IPlatform interface {
credential.ICredential
IPlatformRepo
IPlatformReleases
}
func GetPlatform ¶
func GetPlatform(repo *url.URL, cred *credential.Credential) (IPlatform, error)
type IPlatformReleases ¶
type IPlatformReleases interface {
// ListTags 列出指定仓库的所有标签
ListTags(ctx context.Context, fullName string) ([]*TagInfo, error)
// GetTagReleaseInfo 获取指定仓库下的某个标签信息
GetTagReleaseInfo(ctx context.Context, fullName, tagName string) (*ReleaseInfo, error)
// CreateRelease 在指定仓库下创建一个新的发布版本
CreateRelease(ctx context.Context, fullName string, releaseInfo *ReleaseInfo) (newTagInfo *ReleaseInfo, er error)
// DeleteReleaseAssets 删除指定发布版本下的一个或多个资源文件
DeleteReleaseAssets(ctx context.Context, releaseInfo *ReleaseInfo, filenames []string) error
// UploadReleaseAsset 上传一个或多个资源文件到指定的发布版本
UploadReleaseAsset(ctx context.Context, releaseInfo *ReleaseInfo, filenames []string) error
}
IPlatformReleases 定义了平台发布版本相关的操作
type IPlatformRepo ¶
type IPlatformRepo interface {
// ListOrgRepo 列出指定组织下的所有仓库。
ListOrgRepo(ctx context.Context, orgName string) ([]*RepoInfo, error)
// ListUserRepo 列出当前用户自己创建或拥有的仓库。
ListUserRepo(ctx context.Context) ([]*RepoInfo, error)
// GetRepoDetail 获取单个仓库的详细信息。
GetRepoDetail(ctx context.Context, fullName string) (*RepoInfo, error)
// CreateRepo 创建一个新的仓库。
CreateRepo(ctx context.Context, repoInfo *RepoInfo) error
// DeleteRepo 删除指定的仓库。
DeleteRepo(ctx context.Context, repoInfo *RepoInfo) error
}
IPlatformRepo 定义了对代码托管平台仓库的操作接口。 包括列出仓库、获取单个仓库、创建和删除仓库等操作。
type ReleaseInfo ¶
type ReleaseInfo struct {
ID int64 // Release 的唯一 ID(由平台生成),用于获取或删除
TagName string // 关联的标签名,例如 "v1.0.0"
Title string // Release 的标题名称,例如 "Initial Release"
Description string // Release 的详细描述内容(通常用于更新日志等),例如 "Added login feature, fixed bugs"
FullName string // 仓库全名,通常是 "组织名/仓库名",例如: "my-org/my-repo"
Assets []*AssetInfo // 附件列表,表示该 Release 中包含的所有资源文件(如安装包、构建产物等)
}
func (*ReleaseInfo) GetOwnerRepo ¶
func (ri *ReleaseInfo) GetOwnerRepo() (owner string, repo string, err error)
GetOwnerRepo extracts the repository owner and repository name from FullName. FullName format is usually "owner/repo", but may contain multiple path segments. Rules: - owner: the first segment - repo: the remaining segments joined by "/" Examples:
"openai/chatgpt" -> owner="openai", repo="chatgpt" "google/cloud/storage" -> owner="google", repo="cloud/storage" "microsoft/azure/devops" -> owner="microsoft", repo="azure/devops"
func (*ReleaseInfo) Init ¶
func (ri *ReleaseInfo) Init()
type RepoInfo ¶
type RepoInfo struct {
ID int64 // 仓库唯一 ID,例如: 123456
Name string // 仓库名称(短名),例如: "my-repo"
FullName string // 仓库全名,通常是 "组织名/仓库名",例如: "my-org/my-repo"
Description string // 仓库描述信息,例如: "这是一个示例仓库"
Homepage string // 仓库主页链接,例如: "https://example.com"
IsPrivate bool // 是否为私有仓库,例如: true
CloneURL string // 克隆仓库的 URL(HTTPS 或 SSH),例如: "https://github.com/my-org/my-repo.git"
}
RepoInfo 表示代码托管平台上的仓库信息
func (*RepoInfo) GetOrgName ¶
func (*RepoInfo) GetOwnerRepo ¶
GetOwnerRepo extracts the repository owner and repository name from FullName. FullName format is usually "owner/repo", but may contain multiple path segments. Rules: - owner: the first segment - repo: the remaining segments joined by "/" Examples:
"openai/chatgpt" -> owner="openai", repo="chatgpt" "google/cloud/storage" -> owner="google", repo="cloud/storage" "microsoft/azure/devops" -> owner="microsoft", repo="azure/devops"