db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMysqlMock

func InitMysqlMock() (*gorm.DB, sqlmock.Sqlmock, error)

Types

type Common

type Common struct {
	OrgID     uint32 `gorm:"org_id"`
	OrgName   string `gorm:"org_name"`
	CreatorID string `gorm:"creator_id"`
	UpdaterID string `gorm:"updater_id"`
}

type LabelRelation

type LabelRelation struct {
	dbengine.BaseModel

	LabelID uint64                      `json:"label_id"` // 标签 id
	RefType apistructs.ProjectLabelType `json:"ref_type"` // 标签作用类型, eg: issue
	RefID   string                      `json:"ref_id"`   // 标签关联目标 id
}

LabelRelation 标签关联关系

func (LabelRelation) TableName

func (LabelRelation) TableName() string

TableName 表名

type LabelRelationConfigDB

type LabelRelationConfigDB struct {
	*gorm.DB
}

func (*LabelRelationConfigDB) BatchQueryReleaseTagIDMap

func (client *LabelRelationConfigDB) BatchQueryReleaseTagIDMap(releaseIDs []string) (map[string][]uint64, error)

BatchQueryReleaseTagIDMap 批量查询 release label id

func (*LabelRelationConfigDB) CreateLabelRelation

func (client *LabelRelationConfigDB) CreateLabelRelation(lr *LabelRelation) error

CreateLabelRelation 创建标签关联关系

func (*LabelRelationConfigDB) DeleteLabelRelations

func (client *LabelRelationConfigDB) DeleteLabelRelations(refType apistructs.ProjectLabelType, refID string) error

DeleteLabelRelations 删除标签关联关系

func (*LabelRelationConfigDB) DeleteLabelRelationsByLabel

func (client *LabelRelationConfigDB) DeleteLabelRelationsByLabel(labelID uint64) error

DeleteLabelRelationsByLabel 根据 labelID 删除标签

func (*LabelRelationConfigDB) GetLabelRelationsByLabels

func (client *LabelRelationConfigDB) GetLabelRelationsByLabels(refType apistructs.ProjectLabelType, labelIDs []uint64) ([]LabelRelation, error)

GetLabelRelationsByLabels 获取标签关联关系列表

func (*LabelRelationConfigDB) GetLabelRelationsByRef

func (client *LabelRelationConfigDB) GetLabelRelationsByRef(refType apistructs.ProjectLabelType, refID string) ([]LabelRelation, error)

GetLabelRelationsByRef 获取标签关联关系列表

type Model

type Model struct {
	ID        fields.UUID      `gorm:"id"`
	CreatedAt time.Time        `gorm:"created_at"`
	UpdatedAt time.Time        `gorm:"updated_at"`
	DeletedAt fields.DeletedAt `gorm:"deleted_at"`
}

type OpusDB

type OpusDB struct {
	DB *gorm.DB
}

func (OpusDB) CreateOpus

func (o OpusDB) CreateOpus(opus *ReleaseOpus) error

func (OpusDB) DeleteOpusByReleaseID

func (o OpusDB) DeleteOpusByReleaseID(orgID uint32, releaseID string) error

func (OpusDB) QueryReleaseOpus

func (o OpusDB) QueryReleaseOpus(orgID uint32, releaseIDs []string, pageNo, pageSize int) (int64, []*ReleaseOpus, error)

type Release

type Release struct {
	// ReleaseID Generated by the server when created
	ReleaseID string `json:"releaseId" gorm:"type:varchar(64);primary_key"`
	// ReleaseName Any string, easy for users to identify, the maximum length is 255, required
	ReleaseName string `json:"releaseName" gorm:"index:idx_release_name;not null"`
	// Desc Describe, optional
	Desc string `json:"desc" gorm:"type:text"`
	// Dice When ResourceType is diceyml, store dice.yml context, optional
	Dice string `json:"dice" gorm:"type:text"` // dice.yml
	// Addon When ResourceType is addonyml,store addon.yml context,optional
	Addon string `json:"addon" gorm:"type:text"`
	// Changelog changelog,optional
	Changelog string `json:"changelog" gorm:"type:text"`
	// IsStable not temp if ture, otherwise temp
	IsStable bool `json:"isStable" gorm:"type:tinyint(1)"`
	// IsFormal formal
	IsFormal bool `json:"isFormal" gorm:"type:tinyint(1)"`
	// IsProjectRelease .
	IsProjectRelease bool `json:"IsProjectRelease" gorm:"type:tinyint(1)"`
	// Modes list of release deployment mode
	Modes string `json:"modes" gorm:"type:text"`
	// Labels map type, the maximum length is 1000, optional
	Labels string `json:"labels" gorm:"type:varchar(1000)"`
	// GitBranch
	GitBranch string `json:"gitBranch" gorm:"type:varchar(255)"`
	// Version store release version, only in the same company, same project and same application,the maximum length is 100,optional
	Version string `json:"version" gorm:"type:varchar(100)"`
	// OrgID Corporate identifier,optional
	OrgID int64 `json:"orgId" gorm:"index:idx_org_id"`
	// ProjectID Project identifier,optional
	ProjectID int64 `json:"projectId"`
	// ApplicationID Application identifier,optional
	ApplicationID int64 `json:"applicationId"`
	// ProjectName Project name,optional
	ProjectName string `json:"projectName" gorm:"type:varchar(80)"`
	// ApplicationName Application name,optional
	ApplicationName string `json:"applicationName" gorm:"type:varchar(80)"`
	// UserID User identifier,the maximum length is 50,optional
	UserID string `json:"userId" gorm:"type:varchar(50)"`
	// ClusterName Cluster Name,the maximum length is 80,optional
	ClusterName string `json:"clusterName" gorm:"type:varchar(80)"` // 所属集群
	// Resources Specify the release resource type and resource storage path, optional
	Resources string `json:"resources,omitempty" gorm:"type:text"`
	// Reference Number of deployments, when it is 0, can be clear
	Reference int64 `json:"reference"`
	// CrossCluster Indicates whether the current release can cross clusters, without cluster restrictions
	CrossCluster bool `json:"crossCluster"`
	// CreatedAt Release created time
	CreatedAt time.Time `json:"createdAt"`
	// UpdatedAt Release updated time
	UpdatedAt time.Time `json:"updatedAt"`
	// IsLatest 是否为分支最新
	IsLatest bool `json:"isLatest"`
}

func (Release) TableName

func (Release) TableName() string

Set table name

type ReleaseConfigDB

type ReleaseConfigDB struct {
	*gorm.DB
}

ReleaseConfig .

func (*ReleaseConfigDB) CreateRelease

func (client *ReleaseConfigDB) CreateRelease(release *Release) error

CreateRelease Create Release

func (*ReleaseConfigDB) DeleteRelease

func (client *ReleaseConfigDB) DeleteRelease(releaseID string) error

DeleteRelease Delete Release

func (*ReleaseConfigDB) GetAppIDsByProjectAndVersion

func (client *ReleaseConfigDB) GetAppIDsByProjectAndVersion(projectID int64, version string) ([]int64, error)

GetAppIDsByProjectAndVersion Get appIDList by projectID & version

func (*ReleaseConfigDB) GetLatestReleaseByAppAndVersion

func (client *ReleaseConfigDB) GetLatestReleaseByAppAndVersion(appID int64, version string) (*Release, error)

GetLatestReleaseByAppAndVersion Get the latest release under the app

func (*ReleaseConfigDB) GetRelease

func (client *ReleaseConfigDB) GetRelease(releaseID string) (*Release, error)

GetRelease Get Release

func (*ReleaseConfigDB) GetReleaseNamesByApp

func (client *ReleaseConfigDB) GetReleaseNamesByApp(orgID, appID int64) ([]string, error)

GetReleaseNamesByApp Get releaseName list by appID

func (*ReleaseConfigDB) GetReleases

func (client *ReleaseConfigDB) GetReleases(releaseIDs []string) ([]Release, error)

GetReleases list releases by release ids

func (*ReleaseConfigDB) GetReleasesByAppAndVersion

func (client *ReleaseConfigDB) GetReleasesByAppAndVersion(orgID, projectID, appID int64, version string) ([]Release, error)

GetReleasesByAppAndVersion Get Release list by appID & version

func (*ReleaseConfigDB) GetReleasesByBranch

func (client *ReleaseConfigDB) GetReleasesByBranch(projectID, appID int64, gitBranch string) ([]Release, error)

func (*ReleaseConfigDB) GetReleasesByParams

func (client *ReleaseConfigDB) GetReleasesByParams(
	orgID int64, req *pb.ReleaseListRequest) (int64, []Release, error)

GetReleasesByParams filter Releases by parameters

func (*ReleaseConfigDB) GetReleasesByProjectAndVersion

func (client *ReleaseConfigDB) GetReleasesByProjectAndVersion(orgID, projectID int64, version string) ([]Release, error)

func (*ReleaseConfigDB) GetUnReferedReleasesBefore

func (client *ReleaseConfigDB) GetUnReferedReleasesBefore(before time.Time) ([]Release, error)

GetUnReferedReleasesBefore Get the Release that has not been referenced before a given point in time

func (*ReleaseConfigDB) UpdateRelease

func (client *ReleaseConfigDB) UpdateRelease(release *Release) error

UpdateRelease Update Release

type ReleaseOpus

type ReleaseOpus struct {
	Model
	Common

	ReleaseID     string `gorm:"release_id"`
	OpusID        string `gorm:"opus_id"`
	OpusVersionID string `gorm:"opus_version_id"`
}

func (ReleaseOpus) TableName

func (ReleaseOpus) TableName() string

Jump to

Keyboard shortcuts

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