diff --git a/bootcfg/http/ignition.go b/bootcfg/http/ignition.go index 069cfca3..23f164d7 100644 --- a/bootcfg/http/ignition.go +++ b/bootcfg/http/ignition.go @@ -39,13 +39,11 @@ func ignitionHandler(srv server.Server) ContextHandler { // Skip rendering if raw Ignition JSON is provided if isIgnition(profile.IgnitionId) { - cfg, err := ignition.Parse([]byte(contents)) + _, err := ignition.Parse([]byte(contents)) if err != nil { - log.Errorf("error parsing Ignition JSON: %v", err) - http.NotFound(w, req) - return + log.Warningf("warning parsing Ignition JSON: %v", err) } - renderJSON(w, cfg) + writeJSON(w, []byte(contents)) return } diff --git a/bootcfg/http/ignition_test.go b/bootcfg/http/ignition_test.go index 69f39a69..3c139f0f 100644 --- a/bootcfg/http/ignition_test.go +++ b/bootcfg/http/ignition_test.go @@ -19,7 +19,7 @@ var ( ) func TestIgnitionHandler_V2JSON(t *testing.T) { - content := `{"ignition":{"version":"2.0.0","config":{}},"systemd":{"units":[{"name":"etcd2.service","enable":true},{"name":"a1b2c3d4.service","enable":true}]}}` + content := `{"ignition":{"version":"2.0.0","config":{}},"storage":{},"systemd":{"units":[{"name":"etcd2.service","enable":true},{"name":"a1b2c3d4.service","enable":true}]},"networkd":{},"passwd":{}}` profile := &storagepb.Profile{ Id: fake.Group.Profile, IgnitionId: "file.ign", diff --git a/bootcfg/http/serialize.go b/bootcfg/http/serialize.go index d80f8ddf..9fba14d3 100644 --- a/bootcfg/http/serialize.go +++ b/bootcfg/http/serialize.go @@ -21,9 +21,13 @@ func renderJSON(w http.ResponseWriter, v interface{}) { w.WriteHeader(http.StatusInternalServerError) return } + writeJSON(w, js) +} +// writeJSON writes the given bytes with a JSON Content-Type. +func writeJSON(w http.ResponseWriter, data []byte) { w.Header().Set(contentType, jsonContentType) - _, err = w.Write(js) + _, err := w.Write(data) if err != nil { log.Errorf("error writing to response: %v", err) w.WriteHeader(http.StatusInternalServerError)