j2p

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2017 License: BSD-3-Clause Imports: 8 Imported by: 1

README

[GoDoc] (https://godoc.org/github.com/shuLhan/j2p) [Go Report Card] (https://goreportcard.com/report/github.com/shuLhan/j2p)

j2p is a tool to help migrating from JIRA to Phabricator.

NOTE: due to limited resources on testing (time and JIRA server for testing) this repository does not accept any reporting issue anymore on Github.

Installation

  • Get the repository
$ go get -u github.com/shuLhan/j2p
  • Create config file (see config.example for an example of what you can set)

Configuration

Configuration file is using JSON format. Below is decription for each key in each object.

jira

This option is required to connect and query JIRA server.

  • url: required, location of JIRA server
  • user: required, user name
  • pass: required, password for user
  • search_opt: this option will set start and max result of query
    • start_at: set, any query will return search start at this index
    • max_results: maximum result that a query will return

phabricator

This option is required to connect and export to Phabricator server.

  • url: required, location of Phabricator server
  • token: required, conduit API token
  • secure: if true, certificate of Phabricator server will be verified, otherwise certificate check will be skipped

prioritiesMap

This option define mapping of priorities between JIRA and Phabricator. The key name is priority name in JIRA and their value is priority name in Phabricator.

For example, to map Highest priority in JIRA to Needs Triage in Phabricator, set key and value to "Highest": 90.

statutesMap

This option define mapping of statutes between JIRA and Phabricator. The key name is status name in JIRA and their value is status name in Phabricator. For example, to map Open status in JIRA to open status in Phabricator, add "Open": "open".

Example

$ j2p tasks

This will read the config file and export all projects and tasks from JIRA and import it to Phabricator.

$ j2p --projects="Project A,Project B" tasks

This will only migrate tasks for project "Project A" and "Project B" only.

Features

  • Migrating tasks from JIRA to Phabricator

Limitations

  • Does not support migrating attachments
  • Does not support creating sub-task

Credits

  • Thanks to Go-jira package by andygrunwald [1]

License

Copyright 2016 Muhammad Shulhan ms@kilabit.info. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

[1] https://github.com/andygrunwald/go-jira

Documentation

Index

Constants

View Source
const (
	// JiraAPIProject define project API for JIRA
	JiraAPIProject = "/rest/api/2/project"

	// JiraQIssueAll define query for all issue based on a project.
	JiraQIssueAll = "project = \"%s\" ORDER BY created ASC"
)

Variables

View Source
var (
	// DEBUG debug level, set using environment J2P_DEBUG
	DEBUG = 0
)

Functions

func NewJiraClient

func NewJiraClient(cfg *Config) (jiraCl *jira.Client, e error)

NewJiraClient will create HTTP client to connect to JIRA server and do authentication using basic method (user,password).

Types

type Args

type Args struct {
	Job      string
	Projects ProjectFlags
}

Args contain command parameter passed by user. This will define what kind of object that will be migrated to Phabricator.

type Cmd

type Cmd struct {
	Config    *Config
	JiraCl    *jira.Client
	GonduitCl *gonduit.Client
	Args      Args
	// contains filtered or unexported fields
}

Cmd contains user configuration, HTTP client for JIRA and Phabricator, and command parameters.

func (*Cmd) Init

func (cmd *Cmd) Init() (e error)

Init will, (1) get JIRA and phabricator configuration, (2) login to JIRA, (3) create gonduit client.

func (*Cmd) JiraGetProjects

func (cmd *Cmd) JiraGetProjects() (
	jiraProjects *[]jira.Project,
	e error,
)

JiraGetProjects will query all project in JIRA filtered by command parameters `-projects` and return it.

func (*Cmd) MigrateProjects

func (cmd *Cmd) MigrateProjects() (e error)

MigrateProjects will migrate all projects from JIRA to Phabricator. Here is what this function will do, (1) It will get all project from JIRA (2) For each project in JIRA (2.1) Create the project in Phabricator (2.2) If its fails -- the project already exist, get the project PHID from Phabricator (2.3) Save the first matched project as mapping for Phabricator project, since there is no way we can check other than name.

func (*Cmd) MigrateTasks

func (cmd *Cmd) MigrateTasks() (e error)

MigrateTasks will migrate all task from JIRA to Phabricator based on list of project registered in `cmd.gonProjects`.

func (*Cmd) NewConfig

func (cmd *Cmd) NewConfig() (e error)

NewConfig will read `config` file and save them in Config object.

type Config

type Config struct {
	Jira          ConfigJira        `json:"jira"`
	Phab          ConfigPhabricator `json:"phabricator"`
	PrioritiesMap map[string]int    `json:"prioritiesMap"`
	StatusesMap   map[string]string `json:"statusesMap"`
}

Config contains user configuration, read from `config` file in current directory.

type ConfigJira

type ConfigJira struct {
	URL       string              `json:"url"`
	User      string              `json:"user"`
	Pass      string              `json:"pass"`
	SearchOpt ConfigJiraSearchOpt `json:"search_opt"`
}

ConfigJira contains information about JIRA server and API options.

type ConfigJiraSearchOpt

type ConfigJiraSearchOpt struct {
	StartAt    int `json:"start_at"`
	MaxResults int `json:"max_results"`
}

ConfigJiraSearchOpt contains options when doing query to JIRA.

type ConfigPhabricator

type ConfigPhabricator struct {
	URL    string `json:"url"`
	Token  string `json:"token"`
	Secure bool   `json:"secure"`
}

ConfigPhabricator contains information of Phabricator server.

type ProjectFlags

type ProjectFlags []string

ProjectFlags contains list of project passed through command line.

func (*ProjectFlags) Set

func (prflags *ProjectFlags) Set(vv string) error

Set will parse the projects flags.

func (*ProjectFlags) String

func (prflags *ProjectFlags) String() string

String return text representation of project flags.

Directories

Path Synopsis
cmd
j2p

Jump to

Keyboard shortcuts

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