Skip to content

Commit 7fa9789

Browse files
committed
Fix Dummy template formatting
When the webhook inject the default/dummy configuration, we get: oslo_config.cfg.ConfigFileParseError: Failed to parse This patch fixes that error providing proper formatting to the dummy string and adds an env test that catches issues for this particular scenario. Signed-off-by: Francesco Pantano <[email protected]>
1 parent d3646fd commit 7fa9789

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

api/v1beta1/glance_webhook.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ func (spec *GlanceSpec) isValidKeystoneEP() bool {
7474

7575
// GetTemplateBackend -
7676
func GetTemplateBackend() string {
77-
return fmt.Sprintf(`
78-
[DEFAULT]\n
79-
enabled_backends=backend1:type1 # CHANGE_ME
80-
`)
77+
section := "[DEFAULT]"
78+
dummyBackend := "enabled_backends=backend1:type1 # CHANGE_ME"
79+
return fmt.Sprintf("%s\n%s", section, dummyBackend)
8180
}
8281

8382
// Default - set defaults for this Glance spec

test/functional/glance_controller_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ var _ = Describe("Glance controller", func() {
225225
Expect(api.ContainerImage).To(Equal(util.GetEnvVar("RELATED_IMAGE_GLANCE_API_IMAGE_URL_DEFAULT", glancev1.GlanceAPIContainerImage)))
226226
}
227227
})
228+
It("has a dummy backend set when and empty spec is passed", func() {
229+
glanceDefault := GetGlance(glanceTest.Instance)
230+
Expect(glanceDefault.Spec.CustomServiceConfig).To((ContainSubstring(GlanceDummyBackend)))
231+
})
232+
228233
})
229234
When("All the Resources are ready", func() {
230235
BeforeEach(func() {

test/functional/glance_test_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
//CABundleSecretName -
3838
CABundleSecretName = "combined-ca-bundle"
3939
//GlanceDummyBackend -
40-
GlanceDummyBackend = "[DEFAULT]\nenabled_backends=foo:bar"
40+
GlanceDummyBackend = "enabled_backends=backend1:type1 # CHANGE_ME"
4141
)
4242

4343
// GlanceTestData is the data structure used to provide input data to envTest

0 commit comments

Comments
 (0)