Skip to content

Commit

Permalink
added environment variable CF_INSTANCE_PORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
marsteg committed May 6, 2024
1 parent 0a89343 commit d513048
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ var _ = Describe("CFProcessReconciler Integration Tests", func() {
MatchFields(IgnoreExtras, Fields{"Name": Equal("VCAP_APP_PORT")}),
MatchFields(IgnoreExtras, Fields{"Name": Equal("VCAP_SERVICES")}),
MatchFields(IgnoreExtras, Fields{"Name": Equal("env-key")}),
MatchFields(IgnoreExtras, Fields{"Name": Equal("CF_INSTANCE_PORTS")}),
))
})
})
Expand Down
2 changes: 2 additions & 0 deletions controllers/controllers/workloads/env/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,11 @@ func (b *ProcessEnvBuilder) buildPortEnv(ctx context.Context, cfApp *korifiv1alp
processPorts := ports.FromRoutes(cfRoutesForProcess.Items, cfApp.Name, cfProcess.Spec.ProcessType)
if len(processPorts) > 0 {
portString := strconv.FormatInt(int64(processPorts[0]), 10)
cfInstancePorts := fmt.Sprintf("[{\"internal\":%s}]", portString)
return []corev1.EnvVar{
{Name: "VCAP_APP_PORT", Value: portString},
{Name: "PORT", Value: portString},
{Name: "CF_INSTANCE_PORTS", Value: cfInstancePorts},
}, nil
}

Expand Down
5 changes: 4 additions & 1 deletion controllers/controllers/workloads/env/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ var _ = Describe("EnvBuilder", func() {
"Name": Equal("PORT"),
"Value": Equal("1234"),
}),
MatchFields(IgnoreExtras, Fields{
"Name": Equal("CF_INSTANCE_PORTS"),
"Value": MatchJSON("[{\"internal\":1234}]"),
}),
))
})

When("the route does not have destinations", func() {
BeforeEach(func() {
ensurePatch(cfRoute, func(cfRoute *korifiv1alpha1.CFRoute) {
Expand Down

0 comments on commit d513048

Please sign in to comment.