jira

package
v0.0.0-...-614ca16 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Factory = stories.StoryRegistrationFactory{
	Factory: func(configs []values.Values) []stories.StoryHandlerRegistration {

		var results []stories.StoryHandlerRegistration
		for _, v := range configs {

			rawProvider, _ := v.GetAtPath("provider")
			provider, ok := rawProvider.(string)
			if ok && strings.ToLower(provider) == "jira" {

				var config Config
				err := v.Unmarshal(&config)
				if err != nil {
					core.Log.WithError(err).Error("Could not parse values.")
					continue
				}
				if config.IDPattern == "" {
					config.IDPattern = ".*"
				}

				pattern, reErr := regexp.Compile(config.IDPattern)
				if reErr != nil {
					core.Log.WithError(err).Error("Invalid ID pattern")
					continue
				}
				results = append(results, stories.StoryHandlerRegistration{
					IDPattern: pattern,
					HandlerFactory: func(ctx command.ExecutionContext) (stories.StoryHandler, error) {
						return NewClient(ctx, config)
					},
				})
			}
		}

		return results
	},
	Help: `Jira Story Handler:

Update your workspace bosun.yaml storyHandlers:

storyHandlers:
- provider: jira
  # A pattern that matches the IDs you want to handle
  idPattern: DATAINT-\d+  
  # URL to atlassian jira 
  url: https://aunalytics.atlassian.net
  # Your username
  username:
  # Your account ID; go to your profile in jira and copy the last path segment, like 557058:25a4ebee-6aa5-48c6-a186-561c36d52b33
  accountID: 
  # Obtain a token from https://id.atlassian.com/manage-profile/security/api-tokens and put it in LastPass
  token: 
    script:
      lpass show $FOLDER_AND_PATH --password
`,
}

Functions

This section is empty.

Types

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx command.ExecutionContext, config Config) (*Client, error)

func (*Client) GetBranches

func (c *Client) GetBranches(story *stories.Story) ([]stories.BranchRef, error)

func (*Client) GetStory

func (c *Client) GetStory(id string) (*stories.Story, error)

func (*Client) HandleEvent

func (c *Client) HandleEvent(event *stories.ValidatedEvent) error

type CompiledTransitions

type CompiledTransitions struct {
	InDevelopment *regexp.Regexp
	CodeReview    *regexp.Regexp
	QA            *regexp.Regexp
	UAT           *regexp.Regexp
}

type Config

type Config struct {
	Provider     string               `yaml:"provider"`
	AccountID    string               `yaml:"accountID"`
	JiraUrl      string               `yaml:"url"`
	JiraUsername string               `yaml:"username"`
	JiraToken    command.CommandValue `yaml:"token"`
	IDPattern    string               `yaml:"idPattern"`
	Transitions  Transitions          `yaml:"transitions"`
}

type RepoBranchComment

type RepoBranchComment string

func SubtaskName

func SubtaskName(repoRef issues.IssueRef, branch string) RepoBranchComment

func (RepoBranchComment) String

func (r RepoBranchComment) String() string

type Transitions

type Transitions struct {
	InDevelopment string `yaml:"development,omitempty"`
	CodeReview    string `yaml:"codeReview,omitempty"`
	QA            string `yaml:"qa,omitempty"`
	UAT           string `yaml:"uat,omitempty"`
}

func (Transitions) Compiled

func (t Transitions) Compiled() (CompiledTransitions, error)

Jump to

Keyboard shortcuts

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