Beispiel #1
0
func createTaskPlans(controller *task.TaskDefinitionController, projectDir string) []*plan.TaskUpdatePlan {

	taskDefs := controller.GetTaskDefinitionMap()
	plans := controller.CreateTaskUpdatePlans(taskDefs)

	for _, plan := range plans {
		logger.Main.Infof("Task Definition '%s'", plan.Name)

		for _, add := range plan.NewContainers {
			util.PrintlnCyan(fmt.Sprintf("    (+) %s", add.Name))
			util.PrintlnCyan(fmt.Sprintf("      image: %s", add.Image))
			util.PrintlnCyan(fmt.Sprintf("      ports: %s", add.Ports))
			util.PrintlnCyan(fmt.Sprintf("      environment:\n%s", util.StringValueWithIndent(add.Environment, 4)))
			util.PrintlnCyan(fmt.Sprintf("      links: %s", add.Links))
			util.PrintlnCyan(fmt.Sprintf("      volumes: %s", add.Volumes))
		}

		util.Println()
	}

	return plans
}
Beispiel #2
0
func createBlueGreenPlans(controller *bluegreen.BlueGreenController, jsonOutput bool) ([]*plan.BlueGreenPlan, error) {

	if jsonOutput {
		util.Output = false
		defer func() {
			util.Output = true
		}()
	}

	bgmap := controller.GetBlueGreenMap()

	cplans, errcp := controller.ClusterController.CreateServiceUpdatePlans()
	if errcp != nil {
		return []*plan.BlueGreenPlan{}, errcp
	}

	bgplans, errbgp := controller.CreateBlueGreenPlans(bgmap, cplans)
	if errbgp != nil {
		return bgplans, errbgp
	}

	jsonItems := []BlueGreenPlanJson{}
	for _, bgplan := range bgplans {
		util.PrintlnCyan("    Blue:")
		util.PrintlnCyan(fmt.Sprintf("        Cluster = %s", bgplan.Blue.NewService.Cluster))
		util.PrintlnCyan(fmt.Sprintf("        AutoScalingGroupARN = %s", *bgplan.Blue.AutoScalingGroup.AutoScalingGroupARN))
		util.PrintlnCyan("        Current services as follows:")
		for _, bcs := range bgplan.Blue.ClusterUpdatePlan.CurrentServices {
			util.PrintlnCyan(fmt.Sprintf("            %s:", *bcs.ServiceName))
			util.PrintlnCyan(fmt.Sprintf("                ServiceARN = %s", *bcs.ServiceARN))
			util.PrintlnCyan(fmt.Sprintf("                TaskDefinition = %s", *bcs.TaskDefinition))
			util.PrintlnCyan(fmt.Sprintf("                DesiredCount = %d", *bcs.DesiredCount))
			util.PrintlnCyan(fmt.Sprintf("                PendingCount = %d", *bcs.PendingCount))
			util.PrintlnCyan(fmt.Sprintf("                RunningCount = %d", *bcs.RunningCount))
		}

		var active string
		if bgplan.IsBlueWithPrimaryElb() {
			active = "blue"
		} else {
			active = "green"
		}

		util.PrintlnGreen("    Green:")
		util.PrintlnGreen(fmt.Sprintf("        Cluster = %s", bgplan.Green.NewService.Cluster))
		util.PrintlnGreen(fmt.Sprintf("        AutoScalingGroupARN = %s", *bgplan.Green.AutoScalingGroup.AutoScalingGroupARN))
		util.PrintlnGreen("        Current services as follows:")
		for _, gcs := range bgplan.Green.ClusterUpdatePlan.CurrentServices {
			util.PrintlnGreen(fmt.Sprintf("            %s:", *gcs.ServiceName))
			util.PrintlnGreen(fmt.Sprintf("                ServiceARN = %s", *gcs.ServiceARN))
			util.PrintlnGreen(fmt.Sprintf("                TaskDefinition = %s", *gcs.TaskDefinition))
			util.PrintlnGreen(fmt.Sprintf("                DesiredCount = %d", *gcs.DesiredCount))
			util.PrintlnGreen(fmt.Sprintf("                PendingCount = %d", *gcs.PendingCount))
			util.PrintlnGreen(fmt.Sprintf("                RunningCount = %d", *gcs.RunningCount))
		}

		util.Println()

		jsonItems = append(jsonItems, BlueGreenPlanJson{

			Blue: BlueGreenServiceJson{
				ClusterARN:          *bgplan.Blue.CurrentService.ClusterARN,
				AutoScalingGroupARN: *bgplan.Blue.AutoScalingGroup.AutoScalingGroupARN,
				Instances:           bgplan.Blue.AutoScalingGroup.Instances,
				TaskDefinition:      *bgplan.Blue.CurrentService.TaskDefinition,
				DesiredCount:        *bgplan.Blue.CurrentService.DesiredCount,
				PendingCount:        *bgplan.Blue.CurrentService.PendingCount,
				RunningCount:        *bgplan.Blue.CurrentService.RunningCount,
			},
			Green: BlueGreenServiceJson{
				ClusterARN:          *bgplan.Green.CurrentService.ClusterARN,
				AutoScalingGroupARN: *bgplan.Green.AutoScalingGroup.AutoScalingGroupARN,
				Instances:           bgplan.Green.AutoScalingGroup.Instances,
				TaskDefinition:      *bgplan.Green.CurrentService.TaskDefinition,
				DesiredCount:        *bgplan.Green.CurrentService.DesiredCount,
				PendingCount:        *bgplan.Green.CurrentService.PendingCount,
				RunningCount:        *bgplan.Green.CurrentService.RunningCount,
			},
			PrimaryElb: bgplan.PrimaryElb,
			StandbyElb: bgplan.StandbyElb,
			Active:     active,
		})
	}

	if jsonOutput {
		bt, err := json.Marshal(&jsonItems)
		if err != nil {
			return bgplans, err
		}
		fmt.Println(string(bt))
	}

	return bgplans, nil
}