Help us shape the future of Go! Take the 2026 Go Developer Survey

sql

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDbConnection

func NewDbConnection(cfg *Config, logger *zap.SugaredLogger) (*pg.DB, error)

Types

type AppRelease

type AppRelease struct {
	Id                    int           `pg:"id,pk"`
	AppId                 int           `pg:"app_id,notnull,use_zero"`                   //orchestrator appId
	EnvironmentId         int           `pg:"environment_id,notnull,use_zero"`           //orchestrator env id
	CiArtifactId          int           `pg:"ci_artifact_id,notnull,use_zero"`           //orchestrator ciAretefactId  used for identifying rollback (appId,environmentId, ciArtifactId)
	ReleaseId             int           `pg:"release_id,notnull,use_zero"`               // orchestrator release counter
	PipelineOverrideId    int           `pg:"pipeline_override_id,notnull,use_zero"`     //pipeline override id orchestrator
	ChangeSizeLineAdded   int           `pg:"change_size_line_added,notnull,use_zero"`   //total lines added in this release
	ChangeSizeLineDeleted int           `pg:"change_size_line_deleted,notnull,use_zero"` //total lines deleted during this release
	TriggerTime           time.Time     `pg:"trigger_time,notnull"`                      //deployment time
	ReleaseType           ReleaseType   `pg:"release_type,notnull,use_zero"`
	ReleaseStatus         ReleaseStatus `pg:"release_status,notnull,use_zero"`
	ProcessStage          ProcessStage  `pg:"process_status,notnull,use_zero"`
	CreatedTime           time.Time     `pg:"created_time,notnull"`
	UpdatedTime           time.Time     `pg:"updated_time,notnull"`
	LeadTime              *LeadTime
	// contains filtered or unexported fields
}

type AppReleaseRepository

type AppReleaseRepository interface {
	Save(appRelease *AppRelease) (*AppRelease, error)
	Update(appRelease *AppRelease) (*AppRelease, error)
	CheckDuplicateRelease(appId, environmentId, ciArtifactId int) (bool, error)
	GetPreviousReleaseWithinTime(appId, environmentId int, within time.Time, currentAppReleaseId int) (*AppRelease, error)
	GetPreviousRelease(appId, environmentId int, appReleaseId int) (*AppRelease, error)
	GetReleaseBetween(appId, environmentId int, from time.Time, to time.Time) ([]AppRelease, error)
	CleanAppDataForEnvironment(appId, environmentId int) error
}

type AppReleaseRepositoryImpl

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

func NewAppReleaseRepositoryImpl

func NewAppReleaseRepositoryImpl(dbConnection *pg.DB,
	logger *zap.SugaredLogger,
	leadTimeRepository LeadTimeRepository,
	pipelineMaterialRepository PipelineMaterialRepository) *AppReleaseRepositoryImpl

func (*AppReleaseRepositoryImpl) CheckDuplicateRelease

func (impl *AppReleaseRepositoryImpl) CheckDuplicateRelease(appId, environmentId, ciArtifactId int) (bool, error)

func (*AppReleaseRepositoryImpl) CleanAppDataForEnvironment

func (impl *AppReleaseRepositoryImpl) CleanAppDataForEnvironment(appId, environmentId int) error

func (*AppReleaseRepositoryImpl) GetPreviousRelease

func (impl *AppReleaseRepositoryImpl) GetPreviousRelease(appId, environmentId int,
	appReleaseId int) (*AppRelease, error)

func (*AppReleaseRepositoryImpl) GetPreviousReleaseWithinTime

func (impl *AppReleaseRepositoryImpl) GetPreviousReleaseWithinTime(appId, environmentId int,
	within time.Time,
	currentAppReleaseId int) (*AppRelease, error)

func (*AppReleaseRepositoryImpl) GetReleaseBetween

func (impl *AppReleaseRepositoryImpl) GetReleaseBetween(appId, environmentId int,
	from time.Time,
	to time.Time,
) ([]AppRelease, error)

func (*AppReleaseRepositoryImpl) Save

func (impl *AppReleaseRepositoryImpl) Save(appRelease *AppRelease) (*AppRelease, error)

func (*AppReleaseRepositoryImpl) Update

func (impl *AppReleaseRepositoryImpl) Update(appRelease *AppRelease) (*AppRelease, error)

type Config

type Config struct {
	Addr            string `env:"PG_ADDR" envDefault:"127.0.0.1"`
	Port            string `env:"PG_PORT" envDefault:"5432"`
	User            string `env:"PG_USER" envDefault:""`
	Password        string `env:"PG_PASSWORD" envDefault:"" secretData:"-"`
	Database        string `env:"PG_DATABASE" envDefault:"lens"`
	ApplicationName string `env:"APP" envDefault:"lens"`
	LogQuery        bool   `env:"PG_LOG_QUERY" envDefault:"true"`
}

func GetConfig

func GetConfig() (*Config, error)

type LeadTime

type LeadTime struct {
	Id                 int           `pg:"id"`
	AppReleaseId       int           `pg:"app_release_id"`
	PipelineMaterialId int           `pg:"pipeline_material_id"`
	CommitHash         string        `pg:"commit_hash"`
	CommitTime         time.Time     `pg:"commit_time"`
	LeadTime           time.Duration `pg:"lead_time"`
	AppRelease         *AppRelease
	// contains filtered or unexported fields
}

type LeadTimeRepository

type LeadTimeRepository interface {
	Save(leadTime *LeadTime) (*LeadTime, error)
	FindByIds(ids []int) ([]LeadTime, error)
	CleanAppDataForEnvironment(appId, environmentId int, tx *pg.Tx) error
}

type LeadTimeRepositoryImpl

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

func NewLeadTimeRepositoryImpl

func NewLeadTimeRepositoryImpl(dbConnection *pg.DB,
	logger *zap.SugaredLogger) *LeadTimeRepositoryImpl

func (*LeadTimeRepositoryImpl) CleanAppDataForEnvironment

func (impl *LeadTimeRepositoryImpl) CleanAppDataForEnvironment(appId, environmentId int, tx *pg.Tx) error

func (*LeadTimeRepositoryImpl) FindByIds

func (impl *LeadTimeRepositoryImpl) FindByIds(ids []int) ([]LeadTime, error)

func (*LeadTimeRepositoryImpl) Save

func (impl *LeadTimeRepositoryImpl) Save(leadTime *LeadTime) (*LeadTime, error)

type PipelineMaterial

type PipelineMaterial struct {
	PipelineMaterialId int    `pg:"pipeline_material_id"`
	CommitHash         string `pg:"commit_hash"`
	AppReleaseId       int    `pg:"app_release_id"`
	AppRelease         *AppRelease
	// contains filtered or unexported fields
}

type PipelineMaterialRepository

type PipelineMaterialRepository interface {
	Save(pipelineMaterial ...*PipelineMaterial) error
	FindByAppReleaseId(appReleaseId int) ([]*PipelineMaterial, error)
	FindByAppReleaseIds(appReleaseIds []int) ([]*PipelineMaterial, error)
	CleanAppDataForEnvironment(appId, environmentId int, tx *pg.Tx) error
}

type PipelineMaterialRepositoryImpl

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

func NewPipelineMaterialRepositoryImpl

func NewPipelineMaterialRepositoryImpl(dbConnection *pg.DB,
	logger *zap.SugaredLogger) *PipelineMaterialRepositoryImpl

func (*PipelineMaterialRepositoryImpl) CleanAppDataForEnvironment

func (impl *PipelineMaterialRepositoryImpl) CleanAppDataForEnvironment(appId, environmentId int, tx *pg.Tx) error

func (*PipelineMaterialRepositoryImpl) FindByAppReleaseId

func (impl *PipelineMaterialRepositoryImpl) FindByAppReleaseId(appReleaseId int) ([]*PipelineMaterial, error)

func (*PipelineMaterialRepositoryImpl) FindByAppReleaseIds

func (impl *PipelineMaterialRepositoryImpl) FindByAppReleaseIds(appReleaseIds []int) ([]*PipelineMaterial, error)

func (*PipelineMaterialRepositoryImpl) Save

func (impl *PipelineMaterialRepositoryImpl) Save(pipelineMaterial ...*PipelineMaterial) error

type ProcessStage

type ProcessStage int

------

const (
	Init ProcessStage = iota
	ReleaseTypeDetermined
	LeadTimeFetch
)

func (ProcessStage) String

func (ProcessStage ProcessStage) String() string

type ReleaseStatus

type ReleaseStatus int

--------------

const (
	Success ReleaseStatus = iota
	Failure
)

func (ReleaseStatus) String

func (releaseStatus ReleaseStatus) String() string

type ReleaseType

type ReleaseType int

----------------

const (
	Unknown ReleaseType = iota
	RollForward
	RollBack
	Patch
)

func (ReleaseType) String

func (releaseType ReleaseType) String() string

Jump to

Keyboard shortcuts

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