コード例 #1
0
ファイル: commands.go プロジェクト: takasing/ecs-formation
func doCluster(c *cli.Context) {

	ecsManager, err := buildECSManager()

	if err != nil {
		fmt.Fprintf(os.Stderr, "[ERROR]%s\n", color.Red(err.Error()))
		os.Exit(1)
	}

	operation, errSubCommand := createOperation(c.Args())

	if errSubCommand != nil {
		fmt.Fprintf(os.Stderr, "[ERROR]%s\n", color.Red(errSubCommand.Error()))
		os.Exit(1)
	}

	projectDir, err := os.Getwd()
	if err != nil {
		panic(err)
	}

	clusterController := cluster.ClusterControler{
		Ecs:            ecsManager,
		TargetResource: operation.TargetResource,
	}

	plans := createClusterPlans(&clusterController, projectDir)

	if operation.SubCommand == "apply" {
		clusterController.ApplyClusterPlans(plans)
	}
}