cfg

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DateFormat = "2006-01-02T15:04:05-0700"

dateFormat is the format used for the `since` configuration parameter

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(app, level string) *logrus.Entry

newLogger uses the log level provided in the configuration to create a new logrus logger and set fields on it to make it easy to use.

Types

type Config

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

Config is the root configuration object the application creates.

func NewConfig

func NewConfig(cmd *cobra.Command) (Config, error)

NewConfig creates a new, immutable configuration object. This object holds the Viper configuration and the logger, and is validated. The JIRA configuration is not yet initialized.

func (Config) FullSyncAlways

func (c Config) FullSyncAlways() bool

FullSyncAlways returns whether the application should rewrite the config file to set "since" to now or if it should always do a full sync from the given sync. Full sync is required for GitHubProjectBoard -> Jira State syncing. This is because moving a GitHub issue on the project board does not change the last updated time of the issue itself - only that of the project card.

func (Config) GetCompleteFieldKey

func (c Config) GetCompleteFieldKey(key FieldKey) string

GetCompleteFieldKey returns customfield_XXXXX, where XXXXX is the custom field ID (see GetFieldID).

func (Config) GetConfigFile

func (c Config) GetConfigFile() string

GetConfigFile returns the file that Viper loaded the configuration from.

func (Config) GetConfigString

func (c Config) GetConfigString(key string) string

GetConfigString returns a string value from the Viper configuration.

func (Config) GetDaemonPeriod

func (c Config) GetDaemonPeriod() time.Duration

GetDaemonPeriod returns the period on which the tool runs if in daemon mode.

func (Config) GetFieldID

func (c Config) GetFieldID(key FieldKey) string

GetFieldID returns the customfield ID of a JIRA custom field.

func (Config) GetFieldMapper

func (c Config) GetFieldMapper() FieldMapper

func (Config) GetLogger

func (c Config) GetLogger() logrus.Entry

GetLogger returns the configured application logger.

func (Config) GetProject

func (c Config) GetProject() jira.Project

GetProject returns the JIRA project the user has configured.

func (Config) GetProjectKey

func (c Config) GetProjectKey() string

GetProjectKey returns the JIRA key of the configured project.

func (Config) GetRepo

func (c Config) GetRepo() (string, string)

GetRepo returns the user/org name and the repo name of the configured GitHub repository.

func (Config) GetSinceParam

func (c Config) GetSinceParam() time.Time

GetSinceParam returns the `since` configuration parameter, parsed as a time.Time.

func (Config) GetTimeout

func (c Config) GetTimeout() time.Duration

GetTimeout returns the configured timeout on all API calls, parsed as a time.Duration.

func (Config) IsBasicAuth

func (c Config) IsBasicAuth() bool

IsBasicAuth is true if we're using HTTP Basic Authentication, and false if we're using OAuth.

func (Config) IsDaemon

func (c Config) IsDaemon() bool

IsDaemon returns whether the application is running as a daemon

func (Config) IsDryRun

func (c Config) IsDryRun() bool

IsDryRun returns whether the application is running in dry-run mode or not.

func (*Config) LoadJIRAConfig

func (c *Config) LoadJIRAConfig(client jira.Client) error

LoadJIRAConfig loads the JIRA configuration (project key, custom field IDs) from a remote JIRA server.

func (*Config) SaveConfig

func (c *Config) SaveConfig() error

SaveConfig updates the `since` parameter to now, then saves the configuration file.

func (Config) SetJIRAToken

func (c Config) SetJIRAToken(token *oauth1.Token)

SetJIRAToken adds the JIRA OAuth tokens in the Viper configuration, ensuring that they are saved for future runs.

type DefaultFieldMapper

type DefaultFieldMapper struct {
	Config *Config
}

func (DefaultFieldMapper) GetFieldIDs

func (m DefaultFieldMapper) GetFieldIDs(client jira.Client) (map[FieldKey]string, error)

func (DefaultFieldMapper) GetFieldValue

func (m DefaultFieldMapper) GetFieldValue(jIssue *jira.Issue, fieldKey FieldKey) (interface{}, error)

Default Field Mapper

func (DefaultFieldMapper) MapFields

func (m DefaultFieldMapper) MapFields(issue *models.ExtendedGithubIssue) (jira.IssueFields, error)

type FieldKey

type FieldKey int

fieldKey is an enum-like type to represent the customfield ID keys

const (
	GitHubID        FieldKey = iota
	GitHubNumber    FieldKey = iota
	GitHubLabels    FieldKey = iota
	GitHubStatus    FieldKey = iota
	GitHubReporter  FieldKey = iota
	GitHubCommits   FieldKey = iota
	LastISUpdate    FieldKey = iota
	GitHubIssueData FieldKey = iota
)

type FieldMapper

type FieldMapper interface {
	MapFields(issue *models.ExtendedGithubIssue) (jira.IssueFields, error)

	GetFieldValue(jIssue *jira.Issue, fieldKey FieldKey) (interface{}, error)

	// getFieldIDs requests the metadata of every issue field in the JIRA
	// project, and saves the IDs of the custom fields used by issue-sync.
	GetFieldIDs(client jira.Client) (map[FieldKey]string, error)
}

type JsonFieldMapper

type JsonFieldMapper struct {
	Config *Config
}

func (JsonFieldMapper) GetFieldIDs

func (m JsonFieldMapper) GetFieldIDs(client jira.Client) (map[FieldKey]string, error)

func (JsonFieldMapper) GetFieldValue

func (m JsonFieldMapper) GetFieldValue(jIssue *jira.Issue, fieldKey FieldKey) (interface{}, error)

Json Field Mapper

func (JsonFieldMapper) MapFields

func (m JsonFieldMapper) MapFields(issue *models.ExtendedGithubIssue) (jira.IssueFields, error)

type TestFieldMapper

type TestFieldMapper struct {
	HandleMapFields     func(issue *models.ExtendedGithubIssue) (jira.IssueFields, error)
	HandleGetFieldValue func(jIssue *jira.Issue, fieldKey FieldKey) (interface{}, error)
	HandleGetFieldIDs   func(client jira.Client) (map[FieldKey]string, error)
}

func (TestFieldMapper) GetFieldIDs

func (m TestFieldMapper) GetFieldIDs(client jira.Client) (map[FieldKey]string, error)

func (TestFieldMapper) GetFieldValue

func (m TestFieldMapper) GetFieldValue(jIssue *jira.Issue, fieldKey FieldKey) (interface{}, error)

func (TestFieldMapper) MapFields

func (m TestFieldMapper) MapFields(issue *models.ExtendedGithubIssue) (jira.IssueFields, error)

Jump to

Keyboard shortcuts

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