func buildCluster(name, path, profile, profileFileName string) *dcluster.Cluster { fileName := name if fileName == "" { fileName = DEFAULT_CLUSTER_FILE } if profileFileName == "" { profileFileName = DEFAULT_PROFILE_FILE } file := "" seperator := "/" if strings.HasSuffix(path, seperator) { file = path + fileName } else { file = path + seperator + fileName } cluster, err := dcluster.NewCluster(file, profile, profileFileName) if err != nil { if os.IsNotExist(err) { fmt.Printf("Cannot locate Clusterfile: '%s'\n", file) } else { fmt.Printf("Read Clusterfile '%s' error: '%s'\n", file, err.Error()) } os.Exit(1) } return cluster }
func TestCheckAndApplyProfile(t *testing.T) { file := "../cluster.aliyun.usertag.multiprofile.yml" profile := "../profile.yml" cluster, err := cluster.NewCluster(file, "", profile) if err != nil { t.Errorf("Parse Cluster Failed:%s\n", err.Error()) } t.Logf("Cluster Parsed:\n%+v", cluster) }