diff --git a/cmd/config_load.go b/cmd/config_load.go index 52e8897..de40ce5 100644 --- a/cmd/config_load.go +++ b/cmd/config_load.go @@ -54,14 +54,6 @@ var configLoadCmd = &cobra.Command{ } switch configFormat { - case types.ConfigFormatJson, types.ConfigFormatJsonIetf, types.ConfigFormatXml: - // TODO: - // lc.SetFlags() - rawParam.SetName(intentName).SetPrio(priority) - // if data is comming from stdin, store it in data - if strings.TrimSpace(configurationFile) == "-" { - rawParam.SetData(configByte) - } case types.ConfigFormatSdc: sdcC, err := LoadSDCConfigCR(configByte) @@ -83,6 +75,14 @@ var configLoadCmd = &cobra.Command{ if err != nil { return err } + default: + // TODO: + // lc.SetFlags() + rawParam.SetName(intentName).SetPrio(priority) + // if data is comming from stdin, store it in data + if strings.TrimSpace(configurationFile) == "-" { + rawParam.SetData(configByte) + } } // if pipelineFile is set, then we need to generate just the pieline instruction equivalent of the actual command and exist diff --git a/pkg/configdiff/configdiff.go b/pkg/configdiff/configdiff.go index 1a8cc97..be5464b 100644 --- a/pkg/configdiff/configdiff.go +++ b/pkg/configdiff/configdiff.go @@ -365,7 +365,14 @@ func (c *ConfigDiff) TreeLoadData(ctx context.Context, cl *params.ConfigLoad) er return err } importer = treejson.NewJsonTreeImporter(j) - + case types.ConfigFormatYaml: + var y any + err = yaml.Unmarshal(intent.GetData(), &y) + if err != nil { + return err + } + // we use json importer since we're based basically on map[string]any + importer = treejson.NewJsonTreeImporter(y) case types.ConfigFormatXml: xmlDoc := etree.NewDocument() err := xmlDoc.ReadFromBytes(intent.GetData()) @@ -373,6 +380,8 @@ func (c *ConfigDiff) TreeLoadData(ctx context.Context, cl *params.ConfigLoad) er return err } importer = treexml.NewXmlTreeImporter(&xmlDoc.Element) + default: + return fmt.Errorf("import of format %s not supported yet", intent.GetFormat().String()) } // overwrite running intent with running prio