jira

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

View Source
const (
	StatusNew            = "NEW"
	StatusBacklog        = "BACKLOG"
	StatusAssigned       = "ASSIGNED"
	StatusInProgess      = "IN PROGRESS"
	StatusModified       = "MODIFIED"
	StatusPost           = "POST"
	StatusOnDev          = "ON_DEV"
	StatusOnQA           = "ON_QA"
	StatusVerified       = "VERIFIED"
	StatusReleasePending = "RELEASE PENDING"
	StatusClosed         = "CLOSED"
)

These are all the current valid states for Red Hat bugs in jira

Variables

This section is empty.

Functions

func CloneIssue

func CloneIssue(jc Client, parent *jira.Issue) (*jira.Issue, error)

CloneIssue copies an issue struct, clears unsettable fields, creates a new issue using the updated struct, and then links the new issue as a clone to the original.

func DeleteRemoteLinkViaURL

func DeleteRemoteLinkViaURL(jc Client, issueID, url string) (bool, error)

DeleteRemoteLinkViaURL identifies and removes a remote link from an issue the has the provided URL. The returned bool indicates whether a change was made during the operation as a remote link with the URL not existing is not consider an error for this function.

func GetIssueQaContact

func GetIssueQaContact(issue *jira.Issue) (*jira.User, error)

func GetIssueTargetVersion

func GetIssueTargetVersion(issue *jira.Issue) (*[]*jira.Version, error)

func GetUnknownField

func GetUnknownField(field string, issue *jira.Issue, fn func() interface{}) error

func HandleJiraError

func HandleJiraError(response *jira.Response, err error) error

HandleJiraError collapses cryptic Jira errors to include response bodies if it's detected that the original error holds no useful context in the first place

func IsNotFound

func IsNotFound(err error) bool

func JiraErrorBody

func JiraErrorBody(err error) string

JiraErrorBody will identify if an error is a JiraError and return the stored response body if it is; if it is not, an empty string will be returned

func JiraErrorStatusCode

func JiraErrorStatusCode(err error) int

JiraErrorStatusCode will identify if an error is a JiraError and return the stored status code if it is; if it is not, `-1` will be returned

func NewNotFoundError

func NewNotFoundError(err error) error

func UpdateStatus

func UpdateStatus(jc Client, issueID, statusName string) error

UpdateStatus updates an issue's status by identifying the ID of the provided statusName and then doing the status transition using the provided client to update the issue.

Types

type BasicAuthGenerator

type BasicAuthGenerator func() (username, password string)

type BearerAuthGenerator

type BearerAuthGenerator func() (token string)

type Client

type Client interface {
	GetIssue(id string) (*jira.Issue, error)
	// SearchWithContext will search for tickets according to the jql
	// Jira API docs: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-query-issues
	SearchWithContext(ctx context.Context, jql string, options *jira.SearchOptions) ([]jira.Issue, *jira.Response, error)
	UpdateIssue(*jira.Issue) (*jira.Issue, error)
	CreateIssue(*jira.Issue) (*jira.Issue, error)
	CreateIssueLink(*jira.IssueLink) error
	// CloneIssue copies an issue struct, clears unsettable fields, creates a new
	// issue using the updated struct, and then links the new issue as a clone to
	// the original.
	CloneIssue(*jira.Issue) (*jira.Issue, error)
	GetTransitions(issueID string) ([]jira.Transition, error)
	DoTransition(issueID, transitionID string) error
	// UpdateStatus updates an issue's status by identifying the ID of the provided
	// statusName and then doing the status transition to update the issue.
	UpdateStatus(issueID, statusName string) error
	// GetIssueSecurityLevel returns the security level of an issue. If no security level
	// is set for the issue, the returned SecurityLevel and error will both be nil and
	// the issue will follow the default project security level.
	GetIssueSecurityLevel(*jira.Issue) (*SecurityLevel, error)
	// GetIssueQaContact get the user details for the QA contact. The QA contact is a custom field in Jira
	GetIssueQaContact(*jira.Issue) (*jira.User, error)
	// GetIssueTargetVersion get the issue Target Release. The target release is a custom field in Jira
	GetIssueTargetVersion(issue *jira.Issue) (*[]*jira.Version, error)
	// FindUser returns all users with a field matching the queryParam (ex: email, display name, etc.)
	FindUser(queryParam string) ([]*jira.User, error)
	GetRemoteLinks(id string) ([]jira.RemoteLink, error)
	AddRemoteLink(id string, link *jira.RemoteLink) (*jira.RemoteLink, error)
	UpdateRemoteLink(id string, link *jira.RemoteLink) error
	DeleteLink(id string) error
	DeleteRemoteLink(issueID string, linkID int) error
	// DeleteRemoteLinkViaURL identifies and removes a remote link from an issue
	// the has the provided URL. The returned bool indicates whether a change
	// was made during the operation as a remote link with the URL not existing
	// is not consider an error for this function.
	DeleteRemoteLinkViaURL(issueID, url string) (bool, error)
	ForPlugin(plugin string) Client
	AddComment(issueID string, comment *jira.Comment) (*jira.Comment, error)
	ListProjects() (*jira.ProjectList, error)
	JiraClient() *jira.Client
	JiraURL() string
	Used() bool
	WithFields(fields logrus.Fields) Client
}

func NewClient

func NewClient(endpoint string, opts ...Option) (Client, error)

type CreateIssueError

type CreateIssueError struct {
	ErrorMessages []string          `json:"errorMessages"`
	Errors        map[string]string `json:"errors"`
}

type JiraError

type JiraError struct {
	StatusCode    int
	Body          string
	OriginalError error
}

func (JiraError) Error

func (e JiraError) Error() string

type NotFoundError

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

func (NotFoundError) Is

func (NotFoundError) Is(target error) bool

type Option

type Option func(*Options)

func WithBasicAuth

func WithBasicAuth(basicAuth BasicAuthGenerator) Option

func WithBearerAuth

func WithBearerAuth(token BearerAuthGenerator) Option

func WithFields

func WithFields(fields logrus.Fields) Option

type Options

type Options struct {
	BasicAuth  BasicAuthGenerator
	BearerAuth BearerAuthGenerator
	LogFields  logrus.Fields
}

type SecurityLevel

type SecurityLevel struct {
	Self        string `json:"self"`
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

func GetIssueSecurityLevel

func GetIssueSecurityLevel(issue *jira.Issue) (*SecurityLevel, error)

GetIssueSecurityLevel returns the security level of an issue. If no security level is set for the issue, the returned SecurityLevel and error will both be nil and the issue will follow the default project security level.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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