Add PWD_HOST_FQDN env variable to instances.

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-06-14 19:02:07 -03:00
parent fa275b8ef4
commit 8f247794bb
4 changed files with 7 additions and 2 deletions

View File

@@ -206,6 +206,7 @@ type CreateContainerOpts struct {
ServerKey []byte
CACert []byte
Privileged bool
HostFQDN string
}
func (d *docker) CreateContainer(opts CreateContainerOpts) (string, error) {
@@ -256,6 +257,7 @@ func (d *docker) CreateContainer(opts CreateContainerOpts) (string, error) {
h.Resources.OomKillDisable = &t
env = append(env, fmt.Sprintf("PWD_IP_ADDRESS=%s", opts.PwdIpAddress))
env = append(env, fmt.Sprintf("PWD_HOST_FQDN=%s", opts.HostFQDN))
cf := &container.Config{Hostname: opts.Hostname,
Image: opts.Image,
Tty: true,

View File

@@ -13,7 +13,7 @@ func NewInstance(rw http.ResponseWriter, req *http.Request) {
vars := mux.Vars(req)
sessionId := vars["sessionId"]
body := pwd.InstanceConfig{}
body := pwd.InstanceConfig{Host: req.Host}
json.NewDecoder(req.Body).Decode(&body)

View File

@@ -66,6 +66,7 @@ type InstanceConfig struct {
CACert []byte
Cert []byte
Key []byte
Host string
}
func (i *Instance) setUsedPort(port uint16) {
@@ -223,6 +224,7 @@ func (p *pwd) InstanceNew(session *Session, conf InstanceConfig) (*Instance, err
ServerKey: conf.ServerKey,
CACert: conf.CACert,
Privileged: false,
HostFQDN: conf.Host,
}
for _, imageName := range p.InstanceAllowedImages() {

View File

@@ -57,7 +57,7 @@ func TestInstanceNew(t *testing.T) {
assert.Nil(t, err)
instance, err := p.InstanceNew(session, InstanceConfig{})
instance, err := p.InstanceNew(session, InstanceConfig{Host: "something.play-with-docker.com"})
assert.Nil(t, err)
@@ -83,6 +83,7 @@ func TestInstanceNew(t *testing.T) {
ServerKey: nil,
CACert: nil,
Privileged: true,
HostFQDN: "something.play-with-docker.com",
}
assert.Equal(t, expectedContainerOpts, containerOpts)
}