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


Golang parse.ContainerNode類代碼示例

本文整理匯總了Golang中github.com/drone/drone/engine/compiler/parse.ContainerNode的典型用法代碼示例。如果您正苦於以下問題:Golang ContainerNode類的具體用法?Golang ContainerNode怎麽用?Golang ContainerNode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: validateConfig

// validate the container configuration and return an error if
// restricted configurations are used.
func (v *validateOp) validateConfig(node *parse.ContainerNode) error {
	if v.trusted {
		return nil
	}
	if node.Container.Privileged {
		return fmt.Errorf("Insufficient privileges to use privileged mode")
	}
	if len(node.Container.DNS) != 0 {
		return fmt.Errorf("Insufficient privileges to use custom dns")
	}
	if len(node.Container.DNSSearch) != 0 {
		return fmt.Errorf("Insufficient privileges to use dns_search")
	}
	if len(node.Container.Devices) != 0 {
		return fmt.Errorf("Insufficient privileges to use devices")
	}
	if len(node.Container.ExtraHosts) != 0 {
		return fmt.Errorf("Insufficient privileges to use extra_hosts")
	}
	if len(node.Container.Network) != 0 {
		return fmt.Errorf("Insufficient privileges to override the network")
	}
	if node.Container.OomKillDisable {
		return fmt.Errorf("Insufficient privileges to disable oom_kill")
	}
	if len(node.Container.Volumes) != 0 && node.Type() != parse.NodeCache {
		return fmt.Errorf("Insufficient privileges to use volumes")
	}
	if len(node.Container.VolumesFrom) != 0 {
		return fmt.Errorf("Insufficient privileges to use volumes_from")
	}
	return nil
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:35,代碼來源:validate.go

示例2: visitMatrix

func (v *filterOp) visitMatrix(node *parse.ContainerNode) {
	for key, val := range node.Conditions.Matrix {
		if v.matrix[key] != val {
			node.Disabled = true
			break
		}
	}
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:8,代碼來源:filter.go

示例3: visitEvent

// visitEvent is a helper function that disables container steps
// when the build event conditions are not satisfied.
func (v *filterOp) visitEvent(node *parse.ContainerNode) {
	if len(node.Conditions.Event) == 0 {
		return
	}
	for _, pattern := range node.Conditions.Event {
		if ok, _ := filepath.Match(pattern, v.event); ok {
			return
		}
	}
	node.Disabled = true
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:13,代碼來源:filter.go

示例4: visitPlatform

// visitPlatform is a helper function that disables container steps
// when the build event conditions are not satisfied.
func (v *filterOp) visitPlatform(node *parse.ContainerNode) {
	if len(node.Conditions.Platform) == 0 {
		return
	}
	for _, pattern := range node.Conditions.Platform {
		if ok, _ := filepath.Match(pattern, v.platform); ok {
			return
		}
	}
	node.Disabled = true
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:13,代碼來源:filter.go

示例5: VisitContainer

func (v *cacheOp) VisitContainer(node *parse.ContainerNode) error {
	if node.Type() != parse.NodeCache {
		return nil
	}
	if len(node.Vargs) == 0 || v.enable == false {
		node.Disabled = true
		return nil
	}

	if node.Container.Name == "" {
		node.Container.Name = "cache"
	}
	if node.Container.Image == "" {
		node.Container.Image = v.plugin
	}

	// discard any other cache properties except the image name.
	// everything else is discard for security reasons.
	node.Container = runner.Container{
		Name:  node.Container.Name,
		Alias: node.Container.Alias,
		Image: node.Container.Image,
		Volumes: []string{
			v.mount + ":/cache",
		},
	}

	// this is a hack until I can come up with a better solution.
	// this copies the clone name, and appends at the end of the
	// build. When it is executed a second time the build should
	// have a completed status, so it knows to cache instead
	// of restore.
	cache := node.Root().NewCacheNode()
	cache.Vargs = node.Vargs
	cache.Container = node.Container
	node.Root().Script = append(node.Root().Script, cache)
	return nil
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:38,代碼來源:cache.go

示例6: VisitContainer

func (v *shellOp) VisitContainer(node *parse.ContainerNode) error {
	if node.NodeType != parse.NodeShell {
		return nil
	}

	node.Container.Entrypoint = []string{
		"/bin/sh", "-c",
	}
	node.Container.Command = []string{
		"echo $DRONE_SCRIPT | base64 -d | /bin/sh -e",
	}
	if node.Container.Environment == nil {
		node.Container.Environment = map[string]string{}
	}
	node.Container.Environment["HOME"] = "/root"
	node.Container.Environment["SHELL"] = "/bin/sh"
	node.Container.Environment["DRONE_SCRIPT"] = toScript(
		node.Root().Path,
		node.Commands,
	)

	return nil
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:23,代碼來源:shell.go

示例7: VisitContainer

func (v *cloneOp) VisitContainer(node *parse.ContainerNode) error {
	if node.Type() != parse.NodeClone {
		return nil
	}
	if v.enable == false {
		node.Disabled = true
		return nil
	}

	if node.Container.Name == "" {
		node.Container.Name = "clone"
	}
	if node.Container.Image == "" {
		node.Container.Image = v.plugin
	}

	// discard any other cache properties except the image name.
	// everything else is discard for security reasons.
	node.Container = runner.Container{
		Name:  node.Container.Name,
		Image: node.Container.Image,
	}
	return nil
}
開發者ID:tnaoto,項目名稱:drone,代碼行數:24,代碼來源:clone.go


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