Skip to content

Commit

Permalink
Update CF_INSTANCE_PORT and CF_INSTANCE_ADDR tests so they pass regar…
Browse files Browse the repository at this point in the history
…dless of unproxied port configuration
  • Loading branch information
geofffranks authored and ctlong committed Sep 24, 2024
1 parent 7d7e3bf commit 8eb69a4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 29 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ include_app_syslog_tcp
* `private_docker_registry_password`: Password to access the private docker repository. [See below](#private-docker)
* `unallocated_ip_for_security_group`: An unused IP address in the private network used by CF. Defaults to 10.0.244.255. [See below](#container-networking-and-application-security-groups)

* `require_proxied_app_traffic`: Set this to `true` if Diego was configured to require proxied port mappings, i.e. if `containers.proxy.enable_unproxied_port_mappings` is set to `false`.

* `staticfile_buildpack_name` [See below](#buildpack-names)
* `java_buildpack_name` [See below](#buildpack-names)
* `ruby_buildpack_name` [See below](#buildpack-names)
Expand Down
15 changes: 5 additions & 10 deletions apps/default_environment_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,11 @@ exit 1
"VCAP_APP_PORT",
)

if Config.GetRequireProxiedAppTraffic() {
assertNotPresent(env,
"CF_INSTANCE_ADDR",
"CF_INSTANCE_PORT",
)
} else {
assertPresent(env,
"CF_INSTANCE_ADDR",
"CF_INSTANCE_PORT",
)
if v, ok := env["CF_INSTANCE_PORT"]; ok && v != "" {
Expect(v).To(MatchRegexp(`[0-9]+`))
}
if v, ok := env["CF_INSTANCE_ADDR"]; ok && v != "" {
Expect(v).To(MatchRegexp(`[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+`))
}

if Config.GetIncludeTasks() {
Expand Down
4 changes: 1 addition & 3 deletions apps/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,10 @@ var _ = AppsDescribe("Application Lifecycle", func() {
Expect(len(ports)).NotTo(BeZero())
Expect(ports[0].Internal).NotTo(BeZero())

if Config.GetRequireProxiedAppTraffic() {
Expect(ports[0].External).To(BeNil())
if ports[0].External == nil {
Expect(envValues.Port).To(BeZero())
Expect(envValues.Addr).To(BeZero())
} else {
Expect(ports[0].External).NotTo(BeNil())
Expect(*ports[0].External).NotTo(BeZero())
Expect(envValues.Port).To(MatchRegexp(`[0-9]+`))
Expect(envValues.Addr).To(MatchRegexp(`[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+`))
Expand Down
1 change: 0 additions & 1 deletion helpers/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ type CatsConfig interface {
GetRBuildpackName() string
GetRubyBuildpackName() string
GetUnallocatedIPForSecurityGroup() string
GetRequireProxiedAppTraffic() bool
GetDynamicASGsEnabled() bool
GetCommaDelimitedASGsEnabled() bool
GetReadinessHealthChecksEnabled() bool
Expand Down
6 changes: 0 additions & 6 deletions helpers/config/config_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ type config struct {
PublicDockerAppImage *string `json:"public_docker_app_image"`

UnallocatedIPForSecurityGroup *string `json:"unallocated_ip_for_security_group"`
RequireProxiedAppTraffic *bool `json:"require_proxied_app_traffic"`

DynamicASGsEnabled *bool `json:"dynamic_asgs_enabled"`
CommaDelimitedASGsEnabled *bool `json:"comma_delim_asgs_enabled"`
Expand Down Expand Up @@ -235,7 +234,6 @@ func getDefaults() config {
defaults.PublicDockerAppImage = ptrToString("cloudfoundry/diego-docker-app:latest")

defaults.UnallocatedIPForSecurityGroup = ptrToString("10.0.244.255")
defaults.RequireProxiedAppTraffic = ptrToBool(false)

defaults.DynamicASGsEnabled = ptrToBool(true)
defaults.CommaDelimitedASGsEnabled = ptrToBool(false)
Expand Down Expand Up @@ -1109,10 +1107,6 @@ func (c *config) GetUnallocatedIPForSecurityGroup() string {
return *c.UnallocatedIPForSecurityGroup
}

func (c *config) GetRequireProxiedAppTraffic() bool {
return *c.RequireProxiedAppTraffic
}

func (c *config) GetStacks() []string {
return *c.Stacks
}
Expand Down
7 changes: 0 additions & 7 deletions helpers/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ type testConfig struct {
IsolationSegmentDomain *string `json:"isolation_segment_domain,omitempty"`

UnallocatedIPForSecurityGroup *string `json:"unallocated_ip_for_security_group"`
RequireProxiedAppTraffic *bool `json:"require_proxied_app_traffic"`

UseWindowsTestTask *bool `json:"use_windows_test_task,omitempty"`
UseWindowsContextPath *bool `json:"use_windows_context_path,omitempty"`
Expand Down Expand Up @@ -188,7 +187,6 @@ type nullConfig struct {
Stacks *[]string `json:"stacks"`

UnallocatedIPForSecurityGroup *string `json:"unallocated_ip_for_security_group"`
RequireProxiedAppTraffic *bool `json:"require_proxied_app_traffic"`
UseWindowsContextPath *bool `json:"use_windows_context_path"`
UseWindowsTestTask *bool `json:"use_windows_test_task"`
}
Expand Down Expand Up @@ -345,8 +343,6 @@ var _ = Describe("Config", func() {
Expect(config.GetCredHubBrokerClientCredential()).To(Equal("credhub_admin_client"))
Expect(config.GetCredHubLocation()).To(Equal("https://credhub.service.cf.internal:8844"))

Expect(config.GetRequireProxiedAppTraffic()).To(BeFalse())

Expect(config.GetStacks()).To(ConsistOf("cflinuxfs4"))

Expect(config.GetBinaryBuildpackName()).To(Equal("binary_buildpack"))
Expand Down Expand Up @@ -441,7 +437,6 @@ var _ = Describe("Config", func() {

// These values are allowed to be null
Expect(err.Error()).NotTo(ContainSubstring("unallocated_ip_for_security_group"))
Expect(err.Error()).NotTo(ContainSubstring("require_proxied_app_traffic"))
Expect(err.Error()).NotTo(ContainSubstring("use_windows_context_path"))
Expect(err.Error()).NotTo(ContainSubstring("reporter_config"))
Expect(err.Error()).NotTo(ContainSubstring("use_windows_test_task"))
Expand All @@ -461,7 +456,6 @@ var _ = Describe("Config", func() {
testCfg.SleepTimeout = ptrToInt(101)
testCfg.TimeoutScale = ptrToFloat(1.0)
testCfg.UnallocatedIPForSecurityGroup = ptrToString("192.168.0.1")
testCfg.RequireProxiedAppTraffic = ptrToBool(true)

testCfg.IncludeAppSyslogTcp = ptrToBool(false)
testCfg.IncludeApps = ptrToBool(false)
Expand Down Expand Up @@ -524,7 +518,6 @@ var _ = Describe("Config", func() {
Expect(config.SleepTimeoutDuration()).To(Equal(101 * time.Second))
Expect(config.SleepTimeoutDuration()).To(Equal(101 * time.Second))
Expect(config.GetUnallocatedIPForSecurityGroup()).To(Equal("192.168.0.1"))
Expect(config.GetRequireProxiedAppTraffic()).To(BeTrue())

Expect(config.GetIncludeAppSyslogTcp()).To(BeFalse())
Expect(config.GetIncludeApps()).To(BeFalse())
Expand Down

0 comments on commit 8eb69a4

Please sign in to comment.