mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-03 01:54:29 +00:00
bug: Fix validator on long strings (#1194)
* 🐛 Fix validator on long strings Validator was mistakenly identifying a long yaml as a file and trying to open it, which failed with an error of filename too long. This was not catched in order to identify that the source is not a file but a yaml, so it was directly returning the error. This patch adds that error to the list in order ot identify the source to validate as yaml. Also adds a couple of tests for this functionality. Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com> * 🐛 Merge initramfs generation between distros Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com> --------- Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
@@ -24,6 +24,21 @@ var _ = Describe("Validate", func() {
|
||||
Context("Validate", func() {
|
||||
var yaml string
|
||||
|
||||
Context("With a really long config string", func() {
|
||||
BeforeEach(func() {
|
||||
yaml = `#cloud-config
|
||||
users:
|
||||
- name: kairos
|
||||
passwd: kairos
|
||||
vpn:
|
||||
network_token: "dssdnfjkldashfkjhasdkhfkasjdhfkjhasdjkfhaksjdhfkjashjdkfhioreqwhfuihqweruifhuewrbfhuewrfuyequfhuiehuifheqrihfuiqrehfuirqheiufhreqiuhfuiqheiufhqeuihfuiqrehfiuhqreuifrhiuqehfiuhqeirhfiuewhrfhqwehfriuewhfuihewiuhfruewhrifhwiuehrfiuhweiurfhwueihrfuiwehufhweuihrfuiwerhfuihewruifhewuihfiouwehrfiouhwei"
|
||||
`
|
||||
})
|
||||
It("validates", func() {
|
||||
Expect(Validate(yaml)).ToNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("with a valid config", func() {
|
||||
BeforeEach(func() {
|
||||
yaml = `#cloud-config
|
||||
@@ -32,7 +47,7 @@ users:
|
||||
passwd: kairos`
|
||||
})
|
||||
|
||||
It("is successful", func() {
|
||||
It("is successful reading it from file", func() {
|
||||
f, err := ioutil.TempDir("", "tests")
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
defer os.RemoveAll(f)
|
||||
@@ -43,6 +58,9 @@ users:
|
||||
err = Validate(path)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
It("is successful reading it from a string", func() {
|
||||
Expect(Validate(yaml)).ToNot(HaveOccurred())
|
||||
})
|
||||
})
|
||||
|
||||
Context("without a header", func() {
|
||||
|
Reference in New Issue
Block a user