artifact

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 7 Imported by: 0

README

制品管理服务

为应用部署提供制品

Documentation

Index

Constants

View Source
const (
	ARCH_X86   = "x86"
	ARCH_AMD64 = "amd64"
	ARCH_ARM64 = "arm64"
)
View Source
const (
	APP_NAME = "artifact"
)
View Source
const (
	RESOURCE_PREFIX = "art"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ARCH

type ARCH string

type Artifact

type Artifact struct {
	// 制品Id, Hash(服务Id+分支+Commit)
	Id string `json:"id" bson:"_id" gorm:"column:id;primaryKey"`
	// 创建时间
	CreateAt time.Time `json:"create_at" bson:"create_at" gorm:"column:create_at"`
	// 制品信息
	ArtifactSpec

	// 资产清单 (镜像, Jar包, Helm Chat, Static Web Zip)
	Assets []Asset `json:"assets" bson:"-" gorm:"-"`
}

制品

func NewArtifact

func NewArtifact(req ArtifactSpec) *Artifact

func (*Artifact) AddAsset

func (a *Artifact) AddAsset(assets ...Asset)

func (*Artifact) GetFirstByLabel

func (a *Artifact) GetFirstByLabel(key, value string) *Asset

func (*Artifact) String

func (a *Artifact) String() string

func (Artifact) TableName

func (a Artifact) TableName() string

type ArtifactSpec

type ArtifactSpec struct {
	// 服务Id, 关联得有仓库
	ServiceId string `json:"service_id" bson:"service_id" gorm:"column:service_id"`
	// 分支
	Branch string `json:"branch" bson:"branch" gorm:"column:branch"`
	// Commit号
	Commit string `json:"commit" bson:"commit" gorm:"column:commit"`
	// 制品版本(Tag)
	Version string `json:"version" bson:"version" gorm:"column:version"`
}

type Asset

type Asset struct {
	// 管理制品信息
	RefArtifactId string `json:"ref_artifact_id" bson:"ref_artifact_id" gorm:"column:ref_artifact_id;type:varchar(60)"`
	// 制品资产具体信息
	AssetSpec
}

制品资产

func NewAsset

func NewAsset(refArtifactId string, req AssetSpec) *Asset

func (Asset) GetLabel

func (a Asset) GetLabel(key string) string

func (*Asset) String

func (a *Asset) String() string

func (Asset) TableName

func (Asset) TableName() string

type AssetSpec

type AssetSpec struct {
	// 制品Id
	Id string `json:"id" bson:"_id" gorm:"column:id;primaryKey"`
	// 制品上传时间
	UploadAt time.Time `json:"upload_at" bson:"upload_at" gorm:"column:upload_at"`
	// 上传人
	UploadBy string `json:"upload_by" bson:"upload_by" gorm:"column:upload_by;type:varchar(60)"`
	// 制品格式
	Format FORMAT `json:"format" bson:"format" gorm:"column:format;type:varchar(60)"`
	// 资源URL
	URL string `json:"url" bson:"url" gorm:"column:url;type:varchar(120)"`
	// 架构, 能用于那些场景
	Arch ARCH `json:"arch" bson:"arch" gorm:"column:arch;type:varchar(60)"`
	// 资产标签, env=prod
	Lables map[string]string `json:"lables" bson:"lables" gorm:"column:lables;serializer:json;"`
	// 资产的其他属性
	Extras map[string]string `json:"extras" bson:"extras" gorm:"column:extras;serializer:json;"`
}

func (*AssetSpec) SetLabel

func (a *AssetSpec) SetLabel(k, v string) *AssetSpec

type DescribeArtifactRequest

type DescribeArtifactRequest struct {
	// 制品Id, Hash(应用Id+分支+Commit)
	Id string `json:"id" bson:"_id"`
}

func NewDescribeArtifactRequest

func NewDescribeArtifactRequest(artifactId string) *DescribeArtifactRequest

type FORMAT

type FORMAT string
const (
	// 容器镜像
	FORMAT_DOCKER_IMAGE FORMAT = "docker-image"
	// jar包
	FORMAT_JAR FORMAT = "jar"
	// helm
	FORMAT_HELM_CHAT FORMAT = "helm-chat"
	// 压缩文件 (Static Web Zip, 二进制包的部署)
	FORMAT_ZIP_FILE FORMAT = "zip-file"
)

type QueryArtifactRequest

type QueryArtifactRequest struct {
	// 分页参数
	request.PageRequest
	// 标签过滤
	Label map[string]string `json:"label"`
	// 应用Id
	ServiceId string `json:"service_id" bson:"service_id"`
	// 分支
	Branch string `json:"branch" bson:"branch"`
	// Commit号
	Commit string `json:"commit" bson:"commit"`
	//
	WithAssets bool `json:"with_assets" bson:"with_assets"`
}

func NewQueryArtifactRequest

func NewQueryArtifactRequest() *QueryArtifactRequest

type ReportArtifactRequest

type ReportArtifactRequest struct {
	// 制品信息
	ArtifactSpec
	// 制品资产
	AssetSpec
}

func NewReportArtifactRequest

func NewReportArtifactRequest() *ReportArtifactRequest

type Service

type Service interface {
	// 上报制品信息
	ReportArtifact(context.Context, *ReportArtifactRequest) (*Artifact, error)
	// 查询制品信息
	QueryArtifact(context.Context, *QueryArtifactRequest) (*types.Set[*Artifact], error)
	// 查询制品详情
	DescribeArtifact(context.Context, *DescribeArtifactRequest) (*Artifact, error)
}

func GetService

func GetService() Service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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