From 683389a55e0905bade26ac93d992dcb419c23abc Mon Sep 17 00:00:00 2001 From: Armel Soro Date: Mon, 13 Mar 2023 09:45:03 +0100 Subject: [PATCH] WIP - Parse Devfiles without flattening When flattening, the Devfile parser seems to set the default values for unset fields (like deployByDefault or autoBuild). This makes it hard to determine cases where the component needs to be applied automatically (e.g., deployByDefault not set and component not referenced by any Apply commands). However, this also creates other issues when handling child Devfiles with Parents. So needs to be discussed.. --- pkg/devfile/devfile.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/devfile/devfile.go b/pkg/devfile/devfile.go index 92e468ce0c2..31cbb2fcd9f 100644 --- a/pkg/devfile/devfile.go +++ b/pkg/devfile/devfile.go @@ -2,11 +2,11 @@ package devfile import ( "fmt" - "strings" "github.com/devfile/library/v2/pkg/devfile" "github.com/devfile/library/v2/pkg/devfile/parser" + "k8s.io/utils/pointer" "github.com/redhat-developer/odo/pkg/devfile/validate" "github.com/redhat-developer/odo/pkg/log" @@ -44,7 +44,10 @@ func parseDevfile(args parser.ParserArgs) (parser.DevfileObj, error) { // ParseAndValidateFromFile reads, parses and validates devfile from a file // if there are warning it logs them on stdout func ParseAndValidateFromFile(devfilePath string) (parser.DevfileObj, error) { - return parseDevfile(parser.ParserArgs{Path: devfilePath}) + return parseDevfile(parser.ParserArgs{ + Path: devfilePath, + FlattenedDevfile: pointer.Bool(false), + }) } // ParseAndValidateFromFileWithVariables reads, parses and validates devfile from a file @@ -54,6 +57,7 @@ func ParseAndValidateFromFileWithVariables(devfilePath string, variables map[str return parseDevfile(parser.ParserArgs{ Path: devfilePath, ExternalVariables: variables, + FlattenedDevfile: pointer.Bool(false), }) }