Skip to content

Commit

Permalink
Add configutil directory to metricsforwarder package spec
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed Aug 27, 2024
1 parent 905bf21 commit 4f29509
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
1 change: 1 addition & 0 deletions packages/metricsforwarder/spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ files:
- autoscaler/*
- autoscaler/vendor/*
- autoscaler/cf/* # gosub
- autoscaler/configutil/* # gosub
- autoscaler/cred_helper/* # gosub
- autoscaler/db/* # gosub
- autoscaler/db/sqldb/* # gosub
Expand Down
18 changes: 2 additions & 16 deletions src/autoscaler/metricsforwarder/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,20 @@ var _ = Describe("Config", func() {
Describe("LoadConfig", func() {

When("config is read from env", func() {
var vcapServicesJson string
var expectedDbUrl string

BeforeEach(func() {
mockVCAPConfigurationReader = &fakes.FakeVCAPConfigurationReader{}
})

AfterEach(func() {
os.Unsetenv("VCAP_SERVICES")
os.Unsetenv("PORT")
os.Unsetenv("VCAP_APPLICATION")
})

JustBeforeEach(func() {
os.Setenv("VCAP_APPLICATION", "{}")
os.Setenv("VCAP_SERVICES", vcapServicesJson)

mockVCAPConfigurationReader.IsRunningOnCFReturns(true)
mockVCAPConfigurationReader.MaterializeDBFromServiceReturns(expectedDbUrl, nil)
conf, err = LoadConfig(configFile, mockVCAPConfigurationReader)
})

When("PORT env variable is set to a number ", func() {
When("vcap PORT is set to a number ", func() {
BeforeEach(func() {
vcapServicesJson = `{ "user-provided": [ { "name": "config" } ] }`
mockVCAPConfigurationReader.GetPortReturns(3333)
})

Expand All @@ -72,10 +61,9 @@ var _ = Describe("Config", func() {
})
})

When("VCAP_SERVICES is empty", func() {
When("service is empty", func() {
var expectedErr error
BeforeEach(func() {
vcapServicesJson = "{}"
expectedErr = fmt.Errorf("Configuration error: metricsforwarder config service not found")
mockVCAPConfigurationReader.GetServiceCredentialContentReturns([]byte(""), expectedErr)
})
Expand All @@ -89,8 +77,6 @@ var _ = Describe("Config", func() {
var expectedTLSConfig models.TLSCerts

BeforeEach(func() {
vcapServicesJson = `{ "user-provided": [ { "name": "config", "credentials": { "metricsforwarder": { } } }] }`

expectedTLSConfig = models.TLSCerts{
CertFile: "/tmp/client_cert.sslcert",
KeyFile: "/tmp/client_key.sslkey",
Expand Down
2 changes: 2 additions & 0 deletions src/autoscaler/mta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ resources:
- name: config
type: org.cloudfoundry.user-provided-service
parameters:
service-tags:
- config
path: metricsforwarder/default_config.json
- name: policydb
type: org.cloudfoundry.user-provided-service
Expand Down

0 comments on commit 4f29509

Please sign in to comment.