當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Deployment.AddDeployment方法代碼示例

本文整理匯總了Golang中rsprd/com/spread/pkg/deploy.Deployment.AddDeployment方法的典型用法代碼示例。如果您正苦於以下問題:Golang Deployment.AddDeployment方法的具體用法?Golang Deployment.AddDeployment怎麽用?Golang Deployment.AddDeployment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rsprd/com/spread/pkg/deploy.Deployment的用法示例。


在下文中一共展示了Deployment.AddDeployment方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Deployment

// Deployment is created using Deployments of child Entities
func (c *App) Deployment() (*deploy.Deployment, error) {
	d := new(deploy.Deployment)
	err := d.AddDeployment(c.objects)
	if err != nil {
		return nil, err
	}
	for _, entity := range c.children() {
		deploy, err := entity.Deployment()
		if err != nil {
			return nil, err
		}

		err = d.AddDeployment(*deploy)
		if err != nil {
			return nil, err
		}
	}
	return d, nil
}
開發者ID:redspread,項目名稱:spread,代碼行數:20,代碼來源:app.go

示例2: Deployment

// Deployment is created containing Pod with attached Containers.
func (c *Pod) Deployment() (*deploy.Deployment, error) {
	deployment := deploy.Deployment{}

	// create Pod from tree of Entities
	kubePod, childObj, err := c.data()
	if err != nil {
		return nil, err
	}

	// add Pod to deployment
	err = deployment.Add(kubePod)
	if err != nil {
		return nil, err
	}

	// add child objects
	err = deployment.AddDeployment(childObj)
	if err != nil {
		return nil, err
	}
	return &deployment, nil
}
開發者ID:redspread,項目名稱:spread,代碼行數:23,代碼來源:pod.go

示例3: Deployment

// Deployment is created for RC attached with it's Pod.
func (c *ReplicationController) Deployment() (*deploy.Deployment, error) {
	deployment := new(deploy.Deployment)

	// create RC
	kubeRC, childObj, err := c.data()
	if err != nil {
		return nil, err
	}

	// add RC to deployment
	err = deployment.Add(kubeRC)
	if err != nil {
		return nil, err
	}

	// add child objects
	err = deployment.AddDeployment(childObj)
	if err != nil {
		return nil, err
	}
	return deployment, nil
}
開發者ID:redspread,項目名稱:spread,代碼行數:23,代碼來源:replicationcontroller.go

示例4: TestRCAttachPod

func TestRCAttachPod(t *testing.T) {
	kubeContainer := kube.Container{
		Name:            "redis",
		Image:           "redis",
		ImagePullPolicy: kube.PullAlways,
	}
	selector := map[string]string{
		"app": "db",
	}

	// create ReplicationController
	rcObjects := testRandomObjects(10)
	rc := testNewRC(t, "container-test", selector, rcObjects)

	// create kube.Pod
	// create Pod from created pod
	kubePod := &kube.Pod{
		ObjectMeta: kube.ObjectMeta{Name: "attached"},
		Spec: kube.PodSpec{
			Containers: []kube.Container{
				kubeContainer,
			},
			RestartPolicy: kube.RestartPolicyAlways,
			DNSPolicy:     kube.DNSDefault,
		},
	}
	podObjects := testRandomObjects(10)
	pod, err := NewPod(kubePod, kube.ObjectMeta{}, "", podObjects...)
	assert.NoError(t, err, "should be valid pod")

	// Attach pod to RC
	// Should assume defaults up tree creating necessary components
	err = rc.Attach(pod)
	assert.NoError(t, err, "pod should be able to attach to ")
	children := rc.children()
	assert.Contains(t, children, pod, "should have image as child")

	// Compare internal elements
	assert.NotNil(t, rc.pod, "should of created pod")
	assert.Len(t, rc.pod.containers, 1)

	// Create struct representation for expected
	// Insert into Deployment
	// Create Deployment from RC
	rcMeta := rc.rc.ObjectMeta
	rcMeta.Namespace = kube.NamespaceDefault

	podMeta := pod.pod.ObjectMeta
	podMeta.Labels = selector
	expectedRC := &kube.ReplicationController{
		ObjectMeta: rcMeta,
		Spec: kube.ReplicationControllerSpec{
			Selector: selector,
			Template: &kube.PodTemplateSpec{
				ObjectMeta: kube.ObjectMeta{
					Namespace: kube.NamespaceDefault,
					Labels:    selector,
				},
				Spec: kubePod.Spec,
			},
		},
	}

	// Insert into Deployment
	expected := new(deploy.Deployment)
	err = expected.Add(expectedRC)
	assert.NoError(t, err, "should be valid RC")

	// add objects to deployment
	expected.AddDeployment(pod.objects)
	expected.AddDeployment(rc.objects)

	// Create Deployment from RC
	actual, err := rc.Deployment()
	assert.NoError(t, err, "should produce valid deployment")

	// Compare deployments
	testDeploymentEqual(t, expected, actual)

	// check images
	images := rc.Images()
	assert.Len(t, images, 1)
}
開發者ID:redspread,項目名稱:spread,代碼行數:83,代碼來源:replicationcontroller_test.go

示例5: TestRCAttachContainer

func TestRCAttachContainer(t *testing.T) {
	containerName := "attached"
	imageName := "embedded-image"
	selector := map[string]string{
		"app": "db",
	}

	// create ReplicationController
	rcObjects := testRandomObjects(10)
	rc := testNewRC(t, "container-test", selector, rcObjects)

	// create kube.Container
	// create Container from created container
	containerObjects := testRandomObjects(20)
	kubeContainer := testNewKubeContainer(containerName, imageName)
	container, err := NewContainer(kubeContainer, kube.ObjectMeta{}, "", containerObjects...)
	assert.NoError(t, err, "should be valid container")

	// Attach container to RC
	// Should assume defaults up tree creating necessary components
	err = rc.Attach(container)
	assert.NoError(t, err, "container should be able to attach to rc")

	// Compare internal elements
	assert.NotNil(t, rc.pod, "should of created pod")
	// assert.Len(t, rc.pod.containers, 1)

	// Create struct representation for expected
	// Insert into Deployment
	// Create Deployment from RC
	rcMeta := rc.rc.ObjectMeta
	rcMeta.Namespace = kube.NamespaceDefault
	expectedRC := &kube.ReplicationController{
		ObjectMeta: rcMeta,
		Spec: kube.ReplicationControllerSpec{
			Selector: selector,
			Template: &kube.PodTemplateSpec{
				ObjectMeta: kube.ObjectMeta{
					Labels:    selector,
					Namespace: kube.NamespaceDefault,
				},
				Spec: kube.PodSpec{
					Containers: []kube.Container{
						kubeContainer,
					},
					RestartPolicy: kube.RestartPolicyAlways,
					DNSPolicy:     kube.DNSDefault,
				},
			},
		},
	}

	// Insert into Deployment
	expected := new(deploy.Deployment)
	err = expected.Add(expectedRC)
	assert.NoError(t, err, "should be valid RC")

	// add objects to deployment
	expected.AddDeployment(container.objects)
	expected.AddDeployment(rc.objects)

	// Create Deployment from RC
	actual, err := rc.Deployment()
	assert.NoError(t, err, "should produce valid deployment")

	// Compare deployments
	testDeploymentEqual(t, expected, actual)

	// check images
	images := rc.Images()
	assert.Len(t, images, 1)
}
開發者ID:redspread,項目名稱:spread,代碼行數:72,代碼來源:replicationcontroller_test.go

示例6: TestRCAttachImage

func TestRCAttachImage(t *testing.T) {
	imageName := "rc-attach-image"
	rcName := "image-test"
	selector := map[string]string{
		"app": "cache",
	}

	// create ReplicationController
	rcObjects := testRandomObjects(10)
	rc := testNewRC(t, rcName, selector, rcObjects)

	// create Image
	imageObjects := testRandomObjects(10)
	imageEntity := testNewImage(t, imageName, kube.ObjectMeta{}, "", imageObjects)

	// Attach image to RC
	// Should assume defaults up tree creating necessary components
	err := rc.Attach(imageEntity)
	assert.NoError(t, err, "attachment should be allowed")

	// Compare internal elements
	assert.NotNil(t, rc.pod, "should of created template")

	// Create struct representation for expected
	expectedRC := &kube.ReplicationController{
		ObjectMeta: kube.ObjectMeta{
			Name:      rcName,
			Namespace: kube.NamespaceDefault,
		},
		Spec: kube.ReplicationControllerSpec{
			Selector: selector,
			Template: &kube.PodTemplateSpec{
				ObjectMeta: kube.ObjectMeta{
					Namespace: kube.NamespaceDefault,
					Labels:    selector,
				},
				Spec: kube.PodSpec{
					Containers: []kube.Container{
						{
							Name:            imageName,
							Image:           imageName,
							ImagePullPolicy: kube.PullAlways,
						},
					},
					RestartPolicy: kube.RestartPolicyAlways,
					DNSPolicy:     kube.DNSDefault,
				},
			},
		},
	}

	// Insert into Deployment
	expected := new(deploy.Deployment)
	err = expected.Add(expectedRC)
	assert.NoError(t, err, "should be valid RC")

	// add objects to deployment
	expected.AddDeployment(imageEntity.objects)
	expected.AddDeployment(rc.objects)

	// Create Deployment from RC
	actual, err := rc.Deployment()
	assert.NoError(t, err, "should produce valid deployment")

	// Compare deployments
	testDeploymentEqual(t, expected, actual)

	// check images
	images := rc.Images()
	expectedImage, _ := image.FromString(imageName)
	assert.Len(t, images, 1)
	for _, v := range images {
		assert.EqualValues(t, expectedImage, v, "should match original image")
	}
}
開發者ID:redspread,項目名稱:spread,代碼行數:75,代碼來源:replicationcontroller_test.go


注:本文中的rsprd/com/spread/pkg/deploy.Deployment.AddDeployment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。