// BuildDeploymentGroup converts a list of api Services into a deployment group.
//
// Generates the unique identifier for the marathon group, investigates the
// services dependencies, and converts the services into a list of gomarathon Applications.
967182
func (m MarathonDeployer) BuildDeploymentGroup(services []*api.Service, client gomarathonClientAbstractor) *deploymentGroup {
	var deployments = make([]deployment, len(services))
	g := m.generateUniqueUID(client)

	dependents := m.findDependencies(services)
	for i := range services {
		if dependents[services[i].Name] != 0 {
			services[i].Deployment.Count = 1
		}

		m.prepareServiceForDeployment(g, services[i])
		deployments[i] = createDeployment(services[i], client)
	}

	myGroup := new(deploymentGroup)
	myGroup.deployments = deployments

	return myGroup
}
158628
func (s *Deployment) SetDeploymentType(v string) *Deployment {
	s.DeploymentType = &v
	return s
}
1292122
func (s *Service) SetDeployments(v []*Deployment) *Service {
	s.Deployments = v
	return s
}
347667
func (r *marathonClient) UpdateGroup(name string, group *Group, force bool) (*DeploymentID, error) {
	deploymentID := new(DeploymentID)
	path := fmt.Sprintf("%s/%s", marathonAPIGroups, trimRootPath(name))
	if force {
		path += "?force=true"
	}
	if err := r.apiPut(path, group, deploymentID); err != nil {
		return nil, err
	}

	return deploymentID, nil
}
773432
func (s *CreateDeploymentGroupInput) SetDeploymentGroupName(v string) *CreateDeploymentGroupInput {
	s.DeploymentGroupName = &v
	return s
}
332179
func (d *dataSet) ListDeployments() ([]*corev1.ReplicationController, error) {
	results := []*corev1.ReplicationController{}
	for _, item := range d.deploymentIndexer.List() {
		results = append(results, item.(*corev1.ReplicationController))
	}
	return results, nil
}
198301
func RunDeploy(dockerCli *KubeCli, opts options.Deploy, cfg *composetypes.Config) error {
	cmdOut := dockerCli.Out()

	// Initialize clients
	composeClient, err := dockerCli.composeClient()
	if err != nil {
		return err
	}
	stacks, err := composeClient.Stacks(false)
	if err != nil {
		return err
	}

	stack, err := stacks.FromCompose(dockerCli.Err(), opts.Namespace, cfg)
	if err != nil {
		return err
	}

	configMaps := composeClient.ConfigMaps()
	secrets := composeClient.Secrets()
	services := composeClient.Services()

	if err := stacks.IsColliding(services, stack); err != nil {
		return err
	}

	if err := createResources(stack, stacks, configMaps, secrets); err != nil {
		return err
	}

	fmt.Fprintln(cmdOut, "Waiting for the stack to be stable and running...")
	v1beta1Cli, err := dockerCli.stacksv1beta1()
	if err != nil {
		return err
	}

	pods := composeClient.Pods()
	watcher := &deployWatcher{
		stacks: v1beta1Cli,
		pods:   pods,
	}
	statusUpdates := make(chan serviceStatus)
	displayDone := make(chan struct{})
	go func() {
		defer close(displayDone)
		display := newStatusDisplay(dockerCli.Out())
		for status := range statusUpdates {
			display.OnStatus(status)
		}
	}()

	err = watcher.Watch(stack.Name, stack.getServices(), statusUpdates)
	close(statusUpdates)
	<-displayDone
	if err != nil {
		return err
	}
	fmt.Fprintf(cmdOut, "\nStack %s is stable and running\n\n", stack.Name)
	return nil

}
900472
func (s *ContinueDeploymentInput) SetDeploymentWaitType(v string) *ContinueDeploymentInput {
	s.DeploymentWaitType = &v
	return s
}
120482
func (s *InstanceSummary) SetDeploymentId(v string) *InstanceSummary {
	s.DeploymentId = &v
	return s
}
304971
func (c *Client) GetDeployment(deploymentID string) (*ct.Deployment, error) {
	res := &ct.Deployment{}
	return res, c.Get(fmt.Sprintf("/deployments/%s", deploymentID), res)
}
292350
func cmdRepairDeployment(params Parameters) *subcommands.Command {
	return &subcommands.Command{
		Advanced:  true,
		UsageLine: "deployment-repair [options]",
		ShortDesc: "attempts to repair a deployment if it is broken",
		LongDesc:  "This is equivalent of running 'ensure' in paranoia.",
		CommandRun: func() subcommands.CommandRun {
			c := &repairDeploymentRun{}
			c.registerBaseFlags()
			c.clientOptions.registerFlags(&c.Flags, params, withRootDir)
			return c
		},
	}
}
1348456
func (s *CreateDeploymentInput) SetDeploymentGroupName(v string) *CreateDeploymentInput {
	s.DeploymentGroupName = &v
	return s
}
626867
func (c *CoreScheduler) deploymentReap(deployments []string) error {
	// Call to the leader to issue the reap
	for _, req := range c.partitionDeploymentReap(deployments) {
		var resp structs.GenericResponse
		if err := c.srv.RPC("Deployment.Reap", req, &resp); err != nil {
			c.logger.Error("deployment reap failed", "error", err)
			return err
		}
	}

	return nil
}
984357
func newDeployment(foo *samplev1alpha1.Foo) *appsv1.Deployment {
	labels := map[string]string{
		"app":        "nginx",
		"controller": foo.Name,
	}
	return &appsv1.Deployment{
		ObjectMeta: metav1.ObjectMeta{
			Name:      foo.Spec.DeploymentName,
			Namespace: foo.Namespace,
			OwnerReferences: []metav1.OwnerReference{
				*metav1.NewControllerRef(foo, samplev1alpha1.SchemeGroupVersion.WithKind("Foo")),
			},
		},
		Spec: appsv1.DeploymentSpec{
			Replicas: foo.Spec.Replicas,
			Selector: &metav1.LabelSelector{
				MatchLabels: labels,
			},
			Template: corev1.PodTemplateSpec{
				ObjectMeta: metav1.ObjectMeta{
					Labels: labels,
				},
				Spec: corev1.PodSpec{
					Containers: []corev1.Container{
						{
							Name:  "nginx",
							Image: "nginx:latest",
						},
					},
				},
			},
		},
	}
}
167052
func (s *DeploymentGroupInfo) SetDeploymentGroupName(v string) *DeploymentGroupInfo {
	s.DeploymentGroupName = &v
	return s
}
917796
func (b *DockerBuilder) buildDockerGroup() *nodetasks.GroupTask {
	return &nodetasks.GroupTask{
		Name:   "docker",
		System: true,
	}
}
1137796
func (s *ListDeploymentGroupsOutput) SetDeploymentGroups(v []*string) *ListDeploymentGroupsOutput {
	s.DeploymentGroups = v
	return s
}