Merge pull request #1771 from bradrydzewski/master
choose ambassador by platform
This commit is contained in:
commit
a3303d5f5d
2 changed files with 38 additions and 5 deletions
|
@ -167,7 +167,7 @@ func (a *Agent) prep(w *queue.Work) (*yaml.Config, error) {
|
||||||
transform.ImageVolume(conf, []string{a.Local + ":" + conf.Workspace.Path})
|
transform.ImageVolume(conf, []string{a.Local + ":" + conf.Workspace.Path})
|
||||||
}
|
}
|
||||||
|
|
||||||
transform.Pod(conf)
|
transform.Pod(conf, a.Platform)
|
||||||
|
|
||||||
return conf, nil
|
return conf, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,21 +9,54 @@ import (
|
||||||
"github.com/gorilla/securecookie"
|
"github.com/gorilla/securecookie"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type ambassador struct {
|
||||||
|
image string
|
||||||
|
entrypoint []string
|
||||||
|
command []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// default linux amd64 ambassador
|
||||||
|
var defaultAmbassador = ambassador{
|
||||||
|
image: "busybox:latest",
|
||||||
|
entrypoint: []string{"/bin/sleep"},
|
||||||
|
command: []string{"86400"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// lookup ambassador configuration by architecture and os
|
||||||
|
var lookupAmbassador = map[string]ambassador{
|
||||||
|
"linux/amd64": {
|
||||||
|
image: "busybox:latest",
|
||||||
|
entrypoint: []string{"/bin/sleep"},
|
||||||
|
command: []string{"86400"},
|
||||||
|
},
|
||||||
|
"linux/arm": {
|
||||||
|
image: "armhf/alpine:latest",
|
||||||
|
entrypoint: []string{"/bin/sleep"},
|
||||||
|
command: []string{"86400"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Pod transforms the containers in the Yaml to use Pod networking, where every
|
// Pod transforms the containers in the Yaml to use Pod networking, where every
|
||||||
// container shares the localhost connection.
|
// container shares the localhost connection.
|
||||||
func Pod(c *yaml.Config) error {
|
func Pod(c *yaml.Config, platform string) error {
|
||||||
|
|
||||||
rand := base64.RawURLEncoding.EncodeToString(
|
rand := base64.RawURLEncoding.EncodeToString(
|
||||||
securecookie.GenerateRandomKey(8),
|
securecookie.GenerateRandomKey(8),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// choose the ambassador configuration based on os and architecture
|
||||||
|
conf, ok := lookupAmbassador[platform]
|
||||||
|
if !ok {
|
||||||
|
conf = defaultAmbassador
|
||||||
|
}
|
||||||
|
|
||||||
ambassador := &yaml.Container{
|
ambassador := &yaml.Container{
|
||||||
ID: fmt.Sprintf("drone_ambassador_%s", rand),
|
ID: fmt.Sprintf("drone_ambassador_%s", rand),
|
||||||
Name: "ambassador",
|
Name: "ambassador",
|
||||||
Image: "busybox:latest",
|
Image: conf.image,
|
||||||
Detached: true,
|
Detached: true,
|
||||||
Entrypoint: []string{"/bin/sleep"},
|
Entrypoint: conf.entrypoint,
|
||||||
Command: []string{"86400"},
|
Command: conf.command,
|
||||||
Volumes: []string{c.Workspace.Path, c.Workspace.Base},
|
Volumes: []string{c.Workspace.Path, c.Workspace.Base},
|
||||||
Environment: map[string]string{},
|
Environment: map[string]string{},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue