jiraworklog

package module
v0.2.1-0...-0cc80b3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIssueNotFound = errors.New("Jira Issue not found")

var errUnknownProject = errors.New("Unknown Project")

View Source
var ErrNoConfigFile = errors.New("No config file. One will be created for you")

Functions

func NewLogger

func NewLogger(options LoggerOptions) *logrus.Entry

Types

type Config

type Config struct {
	Jira          JiraSettings
	SQLConnection string
	MaxWorklogID  int
	LastTimestamp int64
	UserList      []string
	DoneStatus    []string
	// contains filtered or unexported fields
}

Config holds info needed for connecting to Jira and SQL

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig will load up a Config object based on configPath

func (*Config) Save

func (c *Config) Save() error

Save will persist the configuration information

func (*Config) Write

func (c *Config) Write(path string) error

Write will persist the configuration information to the given path

type Issue

type Issue struct {
	Expand string `json:"expand"`
	ID     string `json:"id"`
	Self   string `json:"self"`
	Key    string `json:"key"`
	Fields struct {
		Summary                  string  `json:"summary"`
		Created                  string  `json:created`
		ResolutionDate           *string `json:resolutiondate`
		StatusCategoryChangeDate *string `json:"statuscategorychangedate"`
		Issuetype                struct {
			Self        string `json:"self"`
			ID          string `json:"id"`
			Description string `json:"description"`
			IconURL     string `json:"iconUrl"`
			Name        string `json:"name"`
			Subtask     bool   `json:"subtask"`
			AvatarID    int    `json:"avatarId"`
		} `json:"issuetype"`
		Parent struct {
			ID     string `json:"id"`
			Key    string `json:"key"`
			Self   string `json:"self"`
			Fields struct {
				Summary string `json:"summary"`
				Status  struct {
					Self           string `json:"self"`
					Description    string `json:"description"`
					IconURL        string `json:"iconUrl"`
					Name           string `json:"name"`
					ID             string `json:"id"`
					StatusCategory struct {
						Self      string `json:"self"`
						ID        int    `json:"id"`
						Key       string `json:"key"`
						ColorName string `json:"colorName"`
						Name      string `json:"name"`
					} `json:"statusCategory"`
				} `json:"status"`
				Priority struct {
					Self    string `json:"self"`
					IconURL string `json:"iconUrl"`
					Name    string `json:"name"`
					ID      string `json:"id"`
				} `json:"priority"`
				Issuetype struct {
					Self        string `json:"self"`
					ID          string `json:"id"`
					Description string `json:"description"`
					IconURL     string `json:"iconUrl"`
					Name        string `json:"name"`
					Subtask     bool   `json:"subtask"`
					AvatarID    int    `json:"avatarId"`
				} `json:"issuetype"`
			} `json:"fields"`
		} `json:"parent"`
		Timespent            int `json:"timespent"`
		Timeoriginalestimate int `json:"timeoriginalestimate"`
		Description          struct {
			Version int    `json:"version"`
			Type    string `json:"type"`
			Content []struct {
				Type    string `json:"type"`
				Content []struct {
					Type string `json:"type"`
					Text string `json:"text"`
				} `json:"content"`
			} `json:"content"`
		} `json:"description"`
		Progress struct {
			Progress int `json:"progress"`
			Total    int `json:"total"`
			Percent  int `json:"percent"`
		} `json:"progress"`
		Aggregateprogress struct {
			Progress int `json:"progress"`
			Total    int `json:"total"`
			Percent  int `json:"percent"`
		} `json:"aggregateprogress"`
		Aggregatetimespent            int `json:"aggregatetimespent"`
		Aggregatetimeoriginalestimate int `json:"aggregatetimeoriginalestimate"`
		Priority                      struct {
			Self    string `json:"self"`
			IconURL string `json:"iconUrl"`
			Name    string `json:"name"`
			ID      string `json:"id"`
		} `json:"priority"`
		Status struct {
			Self           string `json:"self"`
			Description    string `json:"description"`
			IconURL        string `json:"iconUrl"`
			Name           string `json:"name"`
			ID             string `json:"id"`
			StatusCategory struct {
				Self      string `json:"self"`
				ID        int    `json:"id"`
				Key       string `json:"key"`
				ColorName string `json:"colorName"`
				Name      string `json:"name"`
			} `json:"statusCategory"`
		} `json:"status"`
		Timetracking struct {
			OriginalEstimate         string `json:"originalEstimate"`
			RemainingEstimate        string `json:"remainingEstimate"`
			TimeSpent                string `json:"timeSpent"`
			OriginalEstimateSeconds  int    `json:"originalEstimateSeconds"`
			RemainingEstimateSeconds int    `json:"remainingEstimateSeconds"`
			TimeSpentSeconds         int    `json:"timeSpentSeconds"`
		} `json:"timetracking"`
	} `json:"fields"`
}

func (Issue) HasParent

func (i Issue) HasParent() bool

func (Issue) ParentID

func (i Issue) ParentID() string

type Jira

type Jira struct {
	Config *Config
	// contains filtered or unexported fields
}

func NewJira

func NewJira(c *Config) *Jira

func (*Jira) Issue

func (j *Jira) Issue(idOrKey string) (Issue, error)

func (*Jira) WorklogDetails

func (j *Jira) WorklogDetails(ids []int) ([]Worklog, error)

func (*Jira) WorklogsUpdated

func (j *Jira) WorklogsUpdated(timestamp int64) (UpdatedWorklogs, error)

type JiraReader

type JiraReader interface {
	WorklogsUpdated(timestamp int64) (UpdatedWorklogs, error)
	WorklogDetails(ids []int) ([]Worklog, error)
	Issue(idOrKey string) (Issue, error)
}

type JiraSettings

type JiraSettings struct {
	URL      string
	Username string
	Password string
}

JiraSettings represent connection and credential information to Jira

type Job

type Job interface {
	Run() error
	GetInterval() time.Duration
	GetName() string
}

Job represents a job that needs to run at the given interval

type LoggerOptions

type LoggerOptions struct {
	Application string
	LogFile     string
	Level       string
}

type UpdatedWorklogs

type UpdatedWorklogs struct {
	Values []struct {
		WorklogID   int           `json:"worklogId"`
		UpdatedTime int64         `json:"updatedTime"`
		Properties  []interface{} `json:"properties"`
	} `json:"values"`
	Since    int64  `json:"since"`
	Until    int64  `json:"until"`
	Self     string `json:"self"`
	LastPage bool   `json:"lastPage"`
}

type Worker

type Worker struct {
	Stopped bool // A flag determining the state of the worker
	Jobs    []Job
	// contains filtered or unexported fields
}

Worker will do its Action once every interval, making up for lost time that happened during the Action by only waiting the time left in the interval.

func NewWorker

func NewWorker(logger *log.Entry, jobs ...Job) *Worker

NewWorker creates a new worker and instantiates all the data structures required.

func (*Worker) Run

func (w *Worker) Run(job Job)

Run will execute the given job

func (*Worker) Shutdown

func (w *Worker) Shutdown()

Shutdown is a graceful shutdown mechanism

func (*Worker) Start

func (w *Worker) Start()

Start will start the worker and listens for a shutdown call.

type Worklog

type Worklog struct {
	Self   string `json:"self"`
	Author struct {
		Self string `json:"self"`
		//Name         string `json:"name"`
		//Key          string `json:"key"`
		AccountID string `json:"accountId"`
		//EmailAddress string `json:"emailAddress"`
		AvatarUrls struct {
			Four8X48  string `json:"48x48"`
			Two4X24   string `json:"24x24"`
			One6X16   string `json:"16x16"`
			Three2X32 string `json:"32x32"`
		} `json:"avatarUrls"`
		DisplayName string `json:"displayName"`
		Active      bool   `json:"active"`
		TimeZone    string `json:"timeZone"`
		AccountType string `json:"accountType"`
	} `json:"author"`
	UpdateAuthor struct {
		Self         string `json:"self"`
		Name         string `json:"name"`
		Key          string `json:"key"`
		AccountID    string `json:"accountId"`
		EmailAddress string `json:"emailAddress"`
		AvatarUrls   struct {
			Four8X48  string `json:"48x48"`
			Two4X24   string `json:"24x24"`
			One6X16   string `json:"16x16"`
			Three2X32 string `json:"32x32"`
		} `json:"avatarUrls"`
		DisplayName string `json:"displayName"`
		Active      bool   `json:"active"`
		TimeZone    string `json:"timeZone"`
		AccountType string `json:"accountType"`
	} `json:"updateAuthor"`
	Created          string `json:"created"`
	Updated          string `json:"updated"`
	Started          string `json:"started"`
	TimeSpent        string `json:"timeSpent"`
	TimeSpentSeconds int    `json:"timeSpentSeconds"`
	ID               string `json:"id"`
	IssueID          string `json:"issueId"`
}

type WorklogList

type WorklogList struct {
	IDs []int `json:"ids"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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