Fix parsing cmdline when keys have a dash (#73)

* Fix parsing cmdline when keys have a dash

If a key has a dash we need to add quotes to it before parsing it with
gojq, otherwise it will fail AND the full cmdline will not be parsed!

Signed-off-by: Itxaka <itxaka@kairos.io>

* Actualizar bootcmdline_test.go

---------

Signed-off-by: Itxaka <itxaka@kairos.io>
This commit is contained in:
Itxaka
2024-03-18 17:28:31 +01:00
committed by GitHub
parent 1c55cf24d3
commit e50888d054
2 changed files with 25 additions and 4 deletions

View File

@@ -24,5 +24,16 @@ var _ = Describe("BootCMDLine", func() {
Expect(string(b)).To(Equal("baz:\n bar: \"\"\nconfig_url: foo bar\n"), string(b))
})
It("works if cmdline contains a dash or underscore", func() {
f, err := os.CreateTemp("", "test")
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(f.Name())
err = os.WriteFile(f.Name(), []byte(`config-url="foo bar" ba_z.bar=""`), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
_, err = DotToYAML(f.Name())
Expect(err).ToNot(HaveOccurred())
})
})
})