Documentation ¶
Index ¶
- Constants
- func EncodePluginData(data PluginData) map[string]string
- func GetRequestID(issue Issue) (string, error)
- type App
- type ChangeDetails
- type Changelog
- type Comment
- type CommentInput
- type Config
- type CreatedIssue
- type EntityProperty
- type ErrorResult
- type GetIssueCommentQueryOptions
- type GetIssueQueryOptions
- type GetMyPermissionsQueryOptions
- type Issue
- type IssueFields
- type IssueFieldsInput
- type IssueInput
- type IssueTransition
- type IssueTransitionInput
- type IssueType
- type IssueUpdate
- type Jira
- func (j *Jira) AddIssueReviewComment(ctx context.Context, id string, review types.AccessReview) error
- func (j *Jira) AddResolutionComment(ctx context.Context, id string, resolution Resolution) error
- func (j *Jira) CreateIssue(ctx context.Context, reqID string, reqData RequestData) (JiraData, error)
- func (j *Jira) GetIssue(ctx context.Context, id string) (Issue, error)
- func (j *Jira) HealthCheck(ctx context.Context) error
- func (j *Jira) RangeIssueCommentsDescending(ctx context.Context, id string, fn func(PageOfComments) bool) error
- func (j *Jira) ResolveIssue(ctx context.Context, issueID string, resolution Resolution) error
- func (j *Jira) TransitionIssue(ctx context.Context, issueID, transitionID string) error
- type JiraConfig
- type JiraData
- type PageOfChangelogs
- type PageOfComments
- type Permission
- type Permissions
- type PluginData
- type Project
- type RequestData
- type Resolution
- type ResolutionTag
- type StatusDetails
- type UserDetails
- type Webhook
- type WebhookFunc
- type WebhookIssue
- type WebhookServer
Constants ¶
const ( Unresolved = ResolutionTag("") ResolvedApproved = ResolutionTag("approved") ResolvedDenied = ResolutionTag("denied") ResolvedExpired = ResolutionTag("expired") ResolvedPromoted = ResolutionTag("promoted") )
const (
DefaultDir = "/var/lib/teleport/plugins/jira"
)
const (
RequestIDPropertyKey = "teleportAccessRequestId"
)
Variables ¶
This section is empty.
Functions ¶
func EncodePluginData ¶
func EncodePluginData(data PluginData) map[string]string
EncodePluginData serializes a PluginData struct into a string map.
func GetRequestID ¶
GetRequestID extracts a request id from issue properties.
Types ¶
type App ¶
App contains global application state.
type ChangeDetails ¶
type Changelog ¶
type Changelog struct { ID string `json:"id"` Author UserDetails `json:"author"` Created string `json:"created"` Items []ChangeDetails `json:"items"` }
type Comment ¶
type Comment struct { Self string `json:"self"` ID string `json:"id"` Author UserDetails `json:"author"` Body string `json:"body"` Created string `json:"created"` }
type CommentInput ¶
type CommentInput struct { Body string `json:"body,omitempty"` Properties []EntityProperty `json:"properties,omitempty"` }
type Config ¶
type Config struct { Teleport lib.TeleportConfig `toml:"teleport"` Jira JiraConfig `toml:"jira"` HTTP lib.HTTPConfig `toml:"http"` Log logger.Config `toml:"log"` // Teleport is a handle to the client to use when communicating with // the Teleport auth server. The Jira app will create a gRPC-based // client on startup if this is not set. Client teleport.Client // StatusSink receives any status updates from the plugin for // further processing. Status updates will be ignored if not set. StatusSink common.StatusSink // DisableWebhook flags that the plugin should *not* run a // webhook server to receive notifications back from the Jira // serve. The default behavior is to run one. DisableWebhook bool }
func (*Config) CheckAndSetDefaults ¶
type CreatedIssue ¶
type EntityProperty ¶
type ErrorResult ¶
type GetIssueQueryOptions ¶
type Issue ¶
type Issue struct { Expand string `json:"expand"` Self string `json:"self"` ID string `json:"id"` Key string `json:"key"` Fields IssueFields `json:"fields"` Changelog PageOfChangelogs `json:"changelog"` Properties map[string]interface{} `json:"properties"` Transitions []IssueTransition `json:"transitions"` }
type IssueFields ¶
type IssueFields struct { Status StatusDetails `json:"status"` Comment PageOfComments `json:"comment"` Project Project `json:"project"` Type IssueType `json:"issuetype"` Summary string `json:"summary,omitempty"` Description string `json:"description,omitempty"` }
type IssueFieldsInput ¶
type IssueInput ¶
type IssueInput struct { Fields IssueFieldsInput `json:"fields,omitempty"` Properties []EntityProperty `json:"properties,omitempty"` }
type IssueTransition ¶
type IssueTransition struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` To StatusDetails `json:"to,omitempty"` }
func GetTransition ¶
func GetTransition(issue Issue, status string) (IssueTransition, error)
GetTransition returns an issue transition by a status name.
type IssueTransitionInput ¶
type IssueTransitionInput struct {
Transition IssueTransition `json:"transition"`
}
type IssueUpdate ¶
type IssueUpdate struct { Status string Author UserDetails }
IssueUpdate is an info of who updated the issue status.
func GetLastUpdate ¶
func GetLastUpdate(issue Issue, status string) (IssueUpdate, error)
GetLastUpdate returns a last issue update by a status name.
type Jira ¶
type Jira struct {
// contains filtered or unexported fields
}
Jira is a wrapper around resty.Client.
func NewJiraClient ¶
func NewJiraClient(conf JiraConfig, clusterName, teleportProxyAddr string, statusSink common.StatusSink) (*Jira, error)
NewJiraClient builds a new Jira client.
func (*Jira) AddIssueReviewComment ¶
func (j *Jira) AddIssueReviewComment(ctx context.Context, id string, review types.AccessReview) error
AddIssueReviewComment posts an issue comment about access review added to a request.
func (*Jira) AddResolutionComment ¶
AddResolutionComment posts an issue comment about request resolution.
func (*Jira) CreateIssue ¶
func (j *Jira) CreateIssue(ctx context.Context, reqID string, reqData RequestData) (JiraData, error)
CreateIssue creates an issue with "Pending" status
func (*Jira) HealthCheck ¶
HealthCheck checks Jira endpoint for validity and also checks the project permissions.
func (*Jira) RangeIssueCommentsDescending ¶
func (j *Jira) RangeIssueCommentsDescending(ctx context.Context, id string, fn func(PageOfComments) bool) error
RangeIssueCommentsDescending iterates over pages of comments of an issue.
func (*Jira) ResolveIssue ¶
ResolveIssue sets a final status e.g. "approved", "denied" or "expired" to the issue and posts the comment.
type JiraConfig ¶
type JiraConfig struct { URL string `toml:"url"` Username string `toml:"username"` APIToken string `toml:"api_token"` Project string `toml:"project"` IssueType string `toml:"issue_type"` }
func (*JiraConfig) CheckAndSetDefaults ¶
func (c *JiraConfig) CheckAndSetDefaults() error
type PageOfChangelogs ¶
type PageOfComments ¶
type Permission ¶
type Permissions ¶
type Permissions struct {
Permissions map[string]Permission `json:"permissions"`
}
type PluginData ¶
type PluginData struct { RequestData JiraData }
PluginData is a data associated with access request that we store in Teleport using UpdatePluginData API.
func DecodePluginData ¶
func DecodePluginData(dataMap map[string]string) (data PluginData)
DecodePluginData deserializes a string map to PluginData struct.
type Project ¶
type Project struct { Expand string `json:"expand,omitempty"` Self string `json:"self,omitempty"` ID string `json:"id,omitempty"` Key string `json:"key,omitempty"` Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` Name string `json:"name,omitempty"` }
type RequestData ¶
type Resolution ¶
type Resolution struct { Tag ResolutionTag Reason string }
type ResolutionTag ¶
type ResolutionTag string
type StatusDetails ¶
type UserDetails ¶
type Webhook ¶
type Webhook struct { Timestamp int `json:"timestamp"` WebhookEvent string `json:"webhookEvent"` IssueEventTypeName string `json:"issue_event_type_name"` User *struct { Self string `json:"self"` AccountID string `json:"accountId"` AccountType string `json:"accountType"` DisplayName string `json:"displayName"` Active bool `json:"active"` } `json:"user"` Issue *WebhookIssue `json:"issue"` }
type WebhookIssue ¶
type WebhookIssue struct { ID string `json:"id"` Self string `json:"self"` Key string `json:"key"` Fields IssueFields `json:"fields"` }
type WebhookServer ¶
type WebhookServer struct {
// contains filtered or unexported fields
}
WebhookServer is a wrapper around http.Server that processes Jira webhook events. It verifies incoming requests and calls onWebhook for valid ones
func NewWebhookServer ¶
func NewWebhookServer(conf lib.HTTPConfig, onWebhook WebhookFunc) (*WebhookServer, error)
func (*WebhookServer) BaseURL ¶
func (s *WebhookServer) BaseURL() *url.URL
func (*WebhookServer) EnsureCert ¶
func (s *WebhookServer) EnsureCert() error
func (*WebhookServer) ServiceJob ¶
func (s *WebhookServer) ServiceJob() lib.ServiceJob