Skip to content

Commit

Permalink
Merge branch 'beholders_eye/bug/ch1592/var-interpolation-fixes' into …
Browse files Browse the repository at this point in the history
…nextyb
  • Loading branch information
Ridai Govinda Pombo committed Jul 10, 2020
2 parents 592f40f + ebcf469 commit cbaa501
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,14 @@ func (r *Runtime) Shutdown(ctx context.Context) error {
}

func (r *Runtime) EnvironmentData() RuntimeEnvironmentData {
d := RuntimeEnvironmentData{
return RuntimeEnvironmentData{
Containers: ContainerData{
serviceCtx: r.ContainerServiceContext,
},
Services: ServiceData{
serviceCtx: r.ContainerServiceContext,
},
}

d.Containers.ip = make(map[string]string)
return d
}

type RuntimeEnvironmentData struct {
Expand All @@ -195,7 +192,6 @@ type ServiceData struct {
}

type ContainerData struct {
ip map[string]string
serviceCtx *narwhal.ServiceContext
}

Expand All @@ -207,8 +203,7 @@ func (c ContainerData) Environment(ctx context.Context) map[string]string {
for _, containerDef := range c.serviceCtx.ContainerDefinitions {
if ipv4, err := narwhal.IPv4Address(ctx, narwhal.DockerClient(), containerDef.Label); err == nil {
key := fmt.Sprintf("YB_CONTAINER_%s_IP", strings.ToUpper(containerDef.Label))
c.ip[containerDef.Label] = ipv4.String()
result[key] = c.ip[containerDef.Label]
result[key] = ipv4.String()
}
}
}
Expand All @@ -217,7 +212,14 @@ func (c ContainerData) Environment(ctx context.Context) map[string]string {

// IP returns an IP adress associated with an container "label"
func (c ContainerData) IP(label string) string {
return c.ip[label]
if c.serviceCtx != nil {
for _, containerDef := range c.serviceCtx.ContainerDefinitions {
if ipv4, err := narwhal.IPv4Address(context.Background(), narwhal.DockerClient(), containerDef.Label); err == nil {
return ipv4.String()
}
}
}
return ""
}

func HostOS() Os {
Expand Down

0 comments on commit cbaa501

Please sign in to comment.