sql

package
v0.0.0-...-51001cb Latest Latest
Warning

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

Go to latest
Published: Apr 18, 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 AuthMode

type AuthMode string
const (
	AUTH_MODE_USERNAME_PASSWORD AuthMode = "USERNAME_PASSWORD"
	AUTH_MODE_SSH               AuthMode = "SSH"
	AUTH_MODE_ACCESS_TOKEN      AuthMode = "ACCESS_TOKEN"
	AUTH_MODE_ANONYMOUS         AuthMode = "ANONYMOUS"
)

type CiPipelineMaterial

type CiPipelineMaterial struct {
	Id            int        `sql:"id"`
	GitMaterialId int        `sql:"git_material_id"` //id stored in db GitMaterial( foreign key)
	Type          SourceType `sql:"type"`
	Value         string     `sql:"value"`
	Active        bool       `sql:"active,notnull"`
	LastSeenHash  string     `sql:"last_seen_hash,notnull"`
	CommitAuthor  string     `sql:"commit_author"`
	CommitDate    time.Time  `sql:"commit_date"`
	CommitMessage string     `sql:"commit_message"`

	CommitHistory string `sql:"commit_history"` //last five commit for caching purpose1
	Errored       bool   `sql:"errored,notnull"`
	ErrorMsg      string `sql:"error_msg,notnull"`
	// contains filtered or unexported fields
}

type CiPipelineMaterialRepository

type CiPipelineMaterialRepository interface {
	FindByGitMaterialId(gitMaterialId int) ([]*CiPipelineMaterial, error)
	Update(material []*CiPipelineMaterial) error
	FindByIds(ids []int) ([]*CiPipelineMaterial, error)
	FindById(id int) (*CiPipelineMaterial, error)
	Exists(id int) (bool, error)
	Save(material []*CiPipelineMaterial) ([]*CiPipelineMaterial, error)
}

type CiPipelineMaterialRepositoryImpl

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

func NewCiPipelineMaterialRepositoryImpl

func NewCiPipelineMaterialRepositoryImpl(dbConnection *pg.DB,
	logger *zap.SugaredLogger) *CiPipelineMaterialRepositoryImpl

func (CiPipelineMaterialRepositoryImpl) Exists

func (impl CiPipelineMaterialRepositoryImpl) Exists(id int) (bool, error)

func (CiPipelineMaterialRepositoryImpl) FindByGitMaterialId

func (impl CiPipelineMaterialRepositoryImpl) FindByGitMaterialId(gitMaterialId int) ([]*CiPipelineMaterial, error)

func (CiPipelineMaterialRepositoryImpl) FindById

func (CiPipelineMaterialRepositoryImpl) FindByIds

func (impl CiPipelineMaterialRepositoryImpl) FindByIds(ids []int) (materials []*CiPipelineMaterial, err error)

func (CiPipelineMaterialRepositoryImpl) Save

func (CiPipelineMaterialRepositoryImpl) Update

func (impl CiPipelineMaterialRepositoryImpl) Update(materials []*CiPipelineMaterial) error

type CiPipelineMaterialWebhookDataMapping

type CiPipelineMaterialWebhookDataMapping struct {
	Id                   int       `sql:"id,pk"`
	CiPipelineMaterialId int       `sql:"ci_pipeline_material_id"`
	WebhookDataId        int       `sql:"webhook_data_id"`
	ConditionMatched     bool      `sql:"condition_matched,notnull"`
	IsActive             bool      `sql:"is_active,notnull"`
	CreatedOn            time.Time `sql:"created_on"`
	UpdatedOn            time.Time `sql:"updated_on"`

	FilterResults []*CiPipelineMaterialWebhookDataMappingFilterResult `pg:"fk:webhook_data_mapping_id"`
	// contains filtered or unexported fields
}

type CiPipelineMaterialWebhookDataMappingFilterResult

type CiPipelineMaterialWebhookDataMappingFilterResult struct {
	Id                   int               `sql:"id,pk"`
	WebhookDataMappingId int               `sql:"webhook_data_mapping_id,notnull"`
	SelectorName         string            `sql:"selector_name,notnull"`
	SelectorCondition    string            `sql:"selector_condition"`
	SelectorValue        string            `sql:"selector_value"`
	ConditionMatched     bool              `sql:"condition_matched,notnull"`
	MatchedGroups        map[string]string `sql:"matched_groups"`
	IsActive             bool              `sql:"is_active,notnull"`
	CreatedOn            time.Time         `sql:"created_on,notnull"`
	// contains filtered or unexported fields
}

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:"git_sensor"`
	ApplicationName string `env:"APP" envDefault:"git-sensor"`
	LogQuery        bool   `env:"PG_LOG_QUERY" envDefault:"true"`
}

func GetConfig

func GetConfig() (*Config, error)

type GitHostWebhookEvent

type GitHostWebhookEvent struct {
	Id            int       `sql:"id,pk"`
	GitHostId     int       `sql:"git_host_id,notnull"`
	Name          string    `sql:"name,notnull"`
	EventTypesCsv string    `sql:"event_types_csv,notnull"`
	ActionType    string    `sql:"action_type,notnull"`
	IsActive      bool      `sql:"is_active,notnull"`
	CreatedOn     time.Time `sql:"created_on,notnull"`
	UpdatedOn     time.Time `sql:"updated_on"`

	Selectors []*GitHostWebhookEventSelectors `pg:"fk:event_id"`
	// contains filtered or unexported fields
}

type GitHostWebhookEventSelectors

type GitHostWebhookEventSelectors struct {
	Id                   int       `sql:"id,pk"`
	EventId              int       `sql:"event_id,notnull"`
	Name                 string    `sql:"name,notnull"`
	Selector             string    `sql:"selector,notnull"`
	ToShow               bool      `sql:"to_show,notnull"`
	ToShowInCiFilter     bool      `sql:"to_show_in_ci_filter,notnull"`
	ToUseInCiEnvVariable bool      `sql:"to_use_in_ci_env_variable"`
	FixValue             string    `sql:"fix_value"`
	PossibleValues       string    `sql:"possible_values"`
	IsActive             bool      `sql:"is_active,notnull"`
	CreatedOn            time.Time `sql:"created_on,notnull"`
	UpdatedOn            time.Time `sql:"updated_on"`
	// contains filtered or unexported fields
}

type GitMaterial

type GitMaterial struct {
	Id               int    `sql:"id,pk"`
	GitProviderId    int    `sql:"git_provider_id,notnull"`
	Url              string `sql:"url,omitempty"`
	FetchSubmodules  bool   `sql:"fetch_submodules,notnull"`
	Name             string `sql:"name, omitempty"`
	CheckoutLocation string `sql:"checkout_location"`
	CheckoutStatus   bool   `sql:"checkout_status,notnull"`
	CheckoutMsgAny   string `sql:"checkout_msg_any"`
	Deleted          bool   `sql:"deleted,notnull"`
	//------
	LastFetchTime       time.Time `json:"last_fetch_time"`
	FetchStatus         bool      `json:"fetch_status"`
	LastFetchErrorCount int       `json:"last_fetch_error_count"` //continues fetch error
	FetchErrorMessage   string    `json:"fetch_error_message"`
	FilterPattern       []string  `sql:"filter_pattern"`
	GitProvider         *GitProvider
	CiPipelineMaterials []*CiPipelineMaterial
	// contains filtered or unexported fields
}

TODO: add support for submodule

type GitProvider

type GitProvider struct {
	Id            int      `sql:"id,pk"`
	Name          string   `sql:"name,notnull"`
	Url           string   `sql:"url,notnull"`
	UserName      string   `sql:"user_name"`
	Password      string   `sql:"password"`
	SshPrivateKey string   `sql:"ssh_private_key"`
	AccessToken   string   `sql:"access_token"`
	AuthMode      AuthMode `sql:"auth_mode,notnull"`
	Active        bool     `sql:"active,notnull"`
	// contains filtered or unexported fields
}

type GitProviderRepository

type GitProviderRepository interface {
	GetById(id int) (*GitProvider, error)
	Save(provider *GitProvider) error
	Update(provider *GitProvider) error
	Exists(id int) (bool, error)
}

type GitProviderRepositoryImpl

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

func NewGitProviderRepositoryImpl

func NewGitProviderRepositoryImpl(dbConnection *pg.DB) *GitProviderRepositoryImpl

func (GitProviderRepositoryImpl) Exists

func (impl GitProviderRepositoryImpl) Exists(id int) (bool, error)

func (GitProviderRepositoryImpl) GetById

func (impl GitProviderRepositoryImpl) GetById(id int) (*GitProvider, error)

func (GitProviderRepositoryImpl) Save

func (impl GitProviderRepositoryImpl) Save(provider *GitProvider) error

func (GitProviderRepositoryImpl) Update

func (impl GitProviderRepositoryImpl) Update(provider *GitProvider) error

type MaterialRepository

type MaterialRepository interface {
	FindById(id int) (*GitMaterial, error)
	Update(material *GitMaterial) error
	Save(material *GitMaterial) error
	FindActive() ([]*GitMaterial, error)
	FindAll() ([]*GitMaterial, error)
	FindAllActiveByUrls(urls []string) ([]*GitMaterial, error)
}

type MaterialRepositoryImpl

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

func NewMaterialRepositoryImpl

func NewMaterialRepositoryImpl(dbConnection *pg.DB) *MaterialRepositoryImpl

func (MaterialRepositoryImpl) FindActive

func (repo MaterialRepositoryImpl) FindActive() ([]*GitMaterial, error)

func (MaterialRepositoryImpl) FindAll

func (repo MaterialRepositoryImpl) FindAll() ([]*GitMaterial, error)

func (MaterialRepositoryImpl) FindAllActiveByUrls

func (repo MaterialRepositoryImpl) FindAllActiveByUrls(urls []string) ([]*GitMaterial, error)

func (MaterialRepositoryImpl) FindById

func (repo MaterialRepositoryImpl) FindById(id int) (*GitMaterial, error)

func (MaterialRepositoryImpl) Save

func (repo MaterialRepositoryImpl) Save(material *GitMaterial) error

func (MaterialRepositoryImpl) Update

func (repo MaterialRepositoryImpl) Update(material *GitMaterial) error

type SourceType

type SourceType string
const (
	SOURCE_TYPE_BRANCH_FIXED SourceType = "SOURCE_TYPE_BRANCH_FIXED"
	SOURCE_TYPE_BRANCH_REGEX SourceType = "SOURCE_TYPE_BRANCH_REGEX"
	SOURCE_TYPE_TAG_ANY      SourceType = "SOURCE_TYPE_TAG_ANY"
	SOURCE_TYPE_WEBHOOK      SourceType = "WEBHOOK"
)

type WebhookEventDataMappingFilterResultRepository

type WebhookEventDataMappingFilterResultRepository interface {
	SaveAll(results []*CiPipelineMaterialWebhookDataMappingFilterResult) error
	InactivateForMappingId(webhookDataMappingId int) error
}

type WebhookEventDataMappingFilterResultRepositoryImpl

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

func NewWebhookEventDataMappingFilterResultRepositoryImpl

func NewWebhookEventDataMappingFilterResultRepositoryImpl(dbConnection *pg.DB) *WebhookEventDataMappingFilterResultRepositoryImpl

func (WebhookEventDataMappingFilterResultRepositoryImpl) InactivateForMappingId

func (impl WebhookEventDataMappingFilterResultRepositoryImpl) InactivateForMappingId(webhookDataMappingId int) error

func (WebhookEventDataMappingFilterResultRepositoryImpl) SaveAll

type WebhookEventDataMappingRepository

type WebhookEventDataMappingRepository interface {
	GetCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialId int, webhookParsedDataId int) (*CiPipelineMaterialWebhookDataMapping, error)
	SaveCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialWebhookDataMapping *CiPipelineMaterialWebhookDataMapping) error
	UpdateCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialWebhookDataMapping *CiPipelineMaterialWebhookDataMapping) error
	GetMatchedCiPipelineMaterialWebhookDataMappingForPipelineMaterial(ciPipelineMaterialId int) ([]*CiPipelineMaterialWebhookDataMapping, error)
	InactivateWebhookDataMappingForPipelineMaterials(ciPipelineMaterialIds []int) error
	GetWebhookPayloadDataForPipelineMaterialId(ciPipelineMaterialId int, limit int, offset int, eventTimeSortOrder string) ([]*CiPipelineMaterialWebhookDataMapping, error)
	GetWebhookPayloadFilterDataForPipelineMaterialId(ciPipelineMaterialId int, webhookParsedDataId int) (*CiPipelineMaterialWebhookDataMapping, error)
}

type WebhookEventDataMappingRepositoryImpl

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

func NewWebhookEventDataMappingRepositoryImpl

func NewWebhookEventDataMappingRepositoryImpl(dbConnection *pg.DB) *WebhookEventDataMappingRepositoryImpl

func (WebhookEventDataMappingRepositoryImpl) GetCiPipelineMaterialWebhookDataMapping

func (impl WebhookEventDataMappingRepositoryImpl) GetCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialId int, webhookParsedDataId int) (*CiPipelineMaterialWebhookDataMapping, error)

func (WebhookEventDataMappingRepositoryImpl) GetMatchedCiPipelineMaterialWebhookDataMappingForPipelineMaterial

func (impl WebhookEventDataMappingRepositoryImpl) GetMatchedCiPipelineMaterialWebhookDataMappingForPipelineMaterial(ciPipelineMaterialId int) ([]*CiPipelineMaterialWebhookDataMapping, error)

func (WebhookEventDataMappingRepositoryImpl) GetWebhookPayloadDataForPipelineMaterialId

func (impl WebhookEventDataMappingRepositoryImpl) GetWebhookPayloadDataForPipelineMaterialId(ciPipelineMaterialId int, limit int, offset int, eventTimeSortOrder string) ([]*CiPipelineMaterialWebhookDataMapping, error)

func (WebhookEventDataMappingRepositoryImpl) GetWebhookPayloadFilterDataForPipelineMaterialId

func (impl WebhookEventDataMappingRepositoryImpl) GetWebhookPayloadFilterDataForPipelineMaterialId(ciPipelineMaterialId int, webhookParsedDataId int) (*CiPipelineMaterialWebhookDataMapping, error)

func (WebhookEventDataMappingRepositoryImpl) InactivateWebhookDataMappingForPipelineMaterials

func (impl WebhookEventDataMappingRepositoryImpl) InactivateWebhookDataMappingForPipelineMaterials(ciPipelineMaterialIds []int) error

func (WebhookEventDataMappingRepositoryImpl) SaveCiPipelineMaterialWebhookDataMapping

func (impl WebhookEventDataMappingRepositoryImpl) SaveCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialWebhookDataMapping *CiPipelineMaterialWebhookDataMapping) error

func (WebhookEventDataMappingRepositoryImpl) UpdateCiPipelineMaterialWebhookDataMapping

func (impl WebhookEventDataMappingRepositoryImpl) UpdateCiPipelineMaterialWebhookDataMapping(ciPipelineMaterialWebhookDataMapping *CiPipelineMaterialWebhookDataMapping) error

type WebhookEventParsedData

type WebhookEventParsedData struct {
	Id                int               `sql:"id,pk"`
	EventId           int               `sql:"event_id,notnull"`
	PayloadDataId     int               `sql:"payload_data_id"`
	UniqueId          string            `sql:"unique_id"`
	EventActionType   string            `sql:"event_action_type,notnull"`
	Data              map[string]string `sql:"data,notnull"`
	CiEnvVariableData map[string]string `sql:"ci_env_variable_data"`
	CreatedOn         time.Time         `sql:"created_on,notnull"`
	UpdatedOn         time.Time         `sql:"updated_on"`
	// contains filtered or unexported fields
}

type WebhookEventParsedDataRepository

type WebhookEventParsedDataRepository interface {
	GetWebhookParsedEventDataByEventIdAndUniqueId(eventId int, uniqueId string) (*WebhookEventParsedData, error)
	SaveWebhookParsedEventData(webhookEventParsedData *WebhookEventParsedData) error
	UpdateWebhookParsedEventData(webhookEventParsedData *WebhookEventParsedData) error
	GetWebhookEventParsedDataByIds(ids []int, limit int) ([]*WebhookEventParsedData, error)
	GetWebhookEventParsedDataById(id int) (*WebhookEventParsedData, error)
}

type WebhookEventParsedDataRepositoryImpl

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

func NewWebhookEventParsedDataRepositoryImpl

func NewWebhookEventParsedDataRepositoryImpl(dbConnection *pg.DB) *WebhookEventParsedDataRepositoryImpl

func (WebhookEventParsedDataRepositoryImpl) GetWebhookEventParsedDataById

func (impl WebhookEventParsedDataRepositoryImpl) GetWebhookEventParsedDataById(id int) (*WebhookEventParsedData, error)

func (WebhookEventParsedDataRepositoryImpl) GetWebhookEventParsedDataByIds

func (impl WebhookEventParsedDataRepositoryImpl) GetWebhookEventParsedDataByIds(ids []int, limit int) ([]*WebhookEventParsedData, error)

func (WebhookEventParsedDataRepositoryImpl) GetWebhookParsedEventDataByEventIdAndUniqueId

func (impl WebhookEventParsedDataRepositoryImpl) GetWebhookParsedEventDataByEventIdAndUniqueId(eventId int, uniqueId string) (*WebhookEventParsedData, error)

func (WebhookEventParsedDataRepositoryImpl) SaveWebhookParsedEventData

func (impl WebhookEventParsedDataRepositoryImpl) SaveWebhookParsedEventData(webhookEventParsedData *WebhookEventParsedData) error

func (WebhookEventParsedDataRepositoryImpl) UpdateWebhookParsedEventData

func (impl WebhookEventParsedDataRepositoryImpl) UpdateWebhookParsedEventData(webhookEventParsedData *WebhookEventParsedData) error

type WebhookEventRepository

type WebhookEventRepository interface {
	GetAllGitHostWebhookEventByGitHostId(gitHostId int) ([]*GitHostWebhookEvent, error)
	GetWebhookEventConfigByEventId(eventId int) (*GitHostWebhookEvent, error)
}

type WebhookEventRepositoryImpl

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

func NewWebhookEventRepositoryImpl

func NewWebhookEventRepositoryImpl(dbConnection *pg.DB) *WebhookEventRepositoryImpl

func (WebhookEventRepositoryImpl) GetAllGitHostWebhookEventByGitHostId

func (impl WebhookEventRepositoryImpl) GetAllGitHostWebhookEventByGitHostId(gitHostId int) ([]*GitHostWebhookEvent, error)

func (WebhookEventRepositoryImpl) GetWebhookEventConfigByEventId

func (impl WebhookEventRepositoryImpl) GetWebhookEventConfigByEventId(eventId int) (*GitHostWebhookEvent, error)

Jump to

Keyboard shortcuts

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