示例#1
0
func LoadConfig() (Config, error) {
	// Try the cache first.
	if configCache != nil {
		return configCache, nil
	}

	// Unmarshal.
	var global GlobalConfig
	if err := config.UnmarshalGlobalConfig(&global); err != nil {
		return nil, err
	}
	if err := global.validate(); err != nil {
		return nil, err
	}

	var local LocalConfig
	if err := config.UnmarshalLocalConfig(&local); err != nil {
		return nil, err
	}
	if local.GitHub.ReviewLabel == "" {
		local.GitHub.ReviewLabel = DefaultReviewIssueLabel
	}

	// Save the new instance into the cache and return.
	configCache = &configProxy{
		apiToken:         global.GitHub.Token,
		reviewIssueLabel: local.GitHub.ReviewLabel,
	}
	return configCache, nil
}
示例#2
0
func LoadConfig() (Config, error) {
	// Try the cache first.
	if configCache != nil {
		return configCache, nil
	}

	// Load the local config.
	var local LocalConfig
	if err := config.UnmarshalLocalConfig(&local); err != nil {
		return nil, err
	}

	labels := &local.PT.Labels
	if labels.PointMeLabel == "" {
		labels.PointMeLabel = DefaultPointMeLabel
	}
	if labels.ImplementedLabel == "" {
		labels.ImplementedLabel = DefaultImplementedLabel
	}
	if labels.NoReviewLabel == "" {
		labels.NoReviewLabel = DefaultNoReviewLabel
	}
	if labels.ReviewedLabel == "" {
		labels.ReviewedLabel = DefaultReviewedLabel
	}
	labels.SkipCheckLabels = append(labels.SkipCheckLabels, DefaultSkipCheckLabels...)

	if err := local.validate(); err != nil {
		return nil, err
	}

	// Load the global config.
	var global GlobalConfig
	if err := config.UnmarshalGlobalConfig(&global); err != nil {
		return nil, err
	}
	if err := global.validate(); err != nil {
		return nil, err
	}

	// Load git config.
	storyFilter, err := git.GetConfigString("salsaflow.pivotaltracker.include-stories")
	if err != nil {
		return nil, err
	}

	var storyFilterRe *regexp.Regexp
	if storyFilter != "" {
		var err error
		storyFilterRe, err = regexp.Compile(storyFilter)
		if err != nil {
			return nil, err
		}
	}

	configCache = &configProxy{&local, &global, storyFilterRe}
	return configCache, nil
}
示例#3
0
func LoadConfig() (Config, error) {
	// Try the cache first.
	if configCache != nil {
		return configCache, nil
	}

	// Load the local config.
	var local LocalConfig
	if err := config.UnmarshalLocalConfig(&local); err != nil {
		return nil, err
	}

	tags := &local.Sprintly.Tags
	if tags.NoReviewTag == "" {
		tags.NoReviewTag = DefaultNoReviewTag
	}
	if tags.ReviewedTag == "" {
		tags.ReviewedTag = DefaultReviewedTag
	}

	envs := &local.Sprintly.Environments
	if envs.Staging == "" {
		envs.Staging = DefaultStagingEnvironment
	}
	if envs.Production == "" {
		envs.Production = DefaultProductionEnvironment
	}

	if err := local.validate(); err != nil {
		return nil, err
	}

	// Load the global config.
	var global GlobalConfig
	if err := config.UnmarshalGlobalConfig(&global); err != nil {
		return nil, err
	}
	if err := global.validate(); err != nil {
		return nil, err
	}

	configCache = &configProxy{&local, &global}
	return configCache, nil
}
示例#4
0
func LoadConfig() (Config, error) {
	// Try the cache first.
	if configCache != nil {
		return configCache, nil
	}

	// Create a new configProxy instance.
	proxy := &configProxy{&GlobalConfig{}}
	if err := config.UnmarshalGlobalConfig(proxy.global); err != nil {
		return nil, err
	}
	if err := proxy.global.validate(); err != nil {
		return nil, err
	}

	// Save the new instance into the cache and return.
	configCache = proxy
	return proxy, nil
}