コード例 #1
0
ファイル: script.go プロジェクト: fracting/drone-exec
// Encode encodes the build script as a command in the
// provided Container config. For linux, the build script
// is embedded as the container entrypoint command, base64
// encoded as a one-line script.
func Encode(w *plugin.Workspace, c *dockerclient.ContainerConfig, n *parser.DockerNode) {
	var buf bytes.Buffer
	buf.WriteString(setupScript)
	buf.WriteString(forceYesScript)

	if w != nil && w.Keys != nil && w.Netrc != nil {
		buf.WriteString(writeKey(
			w.Keys.Private,
		))
		buf.WriteString(writeNetrc(
			w.Netrc.Machine,
			w.Netrc.Login,
			w.Netrc.Password,
		))
	}

	if len(n.Shell) > 0 {
		buf.WriteString(fmt.Sprintf("%s << \"EOF\"", n.Shell))
	}

	buf.WriteString(writeCmds(n.Commands))

	if len(n.Shell) > 0 {
		buf.WriteString("EOF")
	}

	buf.WriteString(teardownScript)

	c.Entrypoint = entrypoint
	c.Cmd = []string{encode(buf.Bytes())}
}
コード例 #2
0
ファイル: build.go プロジェクト: fracting/drone-exec
func maybeEscalate(conf dockerclient.ContainerConfig, node *parser.DockerNode) {
	if node.Image == "plugins/drone-docker" || node.Image == "plugins/drone-gcr" || node.Image == "plugins/drone-ecr" {
		return
	}
	conf.Volumes = nil
	conf.HostConfig.NetworkMode = ""
	conf.HostConfig.Privileged = true
	conf.Entrypoint = []string{}
	conf.Cmd = []string{}
}