From 2714cbed691149e9ad82e5ceebcd1395608f4967 Mon Sep 17 00:00:00 2001 From: Laurent Luce Date: Wed, 10 Jul 2024 14:35:16 +0200 Subject: [PATCH] Fix manifest parsing --- kardinal-cli/cmd/root.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kardinal-cli/cmd/root.go b/kardinal-cli/cmd/root.go index 01d693e2..b2c46782 100644 --- a/kardinal-cli/cmd/root.go +++ b/kardinal-cli/cmd/root.go @@ -186,7 +186,10 @@ func parseKubernetesManifestFile(kubernetesManifestFile string) ([]api_types.Ser manifest := string(fileBytes) // TODO: Check format of manifest file blocks := strings.Split(manifest, "---") - serviceConfigs := make([]api_types.ServiceConfig, len(blocks)) + if len(blocks) % 2 != 0 { + return nil, stacktrace.NewError("The manifest should contain pairs of service / deployment specifications") + } + serviceConfigs := make([]api_types.ServiceConfig, len(blocks) / 2) decode := scheme.Codecs.UniversalDeserializer().Decode for index, spec := range strings.Split(manifest, "---") { if len(spec) == 0 {