bugzilla

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdentifierForPull

func IdentifierForPull(org, repo string, num int) string

func IsAccessDenied

func IsAccessDenied(err error) bool

func IsIdentifierNotForPullErr

func IsIdentifierNotForPullErr(err error) bool

func IsInvalidBugID

func IsInvalidBugID(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func PrettyStatus

func PrettyStatus(status, resolution string) string

PrettyStatus returns:

  • "status (resolution)" if both status and resolution are not empty
  • "status" if only resolution is empty
  • "any status with resolution RESOLUTION" if only status is empty
  • "" if both status and resolution are empty

This is useful in user-facing messages that communicate bug state information

func PullFromIdentifier

func PullFromIdentifier(identifier string) (org, repo string, num int, err error)

Types

type AddExternalBugParameters

type AddExternalBugParameters struct {
	// BugIDs are the IDs of Bugzilla bugs to update
	BugIDs []int `json:"bug_ids"`
	// ExternalBugs are the external bugs to add
	ExternalBugs []ExternalBugIdentifier `json:"external_bugs"`
}

AddExternalBugParameters are the parameters required to add an external tracker bug to a Bugzilla bug

type Bug

type Bug struct {
	// ActualTime is the total number of hours that this bug has taken so far. If you are not in the time-tracking group, this field will not be included in the return value.
	ActualTime int `json:"actual_time,omitempty"`
	// Alias is the unique aliases of this bug. An empty array will be returned if this bug has no aliases.
	Alias []string `json:"alias,omitempty"`
	// AssignedTo is the login name of the user to whom the bug is assigned.
	AssignedTo string `json:"assigned_to,omitempty"`
	// AssignedToDetail is an object containing detailed user information for the assigned_to. To see the keys included in the user detail object, see below.
	AssignedToDetail *User `json:"assigned_to_detail,omitempty"`
	// Blocks is the IDs of bugs that are "blocked" by this bug.
	Blocks []int `json:"blocks,omitempty"`
	// CC is the login names of users on the CC list of this bug.
	CC []string `json:"cc,omitempty"`
	// CCDetail is array of objects containing detailed user information for each of the cc list members. To see the keys included in the user detail object, see below.
	CCDetail []User `json:"cc_detail,omitempty"`
	// Classification is the name of the current classification the bug is in.
	Classification string `json:"classification,omitempty"`
	// Component is an array of names of the current components of this bug.
	Component []string `json:"component,omitempty"`
	// CreationTime is when the bug was created.
	CreationTime string `json:"creation_time,omitempty"`
	// Creator is the login name of the person who filed this bug (the reporter).
	Creator string `json:"creator,omitempty"`
	// CreatorDetail is an object containing detailed user information for the creator. To see the keys included in the user detail object, see below.
	CreatorDetail *User `json:"creator_detail,omitempty"`
	// Deadline is the day that this bug is due to be completed, in the format YYYY-MM-DD.
	Deadline string `json:"deadline,omitempty"`
	// DependsOn is the IDs of bugs that this bug "depends on".
	DependsOn []int `json:"depends_on,omitempty"`
	// DupeOf is the bug ID of the bug that this bug is a duplicate of. If this bug isn't a duplicate of any bug, this will be null.
	DupeOf int `json:"dupe_of,omitempty"`
	// EstimatedTime is the number of hours that it was estimated that this bug would take. If you are not in the time-tracking group, this field will not be included in the return value.
	EstimatedTime int `json:"estimated_time,omitempty"`
	// Flags is an array of objects containing the information about flags currently set for the bug. Each flag objects contains the following items
	Flags []Flag `json:"flags,omitempty"`
	// Groups is the names of all the groups that this bug is in.
	Groups []string `json:"groups,omitempty"`
	// ID is the unique numeric ID of this bug.
	ID int `json:"id,omitempty"`
	// IsCCAccessible is if true, this bug can be accessed by members of the CC list, even if they are not in the groups the bug is restricted to.
	IsCCAccessible bool `json:"is_cc_accessible,omitempty"`
	// IsConfirmed is true if the bug has been confirmed. Usually this means that the bug has at some point been moved out of the UNCONFIRMED status and into another open status.
	IsConfirmed bool `json:"is_confirmed,omitempty"`
	// IsOpen is true if this bug is open, false if it is closed.
	IsOpen bool `json:"is_open,omitempty"`
	// IsCreatorAccessible is if true, this bug can be accessed by the creator of the bug, even if they are not a member of the groups the bug is restricted to.
	IsCreatorAccessible bool `json:"is_creator_accessible,omitempty"`
	// Keywords is each keyword that is on this bug.
	Keywords []string `json:"keywords,omitempty"`
	// LastChangeTime is when the bug was last changed.
	LastChangeTime string `json:"last_change_time,omitempty"`
	// OperatingSystem is the name of the operating system that the bug was filed against.
	OperatingSystem string `json:"op_sys,omitempty"`
	// Platform is the name of the platform (hardware) that the bug was filed against.
	Platform string `json:"platform,omitempty"`
	// Priority is the priority of the bug.
	Priority string `json:"priority,omitempty"`
	// Product is the name of the product this bug is in.
	Product string `json:"product,omitempty"`
	// QAContact is the login name of the current QA Contact on the bug.
	QAContact string `json:"qa_contact,omitempty"`
	// QAContactDetail is an object containing detailed user information for the qa_contact. To see the keys included in the user detail object, see below.
	QAContactDetail *User `json:"qa_contact_detail,omitempty"`
	// RemainingTime is the number of hours of work remaining until work on this bug is complete. If you are not in the time-tracking group, this field will not be included in the return value.
	RemainingTime int `json:"remaining_time,omitempty"`
	// Resolution is the current resolution of the bug, or an empty string if the bug is open.
	Resolution string `json:"resolution,omitempty"`
	// SeeAlso is the URLs in the See Also field on the bug.
	SeeAlso []string `json:"see_also,omitempty"`
	// Severity is the current severity of the bug.
	Severity string `json:"severity,omitempty"`
	// Status is the current status of the bug.
	Status string `json:"status,omitempty"`
	// Summary is the summary of this bug.
	Summary string `json:"summary,omitempty"`
	// TargetMilestone is the milestone that this bug is supposed to be fixed by, or for closed bugs, the milestone that it was fixed for.
	TargetMilestone string `json:"target_milestone,omitempty"`
	// TargetRelease are the releases that the bug will be fixed in.
	TargetRelease []string `json:"target_release,omitempty"`
	// UpdateToken is the token that you would have to pass to the process_bug.cgi page in order to update this bug. This changes every time the bug is updated. This field is not returned to logged-out users.
	UpdateToken string `json:"update_token,omitempty"`
	// URL is a URL that demonstrates the problem described in the bug, or is somehow related to the bug report.
	URL string `json:"url,omitempty"`
	// Verified is a custom field in redhat bugzilla that indicates the status of verification by QA
	Verified []string `json:"cf_verified,omitempty"`
	// Version are the versions the bug was reported against.
	Version []string `json:"version,omitempty"`
	// Whiteboard is he value of the "status whiteboard" field on the bug.
	Whiteboard string `json:"whiteboard,omitempty"`
	// PRs holds the links to the pull requests associated with the bug.
	PRs []ExternalBug `json:"external_bug,omitempty"`
}

Bug is a record of a bug. See API documentation at: https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug

type BugCreate

type BugCreate struct {
	// Alias is an optional list of unique aliases of this bug.
	Alias []string `json:"alias,omitempty"`
	// AssignedTo is the login name of the user to whom the bug is assigned.
	AssignedTo string `json:"assigned_to,omitempty"`
	// CC is the login names of users on the CC list of this bug.
	CC []string `json:"cc,omitempty"`
	// CommentIsPrivate sets the description to private. Otherwise it is assumed to be public.
	CommentIsPrivate bool `json:"comment_is_private,omitempty"`
	// CommentTags is an array of strings to add as comment tags for the description
	CommentTags []string `json:"comment_tags,omitempty"`
	// Component is an array of names of the current components of this bug.
	Component []string `json:"component,omitempty"`
	// Description is the initial description for this bug
	Description string `json:"description,omitempty"`
	// Flags is an array of objects containing the information about flags currently set for the bug.
	Flags []Flag `json:"flags,omitempty"`
	// Groups is the names of all the groups that this bug is in.
	Groups []string `json:"groups,omitempty"`
	// IsMarkdown should be set if the description has Markdown structures; otherwise it is normal text.
	IsMarkdown bool `json:"is_markdown,omitempty"`
	// Keywords is each keyword that is on this bug.
	Keywords []string `json:"keywords,omitempty"`
	// OperatingSystem is the name of the operating system that the bug was filed against.
	OperatingSystem string `json:"op_sys,omitempty"`
	// Platform is the name of the platform (hardware) that the bug was filed against.
	Platform string `json:"platform,omitempty"`
	// Priority is the priority of the bug.
	Priority string `json:"priority,omitempty"`
	// Product is the name of the product this bug is in.
	Product string `json:"product,omitempty"`
	// QAContact is the login name of the current QA Contact on the bug.
	QAContact string `json:"qa_contact,omitempty"`
	// Resolution is the current resolution of the bug, or an empty string if the bug is open.
	Resolution string `json:"resolution,omitempty"`
	// Severity is the current severity of the bug.
	Severity string `json:"severity,omitempty"`
	// Status is the current status of the bug.
	Status string `json:"status,omitempty"`
	// SubComponents are the subcomponents of the component for the bug. The key is the Component name, while the value is an array of length 1 containing the subcomponent name.
	// This is a Red Hat bugzilla specific extra field.
	SubComponents map[string][]string `json:"sub_components,omitempty"`
	// Summary is the summary of this bug.
	Summary string `json:"summary,omitempty"`
	// TargetMilestone is the milestone that this bug is supposed to be fixed by, or for closed bugs, the milestone that it was fixed for.
	TargetMilestone string `json:"target_milestone,omitempty"`
	// Version are the versions the bug was reported against.
	Version []string `json:"version,omitempty"`
	// TargetRelease are the releases that the bug will be fixed in.
	TargetRelease []string `json:"target_release,omitempty"`
}

BugCreate holds the info needed to create a new bug https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug

type BugUpdate

type BugUpdate struct {
	// DependsOn specifies the bugs that this bug depends on
	DependsOn  *IDUpdate `json:"depends_on,omitempty"`
	Blocks     *IDUpdate `json:"blocks,omitempty"`
	Resolution string    `json:"resolution,omitempty"`
	// Status is the current status of the bug.
	Status string `json:"status,omitempty"`
	// TargetRelease is the release version this bugfix is targeting
	TargetRelease []string `json:"target_release,omitempty"`
	// Version is the version the bug was reported against.
	Version string `json:"version,omitempty"`
	// The Status Whiteboard field of a bug.
	Whiteboard string `json:"whiteboard,omitempty"`
}

BugUpdate contains fields to update on a Bug. See API documentation at: https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug

type Client

type Client interface {
	Endpoint() string
	// GetBug retrieves a Bug from the server
	GetBug(id int) (*Bug, error)
	// GetComments gets a list of comments for a specific bug ID.
	// https://bugzilla.readthedocs.io/en/latest/api/core/v1/comment.html#get-comments
	GetComments(id int) ([]Comment, error)
	// GetExternalBugPRsOnBug retrieves external bugs on a Bug from the server
	// and returns any that reference a Pull Request in GitHub
	// https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#get-bug
	GetExternalBugPRsOnBug(id int) ([]ExternalBug, error)
	// GetSubComponentsOnBug retrieves a the list of SubComponents of the bug.
	// SubComponents are a Red Hat bugzilla specific extra field.
	GetSubComponentsOnBug(id int) (map[string][]string, error)
	// GetClones gets the list of bugs that the provided bug blocks that also have a matching summary.
	GetClones(bug *Bug) ([]*Bug, error)
	// CreateBug creates a new bug on the server.
	// https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#create-bug
	CreateBug(bug *BugCreate) (int, error)
	// CreateComment creates a new bug on the server.
	// https://bugzilla.redhat.com/docs/en/html/api/core/v1/comment.html#create-comments
	CreateComment(bug *CommentCreate) (int, error)
	// CloneBug clones a bug by creating a new bug with the same fields, copying the description, and updating the bug to depend on the original bug
	CloneBug(bug *Bug, mutations ...func(bug *BugCreate)) (int, error)
	// UpdateBug updates the fields of a bug on the server
	// https://bugzilla.readthedocs.io/en/latest/api/core/v1/bug.html#update-bug
	UpdateBug(id int, update BugUpdate) error
	// AddPullRequestAsExternalBug attempts to add a PR to the external tracker list.
	// External bugs are assumed to fall under the type identified by their hostname,
	// so we will provide https://github.com/ here for the URL identifier. We return
	// any error as well as whether a change was actually made.
	// This will be done via JSONRPC:
	// https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#add-external-bug
	AddPullRequestAsExternalBug(id int, org, repo string, num int) (bool, error)
	// RemovePullRequestAsExternalBug attempts to remove a PR from the external tracker list.
	// External bugs are assumed to fall under the type identified by their hostname,
	// so we will provide https://github.com/ here for the URL identifier. We return
	// any error as well as whether a change was actually made.
	// This will be done via JSONRPC:
	// https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html#remove-external-bug
	RemovePullRequestAsExternalBug(id int, org, repo string, num int) (bool, error)
	// GetAllClones returns all the clones of the bug including itself
	// Differs from GetClones as GetClones only gets the child clones which are one level lower
	GetAllClones(bug *Bug) ([]*Bug, error)
	// GetRootForClone returns the original bug.
	GetRootForClone(bug *Bug) (*Bug, error)
	// SetRoundTripper sets a custom implementation of RoundTripper as the Transport for http.Client
	SetRoundTripper(t http.RoundTripper)

	// ForPlugin and ForSubcomponent allow for the logger used in the client
	// to be created in a more specific manner when spawning parallel workers
	ForPlugin(plugin string) Client
	ForSubcomponent(subcomponent string) Client
	WithFields(fields logrus.Fields) Client
	Used() bool

	// SearchBugs returns all bugs that meet the given criteria
	SearchBugs(filters map[string]string) ([]*Bug, error)
}

func NewClient

func NewClient(getAPIKey func() []byte, endpoint string, githubExternalTrackerId uint, authMethod string) Client

NewClient returns a bugzilla client.

type Comment

type Comment struct {
	// ID is the globally unique ID for the comment.
	ID int `json:"id,omitempty"`
	// BugID is the ID of the bug that this comment is on.
	BugID int `json:"bug_id,omitempty"`
	// AttachmentID is the ID of the attachment if this comment was made on an attachment.
	AttachmentID *int `json:"attachment_id,omitempty"`
	// Count is the number of the comment local to the bug. The Description is 0, comments start with 1.
	Count int `json:"count,omitempty"`
	// Text is the actual text of the comment.
	Text string `json:"text,omitempty"`
	// Creator is the login name of the comment's author.
	Creator string `json:"creator,omitempty"`
	// Time is the time (in Bugzilla's timezone) that the comment was added.
	Time time.Time `json:"time,omitempty"`
	// CreationTime is exactly same as the time key. Use this field instead of time for consistency with other methods including Get Bug and Get Attachment.
	// For compatibility, time is still usable. However, please note that time may be deprecated and removed in a future release.
	CreationTime time.Time `json:"creation_time,omitempty"`
	// IsPrivate is true if this comment is private (only visible to a certain group called the "insidergroup"), false otherwise.
	IsPrivate bool `json:"is_private,omitempty"`
	// IsMarkdown is true if this comment needs Markdown processing; false otherwise.
	IsMarkdown bool `json:"is_markdown,omitempty"`
	// Tags is an array of comment tags currently set for the comment.
	Tags []string `json:"tags,omitempty"`
}

Comment holds information about a comment

type CommentCreate

type CommentCreate struct {
	// ID is the ID of the bug this comment is on.
	ID int `json:"id,omitempty"`
	// Comment is the text of the comment being created.
	Comment string `json:"comment,omitempty"`
	// IsPrivate is true if this comment is private (only visible to a certain group called the "insidergroup"), false otherwise.
	IsPrivate bool `json:"is_private,omitempty"`
}

CommentCreate holds information needed to create a comment

type ExternalBug

type ExternalBug struct {
	// Type holds more metadata for the external bug tracker
	Type ExternalBugType `json:"type"`
	// BugzillaBugID is the ID of the Bugzilla bug this external bug is linked to
	BugzillaBugID int `json:"bug_id"`
	// ExternalBugID is a unique identifier for the bug under the tracker
	ExternalBugID string `json:"ext_bz_bug_id"`
	// The following fields are parsed from the external bug identifier
	Org, Repo string
	Num       int
	// Status holds the status of the PR (ie closed, merged, open)
	Status string `json:"ext_status"`
}

ExternalBug contains details about an external bug linked to a Bugzilla bug. See API documentation at: https://bugzilla.redhat.com/docs/en/html/integrating/api/Bugzilla/Extension/ExternalBugs/WebService.html

type ExternalBugIdentifier

type ExternalBugIdentifier struct {
	// Type is the URL prefix that identifies the external bug tracker type.
	// For GitHub, this is commonly https://github.com/
	Type string `json:"ext_type_url,omitempty"`
	// TrackerID is the internal identifier for the external bug tracker type.
	// This should be passed instead of the ext_type_url when there is more
	// than one external tracker for https://github.com/
	TrackerID int `json:"ext_type_id,omitempty"`
	// ID is the identifier of the external bug within the bug tracker type.
	// For GitHub issues and pull requests, this ID is commonly the path
	// like `org/repo/pull/number` or `org/repo/issue/number`.
	ID string `json:"ext_bz_bug_id"`
}

ExternalBugIdentifier holds fields used to identify external bugs when modifying them using the JSONRPC API

type ExternalBugType

type ExternalBugType struct {
	// URL is the identifying URL for this tracker
	URL string `json:"url"`
}

ExternalBugType holds identifying metadata for a tracker

type Fake

type Fake struct {
	EndpointString   string
	Bugs             map[int]Bug
	BugComments      map[int][]Comment
	BugErrors        sets.Int
	BugErrorMessages map[int]string
	BugCreateErrors  sets.String
	ExternalBugs     map[int][]ExternalBug
	SubComponents    map[int]map[string][]string
	SearchedBugs     []*Bug
}

Fake is a fake Bugzilla client with injectable fields

func (*Fake) AddPullRequestAsExternalBug

func (c *Fake) AddPullRequestAsExternalBug(id int, org, repo string, num int) (bool, error)

AddPullRequestAsExternalBug adds an external bug to the Bugzilla bug, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) CloneBug

func (c *Fake) CloneBug(bug *Bug, mutations ...func(bug *BugCreate)) (int, error)

CloneBug clones a bug by creating a new bug with the same fields, copying the description, and updating the bug to depend on the original bug

func (*Fake) CreateBug

func (c *Fake) CreateBug(bug *BugCreate) (int, error)

CreateBug creates a new bug and associated description comment given a BugCreate or and error if description is in BugCreateErrors set

func (*Fake) CreateComment

func (c *Fake) CreateComment(comment *CommentCreate) (int, error)

func (*Fake) Endpoint

func (c *Fake) Endpoint() string

Endpoint returns the endpoint for this fake

func (*Fake) ForPlugin

func (c *Fake) ForPlugin(plugin string) Client

func (*Fake) ForSubcomponent

func (c *Fake) ForSubcomponent(subcomponent string) Client

func (*Fake) GetAllClones

func (c *Fake) GetAllClones(bug *Bug) ([]*Bug, error)

GetAllClones gets all clones including its parents and children spanning multiple levels

func (*Fake) GetBug

func (c *Fake) GetBug(id int) (*Bug, error)

GetBug retrieves the bug, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) GetClones

func (c *Fake) GetClones(bug *Bug) ([]*Bug, error)

func (*Fake) GetComments

func (c *Fake) GetComments(id int) ([]Comment, error)

GetComments retrieves the bug comments, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) GetExternalBugPRsOnBug

func (c *Fake) GetExternalBugPRsOnBug(id int) ([]ExternalBug, error)

GetBug retrieves the external bugs for the Bugzilla bug, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) GetRootForClone

func (c *Fake) GetRootForClone(bug *Bug) (*Bug, error)

GetRootForClone gets the original bug.

func (*Fake) GetSubComponentsOnBug

func (c *Fake) GetSubComponentsOnBug(id int) (map[string][]string, error)

func (*Fake) RemovePullRequestAsExternalBug

func (c *Fake) RemovePullRequestAsExternalBug(id int, org, repo string, num int) (bool, error)

RemovePullRequestAsExternalBug removes an external bug from the Bugzilla bug, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) SearchBugs

func (c *Fake) SearchBugs(filters map[string]string) ([]*Bug, error)

func (*Fake) SetRoundTripper

func (c *Fake) SetRoundTripper(t http.RoundTripper)

SetRoundTripper sets the Transport in http.Client to a custom RoundTripper

func (*Fake) UpdateBug

func (c *Fake) UpdateBug(id int, update BugUpdate) error

UpdateBug updates the bug, if registered, or an error, if set, or responds with an error that matches IsNotFound

func (*Fake) Used

func (c *Fake) Used() bool

func (*Fake) WithFields

func (c *Fake) WithFields(fields logrus.Fields) Client

type Flag

type Flag struct {
	// The ID of the flag.
	ID int `json:"id,omitempty"`
	// The name of the flag.
	Name string `json:"name,omitempty"`
	// The type ID of the flag.
	TypeID int `json:"type_id,omitempty"`
	// The timestamp when this flag was originally created.
	CreationDate string `json:"creation_date,omitempty"`
	// The timestamp when the flag was last modified.
	ModificationDate string `json:"modification_date,omitempty"`
	// The current status of the flag.
	Status string `json:"status,omitempty"`
	// The login name of the user who created or last modified the flag.
	Setter string `json:"setter,omitempty"`
	// The login name of the user this flag has been requested to be granted or denied. Note, this field is only returned if a requestee is set.
	Requestee string `json:"requestee,omitempty"`
}

Flag holds information about a flag set on a bug

type IDUpdate

type IDUpdate struct {
	// Add contains Bug IDs to add to this field.
	Add []int `json:"add,omitempty"`
	// Remove specifies Bug IDs to remove from this field. If the bug IDs are not already in the field, they will be ignored.
	Remove []int `json:"remove,omitempty"`
	// Set is An exact set of bug IDs to set this field to, overriding the current value. If Set is specified, then Add and Remove will be ignored.
	Set []int `json:"set,omitempty"`
}

IDUpdate is the struct used in Update calls to update fields that are arrays of IDs (ex. DependsOn)

type RemoveExternalBugParameters

type RemoveExternalBugParameters struct {
	// BugIDs are the IDs of Bugzilla bugs to update
	BugIDs []int `json:"bug_ids"`
	// The inline identifier for which external bug to remove
	ExternalBugIdentifier
}

RemoveExternalBugParameters are the parameters required to remove an external tracker bug from a Bugzilla bug

type User

type User struct {
	// The user ID for this user.
	ID int `json:"id,omitempty"`
	// The 'real' name for this user, if any.
	RealName string `json:"real_name,omitempty"`
	// The user's Bugzilla login.
	Name string `json:"name,omitempty"`
	// The user's e-mail.
	Email string `json:"email,omitempty"`
}

User holds information about a user

Jump to

Keyboard shortcuts

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