Skip to content
This repository was archived by the owner on Sep 22, 2020. It is now read-only.

Commit 1e71b27

Browse files
committed
main: handle unknown version case
If Ignition was unable to parse the config as an Ignition Config, Cloud Config, or script, it will return ErrUnknownVersion. This was ignored before which resulted in the validator claiming that the config was valid. This catches that case and returns an error.
1 parent 038f4eb commit 1e71b27

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

validate.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
"github.com/coreos/coreos-cloudinit/config/validate"
2828
ignConfig "github.com/coreos/ignition/config"
29+
"github.com/coreos/ignition/config/validate/report"
2930
"github.com/crawford/nap"
3031
"github.com/gorilla/mux"
3132
)
@@ -102,6 +103,13 @@ func putValidate(r *http.Request) (interface{}, nap.Status) {
102103
return nil, nap.InternalError{err.Error()}
103104
}
104105
return rpt.Entries(), nap.OK{}
106+
case ignConfig.ErrUnknownVersion:
107+
return report.Report{
108+
Entries: []report.Entry{{
109+
Kind: report.EntryError,
110+
Message: "Failed to parse config. Is this a valid Ignition Config, Cloud-Config, or script?",
111+
}},
112+
}, nap.OK{}
105113
default:
106114
rpt.Sort()
107115
return rpt.Entries, nap.OK{}

0 commit comments

Comments
 (0)