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


Golang Container.RootFSPath方法代碼示例

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


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

示例1:

							It("emits a completed container event", func() {
								var event executor.Event
								Eventually(containerEventPoller(eventSource, &event), 5).Should(Equal(executor.EventTypeContainerComplete))

								completeEvent := event.(executor.ContainerCompleteEvent)
								Expect(completeEvent.Container().State).To(Equal(executor.StateCompleted))
								Expect(completeEvent.Container().RunResult.Failed).To(BeTrue())
								Expect(completeEvent.Container().RunResult.FailureReason).To(Equal("Exited with status 1"))
							})
						})
					})
				})

				Context("when the container cannot be created", func() {
					BeforeEach(func() {
						container.RootFSPath = "gopher://example.com"
					})

					It("does not immediately return an error", func() {
						Expect(runErr).NotTo(HaveOccurred())
					})

					Context("when listening for events", func() {
						It("eventually completes with failure", func() {
							Eventually(containerStatePoller(guid)).Should(Equal(executor.StateCompleted))

							container := getContainer(guid)
							Expect(container.RunResult.Failed).To(BeTrue())
							Expect(container.RunResult.FailureReason).To(Equal("failed to initialize container"))
						})
					})
開發者ID:Gerg,項目名稱:inigo,代碼行數:31,代碼來源:executor_garden_test.go

示例2: garden2executor

func garden2executor(handle string, info garden.ContainerInfo) (executor.Container, error) {
	executorContainer := executor.Container{
		Guid:       handle,
		Tags:       executor.Tags{},
		ExternalIP: info.ExternalIP,
	}

	executorContainer.Ports = make([]executor.PortMapping, len(info.MappedPorts))

	for key, value := range info.Properties {
		switch key {
		case ContainerStateProperty:
			state := executor.State(value)

			if state == executor.StateReserved ||
				state == executor.StateInitializing ||
				state == executor.StateCreated ||
				state == executor.StateRunning ||
				state == executor.StateCompleted {
				executorContainer.State = state
			} else {
				return executor.Container{}, InvalidStateError{value}
			}
		case ContainerAllocatedAtProperty:
			_, err := fmt.Sscanf(value, "%d", &executorContainer.AllocatedAt)
			if err != nil {
				return executor.Container{}, MalformedPropertyError{
					Property: ContainerAllocatedAtProperty,
					Value:    value,
				}
			}
		case ContainerRootfsProperty:
			executorContainer.RootFSPath = value
		case ContainerLogProperty:
			err := json.Unmarshal([]byte(value), &executorContainer.LogConfig)
			if err != nil {
				return executor.Container{}, InvalidJSONError{
					Property:     key,
					Value:        value,
					UnmarshalErr: err,
				}
			}
		case ContainerMetricsConfigProperty:
			err := json.Unmarshal([]byte(value), &executorContainer.MetricsConfig)
			if err != nil {
				return executor.Container{}, InvalidJSONError{
					Property:     key,
					Value:        value,
					UnmarshalErr: err,
				}
			}
		case ContainerResultProperty:
			err := json.Unmarshal([]byte(value), &executorContainer.RunResult)
			if err != nil {
				return executor.Container{}, InvalidJSONError{
					Property:     key,
					Value:        value,
					UnmarshalErr: err,
				}
			}
		case ContainerMemoryMBProperty:
			memoryMB, err := strconv.Atoi(value)
			if err != nil {
				return executor.Container{}, MalformedPropertyError{
					Property: key,
					Value:    value,
				}
			}

			executorContainer.MemoryMB = memoryMB
		case ContainerDiskMBProperty:
			diskMB, err := strconv.Atoi(value)
			if err != nil {
				return executor.Container{}, MalformedPropertyError{
					Property: key,
					Value:    value,
				}
			}

			executorContainer.DiskMB = diskMB
		case ContainerCPUWeightProperty:
			cpuWeight, err := strconv.Atoi(value)
			if err != nil {
				return executor.Container{}, MalformedPropertyError{
					Property: key,
					Value:    value,
				}
			}

			executorContainer.CPUWeight = uint(cpuWeight)
		case ContainerStartTimeoutProperty:
			startTimeout, err := strconv.Atoi(value)
			if err != nil {
				return executor.Container{}, MalformedPropertyError{
					Property: key,
					Value:    value,
				}
			}

			executorContainer.StartTimeout = uint(startTimeout)
//.........這裏部分代碼省略.........
開發者ID:snowsnail,項目名稱:executor,代碼行數:101,代碼來源:exchanger.go


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