jira

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package jira provides utilities for the Jira API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    *url.URL
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client implements Interface

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient creates a new Jira client with configuration from environment variables

func (*Client) AddCommentToTicket

func (c *Client) AddCommentToTicket(ticketKey string, comment string) error

AddCommentToTicket adds a comment to an existing Jira ticket

func (*Client) AuthType

func (c *Client) AuthType() string

AuthType returns the type of authentication being used

func (*Client) CreateFlakyTestTicket

func (c *Client) CreateFlakyTestTicket(req FlakyTestTicketRequest) (*TicketResponse, error)

CreateFlakyTestTicket creates a new Jira ticket for a flaky test

func (*Client) GetTicketStatus

func (c *Client) GetTicketStatus(ticketKey string) (*TicketStatus, error)

GetTicketStatus retrieves the current status of a Jira ticket

func (*Client) IsOAuthEnabled

func (c *Client) IsOAuthEnabled() bool

IsOAuthEnabled returns true if OAuth authentication is configured

type CreateIssueRequest

type CreateIssueRequest struct {
	Fields IssueFields `json:"fields"`
}

CreateIssueRequest represents the request body for creating a Jira issue.

type FlakyTestTicketRequest

type FlakyTestTicketRequest struct {
	RepoName        string `json:"repo_name"`
	TestPackageName string `json:"test_package_name"`
	FilePath        string `json:"file_path"`
	TrunkID         string `json:"trunk_id"` // UUID
	Details         string `json:"details"`  // JSON string with additional details (trunk Payload for example)
}

FlakyTestTicketRequest represents the data needed to create a Jira ticket for a flaky test

type IClient

type IClient interface {
	CreateFlakyTestTicket(req FlakyTestTicketRequest) (*TicketResponse, error)
	GetTicketStatus(ticketKey string) (*TicketStatus, error)
	AddCommentToTicket(ticketKey string, comment string) error
}

IClient is the interface that wraps the basic Jira client methods. Helpful for mocking in tests.

type IssueFields

type IssueFields struct {
	Project     Project   `json:"project"`
	Summary     string    `json:"summary"`
	Description string    `json:"description"`
	IssueType   IssueType `json:"issuetype"`
	Labels      []string  `json:"labels"`
}

IssueFields represents the fields for a Jira issue

type IssueType

type IssueType struct {
	Name string `json:"name"`
}

IssueType represents a Jira issue type

type Option

type Option func(*jiraClientOptions)

Option is a function that sets a configuration option for the Jira client.

func WithBaseURL

func WithBaseURL(baseURL *url.URL) Option

WithBaseURL sets the base URL for the Jira client.

func WithConfig

func WithConfig(config config.Config) Option

WithConfig sets the config to use for the Jira client.

func WithLogger

func WithLogger(logger zerolog.Logger) Option

WithLogger sets the logger to use for the Jira client.

type Project

type Project struct {
	Key string `json:"key"`
}

Project represents a Jira project

type TicketResponse

type TicketResponse struct {
	ID   string `json:"id"`
	Key  string `json:"key"`
	Self string `json:"self"`
}

TicketResponse represents the response from Jira when creating a ticket

type TicketStatus

type TicketStatus struct {
	Key    string `json:"key"`
	Status struct {
		Name       string `json:"name"`
		StatusCode string `json:"statusCategory"`
	} `json:"status"`
	Fields struct {
		Status struct {
			Name           string `json:"name"`
			StatusCategory struct {
				Key  string `json:"key"`
				Name string `json:"name"`
			} `json:"statusCategory"`
		} `json:"status"`
	} `json:"fields"`
}

TicketStatus represents the status information of a Jira ticket

func (*TicketStatus) IsResolved

func (jts *TicketStatus) IsResolved() bool

IsResolved returns true if the ticket is in a resolved/closed state

Jump to

Keyboard shortcuts

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