bugzillarest

package
v0.0.0-...-b175f30 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Category type
	Category = "bug"
	// BugzillaRest - DS name
	BugzillaRest string = "bugzillarest"
)

Variables

View Source
var (

	// BugzillaRestRawMapping - bugzilla raw index mapping
	BugzillaRestRawMapping = []byte(`{
  "mappings": 
{"dynamic":true,
"properties":{
"metadata__updated_on":{"type":"date"},
"metadata__timestamp":{"type":"date"},
"updated_on":{"type":"date"},
"timestamp":{"type":"date"},
"short_description":{"type":"text","index":true},
"backend_version":{"type":"keyword"},
"backend_name":{"type":"keyword"},
"status":{"type":"keyword"},
"priority":{"type":"keyword"},
"severity":{"type":"keyword"},
"uuid":{"type": "keyword"},
"origin":{"type":"keyword"},
"tag":{"type":"keyword"}
}}
}`)

	// BugzillaRestEnrichMapping - bugzilla rest enriched index mapping
	BugzillaRestEnrichMapping = []byte(`{"mappings":{"dynamic_templates":[{"notanalyzed":{"match":"*","match_mapping_type":"string","mapping":{"type":"keyword"}}},{"int_to_float":{"match":"*","match_mapping_type":"long","mapping":{"type":"float"}}},{"formatdate":{"match":"*","match_mapping_type":"date","mapping":{"format":"strict_date_optional_time||epoch_millis","type":"date"}}}]}}`)
)

Functions

This section is empty.

Types

type AffiliationClient

type AffiliationClient interface {
	GetIdentityByUser(key string, value string) (*libAffiliations.AffIdentity, error)
	AddIdentity(identity *libAffiliations.Identity) bool
}

AffiliationClient manages user identity

type Attachment

type Attachment struct {
	Data           string
	Size           int
	CreationTime   time.Time
	LastChangeTime time.Time
	ID             int
	BugID          int
	FileName       string
	Summary        string
	ContentType    string
	IsPrivate      bool
	IsObsolete     bool
	IsPatch        bool
	Creator        string
	Flags          []string
}

Attachment describe bug attachment

type AttachmentRes

type AttachmentRes struct {
	Bugs map[string][]Attachment `json:"bugs"`
}

AttachmentRes response from bug attachment api

type Auth0ClientProvider

type Auth0ClientProvider interface {
	GetToken() (string, error)
}

Auth0ClientProvider ...

type AuthClientProvider

type AuthClientProvider interface {
	GetToken(env string) (string, error)
}

AuthClientProvider interacts with auth0 server

type BugData

type BugData struct {
	History             *[]History     `json:"history"`
	Resolution          string         `json:"resolution"`
	Priority            string         `json:"priority"`
	Keywords            []string       `json:"keywords"`
	DependsOn           []int          `json:"depends_on"`
	Alias               []string       `json:"alias"`
	IsCcAccessible      bool           `json:"is_cc_accessible"`
	Duplicates          []int          `json:"duplicates"`
	SeeAlso             []string       `json:"see_also"`
	LastChangeTime      time.Time      `json:"last_change_time"`
	CreatorDetail       *PersonDetail  `json:"creator_detail"`
	Blocks              []int          `json:"blocks"`
	TargetMilestone     string         `json:"target_milestone"`
	Deadline            *string        `json:"deadline"`
	IsOpen              bool           `json:"is_open"`
	RemainingTime       int            `json:"remaining_time"`
	Flags               []string       `json:"flags"`
	Groups              []string       `json:"groups"`
	Component           string         `json:"component"`
	Platform            string         `json:"platform"`
	Comments            Comments       `json:"comments"`
	EstimatedTime       int            `json:"estimated_time"`
	OpSys               string         `json:"op_sys"`
	Severity            string         `json:"severity"`
	URL                 string         `json:"url"`
	Cc                  []string       `json:"cc"`
	IsConfirmed         bool           `json:"is_confirmed"`
	IsCreatorAccessible bool           `json:"is_creator_accessible"`
	ActualTime          int            `json:"actual_time"`
	AssignedTo          string         `json:"assigned_to"`
	DupeOf              *int           `json:"dupe_of"`
	Attachments         []Attachment   `json:"attachments"`
	Tags                []string       `json:"tags"`
	CreationTime        time.Time      `json:"creation_time"`
	Whiteboard          string         `json:"whiteboard"`
	CcDetail            []PersonDetail `json:"cc_detail"`
	Status              string
	Summary             string
	Classification      string
	QaContact           string
	Product             string        `json:"product"`
	ID                  int           `json:"id"`
	Creator             string        `json:"creator"`
	Version             string        `json:"version"`
	AssignedToDetail    *PersonDetail `json:"assigned_to_detail"`
}

BugData single bug data

type BugRestEnrich

type BugRestEnrich struct {
	UUID         string    `json:"uuid"`
	Project      string    `json:"project"`
	Changes      int       `json:"changes"`
	Product      string    `json:"product"`
	Component    string    `json:"component"`
	Status       string    `json:"status"`
	TimeOpenDays float64   `json:"timeopen_days"`
	ChangedDate  time.Time `json:"changed_date"`
	Tag          string    `json:"tag"`
	URL          string    `json:"url"`
	CreationDate time.Time `json:"creation_date"`
	DeltaTs      time.Time `json:"delta_ts"`
	Whiteboard   *string   `json:"whiteboard"`
	AssignedTo   string    `json:"assigned_to"`

	CreatorDetailID           string   `json:"creator_detail_id"`
	CreatorDetailUUID         string   `json:"creator_detail_uuid"`
	CreatorDetailName         string   `json:"creator_detail_name"`
	CreatorDetailUserName     string   `json:"creator_detail_user_name"`
	CreatorDetailDomain       string   `json:"creator_detail_domain"`
	CreatorDetailOrgName      string   `json:"creator_detail_org_name"`
	CreatorDetailMultiOrgName []string `json:"creator_detail_multi_org_names"`
	CreatorDetailBot          bool     `json:"creator_detail_bot"`

	AuthorID            string   `json:"author_id"`
	AuthorUUID          string   `json:"author_uuid"`
	AuthorName          string   `json:"author_name"`
	AuthorUserName      string   `json:"author_user_name"`
	AuthorDomain        string   `json:"author_domain"`
	AuthorOrgName       string   `json:"author_org_name"`
	AuthorMultiOrgNames []string `json:"author_multi_org_names"`
	AuthorBot           bool     `json:"author_bot"`

	AssignedToUUID    string `json:"assigned_to_uuid"`
	AssignedToOrgName string `json:"assigned_to_org_name"`

	AssignedToDetailID           string   `json:"assigned_to_detail_id"`
	AssignedToDetailUUID         string   `json:"assigned_to_detail_uuid"`
	AssignedToDetailName         string   `json:"assigned_to_detail_name"`
	AssignedToDetailUserName     string   `json:"assigned_to_detail_user_name"`
	AssignedToDetailDomain       string   `json:"assigned_to_detail_domain"`
	AssignedToDetailOrgName      string   `json:"assigned_to_detail_org_name"`
	AssignedToDetailMultiOrgName []string `json:"assigned_to_detail_multi_org_names"`
	AssignedToDetailBot          bool     `json:"assigned_to_detail_bot"`

	MainDescription         string    `json:"main_description"`
	MainDescriptionAnalyzed string    `json:"main_description_analyzed"`
	Summary                 string    `json:"summary"`
	SummaryAnalyzed         string    `json:"summary_analyzed"`
	Comments                int       `json:"comments"`
	RepositoryLabels        *[]string `json:"repository_labels"`

	MetadataUpdatedOn      time.Time `json:"metadata__updated_on"`
	MetadataTimestamp      time.Time `json:"metadata__timestamp"`
	MetadataEnrichedOn     time.Time `json:"metadata__enriched_on"`
	MetadataFilterRaw      *string   `json:"metadata__filter_raw"`
	MetadataBackendName    string    `json:"metadata__backend_name"`
	MetadataBackendVersion string    `json:"metadata__backend_version"`

	ISBugzillarestBugrest int     `json:"is_bugzillarest_bugrest"`
	CreationTs            string  `json:"creation_ts"`
	NumberOfComments      int     `json:"number_of_comments"`
	Origin                string  `json:"origin"`
	Offset                *string `json:"offset"`
	ProjectTs             float64 `json:"project_ts"`
	Creator               string  `json:"creator"`
	ISOpen                bool    `json:"is_open"`
	ID                    int     `json:"id"`
	TimeToLastUpdateDays  float64 `json:"time_to_last_update_days"`
	TimeToClose           float64 `json:"time_to_close"`
}

BugRestEnrich ...

type Change

type Change struct {
	Added        string
	Removed      string
	FieldName    string
	AttachmentID *string
}

Change history element changes data

type Comment

type Comment struct {
	ID           int
	Creator      string
	Time         time.Time
	Count        int
	IsPrivate    bool
	CreationTime time.Time
	AttachmentID *int
	Tags         []string
}

Comment describe comment details

type Comments

type Comments []Comment

Comments slice of bug comments

type ESClientProvider

type ESClientProvider interface {
	Add(index string, documentID string, body []byte) ([]byte, error)
	CreateIndex(index string, body []byte) ([]byte, error)
	Bulk(body []byte) ([]byte, error)
	Get(index string, query map[string]interface{}, result interface{}) (err error)
	GetStat(index string, field string, aggType string, mustConditions []map[string]interface{}, mustNotConditions []map[string]interface{}) (result time.Time, err error)
	BulkInsert(data []elastic.BulkData) ([]byte, error)
	DelayOfCreateIndex(ex func(str string, b []byte) ([]byte, error), uin uint, du time.Duration, index string, data []byte) error
}

ESClientProvider used in connecting to ES server

type Enricher

type Enricher struct {
	DSName         string
	BackendVersion string
	Project        string
	// contains filtered or unexported fields
}

Enricher enrich Bugzilla raw

func NewEnricher

func NewEnricher(params *EnricherParams, affiliationsClient AffiliationClient, auth0ClientProvider Auth0ClientProvider, httpClientProvider HTTPClientProvider, affBaseURL string, projectSlug string) *Enricher

NewEnricher initiate a new enricher instance

func (*Enricher) EnrichItem

func (e *Enricher) EnrichItem(rawItem Raw, now time.Time) (*BugRestEnrich, error)

EnrichItem enrich Bugzilla raw item

type EnricherParams

type EnricherParams struct {
	BackendVersion string
	Project        string
}

EnricherParams required parameters for bugzilla enricher

type FetchedBugs

type FetchedBugs struct {
	Bugs []BugData
}

FetchedBugs bugs fetched from bugzilla rest api

type Fetcher

type Fetcher struct {
	HTTPClientProvider    HTTPClientProvider
	ElasticSearchProvider ESClientProvider
	BackendVersion        string
	Endpoint              string
	BackendName           string
	// contains filtered or unexported fields
}

Fetcher contains fetch functionalities

func NewFetcher

func NewFetcher(params *FetcherParams, httpClientProvider HTTPClientProvider, esClientProvider ESClientProvider) *Fetcher

NewFetcher initiates a new bugZillaRest fetcher

func (*Fetcher) FetchAll

func (f *Fetcher) FetchAll(origin string, date string, limit string, offset string, now time.Time) ([]Raw, *time.Time, error)

FetchAll fetches all bugs

func (*Fetcher) FetchItem

func (f *Fetcher) FetchItem(origin string, bugID int, fetchedBug BugData, now time.Time) (*Raw, error)

FetchItem fetches bug item

func (*Fetcher) Query

func (f *Fetcher) Query(index string, query map[string]interface{}) (*RawHits, error)

Query query saved raw data from ES

type FetcherParams

type FetcherParams struct {
	Endpoint       string
	BackendVersion string
}

FetcherParams required parameters for bugzilla fetcher

type HTTPClientProvider

type HTTPClientProvider interface {
	Request(url string, method string, header map[string]string, body []byte, params map[string]string) (statusCode int, resBody []byte, err error)
}

HTTPClientProvider used in connecting to remote http server

type History

type History struct {
	Changes []Change
	Who     string
	When    time.Time
}

History single bug history data

type HistoryBug

type HistoryBug struct {
	ID      int
	History []History
	Alias   []string
}

HistoryBug bug history

type HistoryRes

type HistoryRes struct {
	Bugs []HistoryBug
}

HistoryRes response from bug history api

type HitSource

type HitSource struct {
	ID        string    `json:"id"`
	ChangedAt time.Time `json:"changed_at"`
}

HitSource is the document _source data

type Hits

type Hits struct {
	Hits []NestedHits `json:"hits"`
}

Hits result

type Manager

type Manager struct {
	Endpoint               string
	FetcherBackendVersion  string
	EnricherBackendVersion string
	Fetch                  bool
	Enrich                 bool
	ESUrl                  string
	ESUsername             string
	ESPassword             string
	ESIndex                string
	FromDate               *time.Time
	HTTPTimeout            time.Duration
	Project                string
	FetchSize              int
	EnrichSize             int
	ProjectSlug            string
	AffBaseURL             string
	ESCacheURL             string
	ESCacheUsername        string
	ESCachePassword        string
	AuthGrantType          string
	AuthClientID           string
	AuthClientSecret       string
	AuthAudience           string
	Auth0URL               string
	Environment            string
	Slug                   string
	WebHookURL             string

	EsClientProvider    ESClientProvider
	Fetcher             *Fetcher
	Enricher            *Enricher
	Auth0ClientProvider Auth0ClientProvider
	HTTPClientProvider  HTTPClientProvider

	Retries uint
	Delay   time.Duration
	GapURL  string
}

Manager describes bugzilla manager

func NewManager

func NewManager(param *MgrParams) (*Manager, error)

NewManager initiates bugzilla manager instance

func (*Manager) Sync

func (m *Manager) Sync() error

Sync starts fetch and enrich processes

type MgrParams

type MgrParams struct {
	EndPoint               string
	FetcherBackendVersion  string
	EnricherBackendVersion string
	Fetch                  bool
	Enrich                 bool
	ESUrl                  string
	EsUser                 string
	EsPassword             string
	EsIndex                string
	FromDate               *time.Time
	HTTPTimeout            time.Duration
	Project                string
	FetchSize              int
	EnrichSize             int
	Retries                uint
	Delay                  time.Duration
	GapURL                 string
	ProjectSlug            string
	AffBaseURL             string
	ESCacheURL             string
	ESCacheUsername        string
	ESCachePassword        string
	AuthGrantType          string
	AuthClientID           string
	AuthClientSecret       string
	AuthAudience           string
	Auth0URL               string
	Environment            string
	Slug                   string
	WebHookURL             string

	Fetcher             *Fetcher
	Enricher            *Enricher
	ESClientProvider    ESClientProvider
	Auth0ClientProvider Auth0ClientProvider
	HTTPClientProvider  HTTPClientProvider
}

MgrParams required for creating a new instance of Bugzillarest manager

type NHits

type NHits struct {
	Hits []NestedRawHits `json:"hits"`
}

NHits result

type NestedHits

type NestedHits struct {
	ID     string    `json:"_id"`
	Source HitSource `json:"_source"`
}

NestedHits is the actual hit data

type NestedRawHits

type NestedRawHits struct {
	ID     string `json:"_id"`
	Source Raw    `json:"_source"`
}

NestedRawHits is the actual hit data

type PersonDetail

type PersonDetail struct {
	Name     string `json:"name"`
	RealName string `json:"real_name"`
	ID       int    `json:"id"`
}

PersonDetail describe user data

type Raw

type Raw struct {
	Data                     BugData   `json:"data"`
	UUID                     string    `json:"uuid"`
	MetadataUpdatedOn        time.Time `json:"metadata__updated_on"`
	ClassifiedFieldsFiltered *string   `json:"classified_fields_filtered"`
	UpdatedOn                float64   `json:"updated_on"`
	BackendName              string    `json:"backend_name"`
	Category                 string    `json:"category"`
	Origin                   string    `json:"origin"`
	BackendVersion           string    `json:"backend_version"`
	Tag                      string    `json:"tag"`
	Timestamp                float64   `json:"timestamp"`
	MetadataTimestamp        time.Time `json:"metadata__timestamp"`
	ActualTime               int       `json:"actual_time"`
	EstimatedTime            int       `json:"estimated_time"`
	RemainingTime            int       `json:"remaining_time"`
}

Raw bugzilla rest raw data

type RawHits

type RawHits struct {
	Hits NHits `json:"hits"`
}

RawHits hits returned from elastic

type TopHits

type TopHits struct {
	Hits Hits `json:"hits"`
}

TopHits result

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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