func CheckConsistency(topicConfig TopicConfig, clusterConfig ClusterConfig) error {
	var err error
	if topicConfig.Meta.Cluster != clusterConfig.Meta.Name {
		err = multierror.Append(
			err,
			errors.New("Topic cluster name does not match name in cluster config"),
		)
	}
	if topicConfig.Meta.Environment != clusterConfig.Meta.Environment {
		err = multierror.Append(
			err,
			errors.New("Topic environment does not match cluster environment"),
		)
	}
	if topicConfig.Meta.Region != clusterConfig.Meta.Region {
		err = multierror.Append(
			err,
			errors.New("Topic region does not match cluster region"),
		)
	}
	return err
}
CheckConsistency verifies that the argument topic config is consistent with the argument
cluster, e.g. has the same environment and region, etc.
package config
import (
	"errors"
	"io/ioutil"
	"os"
	"path/filepath"
	"regexp"
	"strings"
	"github.com/ghodss/yaml"
	"github.com/hashicorp/go-multierror"
)
var sep = regexp.MustCompile("(?:^|\\s*\n)---\\s*")
func LoadClusterFile(path string) (ClusterConfig, error) {
	contents, err := ioutil.ReadFile(path)
	if err != nil {
		return ClusterConfig{}, err
	}
	contents = []byte(os.ExpandEnv(string(contents)))
	absPath, err := filepath.Abs(path)
	if err != nil {
		return ClusterConfig{}, err
	}
	config, err := LoadClusterBytes(contents)
	if err != nil {
		return ClusterConfig{}, err
	}
	config.RootDir = filepath.Dir(absPath)
	return config, nil
}
func LoadClusterBytes(contents []byte) (ClusterConfig, error) {
	config := ClusterConfig{}
	err := yaml.Unmarshal(contents, &config)
	return config, err
}
func LoadTopicsFile(path string) ([]TopicConfig, error) {
	contents, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	contents = []byte(os.ExpandEnv(string(contents)))
	trimmedFile := strings.TrimSpace(string(contents))
	topicStrs := sep.Split(trimmedFile, -1)
	topicConfigs := []TopicConfig{}
	for _, topicStr := range topicStrs {
		topicStr = strings.TrimSpace(topicStr)
		if isEmpty(topicStr) {
			continue
		}
		topicConfig, err := LoadTopicBytes([]byte(topicStr))
		if err != nil {
			return nil, err
		}
		topicConfigs = append(topicConfigs, topicConfig)
	}
	return topicConfigs, nil
}
func LoadTopicBytes(contents []byte) (TopicConfig, error) {
	config := TopicConfig{}
	err := yaml.Unmarshal(contents, &config)
	return config, err
}