v1

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0 Copyright 2024 Eric Evans <eevans@wikimedia.org>, Wikimedia Foundation, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	StatusOpen status = iota
	StatusResolved
	StatusStalled
	StatusInvalid
	StatusDeclined

	PriorityHigh priority = iota
	PriorityUnbreakNow
	PriorityNeedsTriage
	PriorityMedium
	PriorityLow
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ByID

type ByID []*Task

func (ByID) Len

func (b ByID) Len() int

func (ByID) Less

func (b ByID) Less(i, j int) bool

func (ByID) Swap

func (b ByID) Swap(i, j int)

type Config

type Config struct {
	GoogleDriveId        string    `yaml:"google_drive_id"`
	GoogleDriveCredsPath string    `yaml:"google_drive_creds_path"`
	IrcConfig            ircConfig `yaml:"irc_config"`
	Phabricator          struct {
		Project string `yaml:"project"`
		URL     string `yaml:"url"`
		Token   string `yaml:"token"`
		User    string `yaml:"user"`
		Policy  struct {
			View string `yaml:"view"`
			Edit string `yaml:"edit"`
		}
	} `yaml:"phabricator"`
}

Config represents a Corto configuration.

func NewConfig

func NewConfig(filename string) (*Config, error)

NewConfig returns a Config struct from the contents of a YAML-formated file.

func ReadConfig

func ReadConfig(data []byte) (*Config, error)

ReadConfig returns a Config struct from the contents of a byte array.

type Corto

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

func NewCorto

func NewCorto(config *Config, tasks TaskManager, gDoc *GoogleDocument) (*Corto, error)

func (*Corto) CreateIncident

func (c *Corto) CreateIncident(title string) (*Task, error)

CreateIncident creates a new incident (Google Doc & Phabricator task), given an incident title.

func (*Corto) GetIncident

func (c *Corto) GetIncident(id int) (*Task, error)

GetIncident loads an existing Incident from its task ID

func (*Corto) ListOpen

func (c *Corto) ListOpen() ([]*Task, error)

ListOpen returns all open Tasks in Phabricator

func (*Corto) ResolveIncident

func (c *Corto) ResolveIncident(id int) (*Task, error)

func (*Corto) TitleIncident

func (c *Corto) TitleIncident(PHID string, new_title string) (bool, error)

func (*Corto) UpdateIC

func (c *Corto) UpdateIC(id int, coordinator string) (*Task, error)

type Document

type Document interface {
	// Create creates a new templated collab document from an Incident
	Create(incident Task) (string, error)
}

type GoogleDocument

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

func NewGoogleDocument

func NewGoogleDocument(ctx context.Context, driveID, credsFile string) (*GoogleDocument, error)

func (*GoogleDocument) Create

func (g *GoogleDocument) Create(incident Task) (string, error)

type ManiphestTaskManager

type ManiphestTaskManager struct {
	URL string
	// contains filtered or unexported fields
}

ManiphestTaskManager is a Phabricator implementation of the TaskManager interface.

func NewManiphestTaskManager

func NewManiphestTaskManager(token, url, project, viewPolicy, editPolicy string) (*ManiphestTaskManager, error)

NewManiphestTaskManager creates a PhabricatorIncidents from a token, URL, and project name.

func (*ManiphestTaskManager) AddComment

func (p *ManiphestTaskManager) AddComment(id int, comment string) error

AddComment creates a new comment on the Task associated with the id argument, using content corresponding to the comment arg.

func (*ManiphestTaskManager) Assign

func (p *ManiphestTaskManager) Assign(id int, user string) (*Task, error)

Assign (re)assigns the owner of a Task

func (*ManiphestTaskManager) Close

func (p *ManiphestTaskManager) Close(id int) (*Task, error)

Close sets an existing Task (corresponding to its ID) to StatusClosed. Upon success, a corresponding Task is returned, otherwise an error.

func (*ManiphestTaskManager) Create

func (p *ManiphestTaskManager) Create(title, description string) (*Task, error)

Create creates a new (open) task given a title and description. A corresponding Task struct is returned upon success, or an error otherwise.

func (*ManiphestTaskManager) Get

func (p *ManiphestTaskManager) Get(id int) (*Task, error)

Get returns a Task corresponding to its ID.

func (*ManiphestTaskManager) ListComments

func (p *ManiphestTaskManager) ListComments(id int, author string) ([]TaskComment, error)

ListComments returns a list of TaskComments according to a Task id and author.

func (*ManiphestTaskManager) ListOpen

func (p *ManiphestTaskManager) ListOpen() ([]*Task, error)

ListOpen returns a list of open tasks.

func (*ManiphestTaskManager) LookupPHID

func (p *ManiphestTaskManager) LookupPHID(name string) (string, error)

LookupPHID returns the Phabricator PHID for a name.

func (*ManiphestTaskManager) QueryPHID

func (p *ManiphestTaskManager) QueryPHID(phid string) (string, error)

type Task

type Task struct {
	ID          int       // incident ID (i.e. the task ID)
	Started     time.Time // incident start time (i.e. task open)
	Title       string    // self explanatory
	Status      status    // the incident status (open, closed, etc)
	Description string    // corresponds with ticket description
	Coordinator string    // IC; coordinates w/ "assigned"
	Tags        []string  // ???
	URL         string    // Task URL
}

Task represents a task ("ticket", etc) in a task tracking system.

type TaskComment

type TaskComment struct {
	Author  string
	Created time.Time
	Updated time.Time
	Content string
}

TaskComment represents a comment associated with a Task.

type TaskManager

type TaskManager interface {
	Create(title, description string) (*Task, error)
	Close(id int) (*Task, error)
	ListOpen() ([]*Task, error)
	Get(id int) (*Task, error)
	Assign(id int, user string) (*Task, error)
	AddComment(id int, comment string) error
	ListComments(id int, author string) ([]TaskComment, error)
}

TaskManager defines an interface for task managment implementations (ticketing systems).

type UserError added in v1.0.7

type UserError struct {
	Msg string
}

UserError is an error type that represents an invalid request, rather than a general system error. For example, attempting an edit to an issue not under the scope of incident management.

func (*UserError) Error added in v1.0.7

func (u *UserError) Error() string

Jump to

Keyboard shortcuts

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