Beispiel #1
0
// LoadConfig can be used to load versioning-related configuration for SalsaFlow.
func LoadConfig() (*Config, error) {
	task := "Load versioning-related configuration"
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, errs.NewError(task, err)
	}
	return spec.local.parse()
}
Beispiel #2
0
func loadConfig() (*moduleConfig, error) {
	// Load the config.
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, err
	}

	// Assemble the config object.
	return &moduleConfig{spec.global}, nil
}
Beispiel #3
0
func newGitHubClient() (*gh.Client, error) {
	task := "Instantiate a GitHub API client"

	// Get the access token.
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, errs.NewError(task, err)
	}

	// Return a new API client.
	return github.NewClient(spec.global.GitHubToken), nil
}
Beispiel #4
0
func loadConfig() (*moduleConfig, error) {
	task := fmt.Sprintf("Load config for module '%v'", ModuleId)

	// Load the config.
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, errs.NewError(task, err)
	}

	// Parse the main repo upstream URL.
	owner, repo, err := github.ParseUpstreamURL()
	if err != nil {
		return nil, errs.NewError(task, err)
	}

	// Assemble the config object.
	var (
		local  = spec.local
		global = spec.global
	)
	return &moduleConfig{
		GitHubOwner:           owner,
		GitHubRepository:      repo,
		UserToken:             global.UserToken,
		StoryLabels:           local.StoryLabels,
		ApprovedLabel:         local.StateLabels.ApprovedLabel,
		BeingImplementedLabel: local.StateLabels.BeingImplementedLabel,
		ImplementedLabel:      local.StateLabels.ImplementedLabel,
		ReviewedLabel:         local.StateLabels.ReviewedLabel,
		SkipReviewLabel:       local.StateLabels.SkipReviewLabel,
		PassedTestingLabel:    local.StateLabels.PassedTestingLabel,
		FailedTestingLabel:    local.StateLabels.FailedTestingLabel,
		SkipTestingLabel:      local.StateLabels.SkipTestingLabel,
		StagedLabel:           local.StateLabels.StagedLabel,
		RejectedLabel:         local.StateLabels.RejectedLabel,
		SkipCheckLabels:       local.SkipCheckLabels,
	}, nil
}
Beispiel #5
0
func loadConfig() (*moduleConfig, error) {
	// Load the config.
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, err
	}

	// Assemble the config object.
	var (
		local  = spec.local
		global = spec.global
	)
	return &moduleConfig{
		ProjectId:        local.ProjectId,
		ComponentLabel:   *local.ComponentLabel,
		PointMeLabel:     local.Labels.PointMeLabel,
		ReviewedLabel:    local.Labels.ReviewedLabel,
		SkipReviewLabel:  local.Labels.SkipReviewLabel,
		TestedLabel:      local.Labels.TestedLabel,
		SkipTestingLabel: local.Labels.SkipTestingLabel,
		SkipCheckLabels:  local.Labels.SkipCheckLabels,
		UserToken:        global.UserToken,
	}, nil
}
Beispiel #6
0
// LoadConfig can be used to load Git-related configuration for SalsaFlow.
func LoadConfig() (*Config, error) {
	// Load the configuration according to the spec.
	task := "Load Git-related configuration"
	spec := newConfigSpec()
	if err := loader.LoadConfig(spec); err != nil {
		return nil, errs.NewError(task, err)
	}

	// Get the remote name, which may be stored in git config.
	task = "Get the remote name for the main project repository"
	remoteName, err := GetConfigString(GitConfigKeyRemote)
	if err != nil {
		return nil, errs.NewError(task, err)
	}
	if remoteName == "" {
		remoteName = DefaultRemoteName
	}

	// Return the main config struct.
	return &Config{
		LocalConfig: *spec.local,
		RemoteName:  remoteName,
	}, nil
}