Skip to content

Commit

Permalink
Add PWD_HOST_FQDN env variable to instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
xetorthio committed Jun 14, 2017
1 parent fa275b8 commit 8f24779
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ type CreateContainerOpts struct {
ServerKey []byte
CACert []byte
Privileged bool
HostFQDN string
}

func (d *docker) CreateContainer(opts CreateContainerOpts) (string, error) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion handlers/new_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions pwd/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type InstanceConfig struct {
CACert []byte
Cert []byte
Key []byte
Host string
}

func (i *Instance) setUsedPort(port uint16) {
Expand Down Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion pwd/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}
Expand Down

0 comments on commit 8f24779

Please sign in to comment.